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 |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 349 | #define _loop0_126_type 1278 |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 350 | #define _tmp_127_type 1279 |
| 351 | #define _tmp_128_type 1280 |
| 352 | #define _tmp_129_type 1281 |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 353 | #define _tmp_130_type 1282 |
| 354 | #define _loop0_131_type 1283 |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 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 |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 368 | #define _tmp_145_type 1297 |
| 369 | #define _loop1_146_type 1298 |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 370 | #define _tmp_147_type 1299 |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 371 | #define _tmp_148_type 1300 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 372 | |
| 373 | static mod_ty file_rule(Parser *p); |
| 374 | static mod_ty interactive_rule(Parser *p); |
| 375 | static mod_ty eval_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 376 | static mod_ty func_type_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 377 | static expr_ty fstring_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 378 | static asdl_seq* type_expressions_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 379 | static asdl_seq* statements_rule(Parser *p); |
| 380 | static asdl_seq* statement_rule(Parser *p); |
| 381 | static asdl_seq* statement_newline_rule(Parser *p); |
| 382 | static asdl_seq* simple_stmt_rule(Parser *p); |
| 383 | static stmt_ty small_stmt_rule(Parser *p); |
| 384 | static stmt_ty compound_stmt_rule(Parser *p); |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 385 | static stmt_ty assignment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 386 | static AugOperator* augassign_rule(Parser *p); |
| 387 | static stmt_ty global_stmt_rule(Parser *p); |
| 388 | static stmt_ty nonlocal_stmt_rule(Parser *p); |
| 389 | static stmt_ty yield_stmt_rule(Parser *p); |
| 390 | static stmt_ty assert_stmt_rule(Parser *p); |
| 391 | static stmt_ty del_stmt_rule(Parser *p); |
| 392 | static stmt_ty import_stmt_rule(Parser *p); |
| 393 | static stmt_ty import_name_rule(Parser *p); |
| 394 | static stmt_ty import_from_rule(Parser *p); |
| 395 | static asdl_seq* import_from_targets_rule(Parser *p); |
| 396 | static asdl_seq* import_from_as_names_rule(Parser *p); |
| 397 | static alias_ty import_from_as_name_rule(Parser *p); |
| 398 | static asdl_seq* dotted_as_names_rule(Parser *p); |
| 399 | static alias_ty dotted_as_name_rule(Parser *p); |
| 400 | static expr_ty dotted_name_rule(Parser *p); |
| 401 | static stmt_ty if_stmt_rule(Parser *p); |
| 402 | static stmt_ty elif_stmt_rule(Parser *p); |
| 403 | static asdl_seq* else_block_rule(Parser *p); |
| 404 | static stmt_ty while_stmt_rule(Parser *p); |
| 405 | static stmt_ty for_stmt_rule(Parser *p); |
| 406 | static stmt_ty with_stmt_rule(Parser *p); |
| 407 | static withitem_ty with_item_rule(Parser *p); |
| 408 | static stmt_ty try_stmt_rule(Parser *p); |
| 409 | static excepthandler_ty except_block_rule(Parser *p); |
| 410 | static asdl_seq* finally_block_rule(Parser *p); |
| 411 | static stmt_ty return_stmt_rule(Parser *p); |
| 412 | static stmt_ty raise_stmt_rule(Parser *p); |
| 413 | static stmt_ty function_def_rule(Parser *p); |
| 414 | static stmt_ty function_def_raw_rule(Parser *p); |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 415 | static Token* func_type_comment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 416 | static arguments_ty params_rule(Parser *p); |
| 417 | static arguments_ty parameters_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 418 | static asdl_seq* slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 419 | static SlashWithDefault* slash_with_default_rule(Parser *p); |
| 420 | static StarEtc* star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 421 | static arg_ty kwds_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 422 | static arg_ty param_no_default_rule(Parser *p); |
| 423 | static NameDefaultPair* param_with_default_rule(Parser *p); |
| 424 | static NameDefaultPair* param_maybe_default_rule(Parser *p); |
| 425 | static arg_ty param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 426 | static expr_ty annotation_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 427 | static expr_ty default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 428 | static asdl_seq* decorators_rule(Parser *p); |
| 429 | static stmt_ty class_def_rule(Parser *p); |
| 430 | static stmt_ty class_def_raw_rule(Parser *p); |
| 431 | static asdl_seq* block_rule(Parser *p); |
| 432 | static asdl_seq* expressions_list_rule(Parser *p); |
| 433 | static expr_ty star_expressions_rule(Parser *p); |
| 434 | static expr_ty star_expression_rule(Parser *p); |
| 435 | static asdl_seq* star_named_expressions_rule(Parser *p); |
| 436 | static expr_ty star_named_expression_rule(Parser *p); |
| 437 | static expr_ty named_expression_rule(Parser *p); |
| 438 | static expr_ty annotated_rhs_rule(Parser *p); |
| 439 | static expr_ty expressions_rule(Parser *p); |
| 440 | static expr_ty expression_rule(Parser *p); |
| 441 | static expr_ty lambdef_rule(Parser *p); |
| 442 | static arguments_ty lambda_parameters_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 443 | static asdl_seq* lambda_slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 444 | static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); |
| 445 | static StarEtc* lambda_star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 446 | static arg_ty lambda_kwds_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 447 | static arg_ty lambda_param_no_default_rule(Parser *p); |
| 448 | static NameDefaultPair* lambda_param_with_default_rule(Parser *p); |
| 449 | static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); |
| 450 | static arg_ty lambda_param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 451 | static expr_ty disjunction_rule(Parser *p); |
| 452 | static expr_ty conjunction_rule(Parser *p); |
| 453 | static expr_ty inversion_rule(Parser *p); |
| 454 | static expr_ty comparison_rule(Parser *p); |
| 455 | static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); |
| 456 | static CmpopExprPair* eq_bitwise_or_rule(Parser *p); |
| 457 | static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); |
| 458 | static CmpopExprPair* lte_bitwise_or_rule(Parser *p); |
| 459 | static CmpopExprPair* lt_bitwise_or_rule(Parser *p); |
| 460 | static CmpopExprPair* gte_bitwise_or_rule(Parser *p); |
| 461 | static CmpopExprPair* gt_bitwise_or_rule(Parser *p); |
| 462 | static CmpopExprPair* notin_bitwise_or_rule(Parser *p); |
| 463 | static CmpopExprPair* in_bitwise_or_rule(Parser *p); |
| 464 | static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); |
| 465 | static CmpopExprPair* is_bitwise_or_rule(Parser *p); |
| 466 | static expr_ty bitwise_or_rule(Parser *p); |
| 467 | static expr_ty bitwise_xor_rule(Parser *p); |
| 468 | static expr_ty bitwise_and_rule(Parser *p); |
| 469 | static expr_ty shift_expr_rule(Parser *p); |
| 470 | static expr_ty sum_rule(Parser *p); |
| 471 | static expr_ty term_rule(Parser *p); |
| 472 | static expr_ty factor_rule(Parser *p); |
| 473 | static expr_ty power_rule(Parser *p); |
| 474 | static expr_ty await_primary_rule(Parser *p); |
| 475 | static expr_ty primary_rule(Parser *p); |
| 476 | static expr_ty slices_rule(Parser *p); |
| 477 | static expr_ty slice_rule(Parser *p); |
| 478 | static expr_ty atom_rule(Parser *p); |
| 479 | static expr_ty strings_rule(Parser *p); |
| 480 | static expr_ty list_rule(Parser *p); |
| 481 | static expr_ty listcomp_rule(Parser *p); |
| 482 | static expr_ty tuple_rule(Parser *p); |
| 483 | static expr_ty group_rule(Parser *p); |
| 484 | static expr_ty genexp_rule(Parser *p); |
| 485 | static expr_ty set_rule(Parser *p); |
| 486 | static expr_ty setcomp_rule(Parser *p); |
| 487 | static expr_ty dict_rule(Parser *p); |
| 488 | static expr_ty dictcomp_rule(Parser *p); |
| 489 | static asdl_seq* kvpairs_rule(Parser *p); |
| 490 | static KeyValuePair* kvpair_rule(Parser *p); |
| 491 | static asdl_seq* for_if_clauses_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 492 | static comprehension_ty for_if_clause_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 493 | static expr_ty yield_expr_rule(Parser *p); |
| 494 | static expr_ty arguments_rule(Parser *p); |
| 495 | static expr_ty args_rule(Parser *p); |
| 496 | static asdl_seq* kwargs_rule(Parser *p); |
| 497 | static expr_ty starred_expression_rule(Parser *p); |
| 498 | static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); |
| 499 | static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); |
| 500 | static expr_ty star_targets_rule(Parser *p); |
| 501 | static asdl_seq* star_targets_seq_rule(Parser *p); |
| 502 | static expr_ty star_target_rule(Parser *p); |
| 503 | static expr_ty star_atom_rule(Parser *p); |
| 504 | static expr_ty inside_paren_ann_assign_target_rule(Parser *p); |
| 505 | static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p); |
| 506 | static asdl_seq* del_targets_rule(Parser *p); |
| 507 | static expr_ty del_target_rule(Parser *p); |
| 508 | static expr_ty del_t_atom_rule(Parser *p); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 509 | static void *del_target_end_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 510 | static asdl_seq* targets_rule(Parser *p); |
| 511 | static expr_ty target_rule(Parser *p); |
| 512 | static expr_ty t_primary_rule(Parser *p); |
| 513 | static void *t_lookahead_rule(Parser *p); |
| 514 | static expr_ty t_atom_rule(Parser *p); |
| 515 | static void *incorrect_arguments_rule(Parser *p); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 516 | static void *invalid_kwarg_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 517 | static void *invalid_named_expression_rule(Parser *p); |
| 518 | static void *invalid_assignment_rule(Parser *p); |
| 519 | static void *invalid_block_rule(Parser *p); |
| 520 | static void *invalid_comprehension_rule(Parser *p); |
| 521 | static void *invalid_parameters_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 522 | static void *invalid_star_etc_rule(Parser *p); |
| 523 | static void *invalid_lambda_star_etc_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 524 | static void *invalid_double_type_comments_rule(Parser *p); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 525 | static void *invalid_del_target_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 526 | static asdl_seq *_loop0_1_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 527 | static asdl_seq *_loop0_2_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 528 | static asdl_seq *_loop0_4_rule(Parser *p); |
| 529 | static asdl_seq *_gather_3_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 530 | static asdl_seq *_loop0_6_rule(Parser *p); |
| 531 | static asdl_seq *_gather_5_rule(Parser *p); |
| 532 | static asdl_seq *_loop0_8_rule(Parser *p); |
| 533 | static asdl_seq *_gather_7_rule(Parser *p); |
| 534 | static asdl_seq *_loop0_10_rule(Parser *p); |
| 535 | static asdl_seq *_gather_9_rule(Parser *p); |
| 536 | static asdl_seq *_loop1_11_rule(Parser *p); |
| 537 | static asdl_seq *_loop0_13_rule(Parser *p); |
| 538 | static asdl_seq *_gather_12_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 539 | static void *_tmp_14_rule(Parser *p); |
| 540 | static void *_tmp_15_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 541 | static void *_tmp_16_rule(Parser *p); |
| 542 | static void *_tmp_17_rule(Parser *p); |
| 543 | static void *_tmp_18_rule(Parser *p); |
| 544 | static void *_tmp_19_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 545 | static void *_tmp_20_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 546 | static void *_tmp_21_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 547 | static asdl_seq *_loop1_22_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 548 | static void *_tmp_23_rule(Parser *p); |
| 549 | static void *_tmp_24_rule(Parser *p); |
| 550 | static asdl_seq *_loop0_26_rule(Parser *p); |
| 551 | static asdl_seq *_gather_25_rule(Parser *p); |
| 552 | static asdl_seq *_loop0_28_rule(Parser *p); |
| 553 | static asdl_seq *_gather_27_rule(Parser *p); |
| 554 | static void *_tmp_29_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 555 | static asdl_seq *_loop0_30_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 556 | static asdl_seq *_loop1_31_rule(Parser *p); |
| 557 | static asdl_seq *_loop0_33_rule(Parser *p); |
| 558 | static asdl_seq *_gather_32_rule(Parser *p); |
| 559 | static void *_tmp_34_rule(Parser *p); |
| 560 | static asdl_seq *_loop0_36_rule(Parser *p); |
| 561 | static asdl_seq *_gather_35_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 562 | static void *_tmp_37_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 563 | static asdl_seq *_loop0_39_rule(Parser *p); |
| 564 | static asdl_seq *_gather_38_rule(Parser *p); |
| 565 | static asdl_seq *_loop0_41_rule(Parser *p); |
| 566 | static asdl_seq *_gather_40_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 567 | static asdl_seq *_loop0_43_rule(Parser *p); |
| 568 | static asdl_seq *_gather_42_rule(Parser *p); |
| 569 | static asdl_seq *_loop0_45_rule(Parser *p); |
| 570 | static asdl_seq *_gather_44_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 571 | static void *_tmp_46_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 572 | static asdl_seq *_loop1_47_rule(Parser *p); |
| 573 | static void *_tmp_48_rule(Parser *p); |
| 574 | static void *_tmp_49_rule(Parser *p); |
| 575 | static void *_tmp_50_rule(Parser *p); |
| 576 | static void *_tmp_51_rule(Parser *p); |
| 577 | static void *_tmp_52_rule(Parser *p); |
| 578 | static asdl_seq *_loop0_53_rule(Parser *p); |
| 579 | static asdl_seq *_loop0_54_rule(Parser *p); |
| 580 | static asdl_seq *_loop0_55_rule(Parser *p); |
| 581 | static asdl_seq *_loop1_56_rule(Parser *p); |
| 582 | static asdl_seq *_loop0_57_rule(Parser *p); |
| 583 | static asdl_seq *_loop1_58_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 584 | static asdl_seq *_loop1_59_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 585 | static asdl_seq *_loop1_60_rule(Parser *p); |
| 586 | static asdl_seq *_loop0_61_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 587 | static asdl_seq *_loop1_62_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 588 | static asdl_seq *_loop0_63_rule(Parser *p); |
| 589 | static asdl_seq *_loop1_64_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 590 | static asdl_seq *_loop0_65_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 591 | static asdl_seq *_loop1_66_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 592 | static asdl_seq *_loop1_67_rule(Parser *p); |
| 593 | static void *_tmp_68_rule(Parser *p); |
| 594 | static asdl_seq *_loop0_70_rule(Parser *p); |
| 595 | static asdl_seq *_gather_69_rule(Parser *p); |
| 596 | static asdl_seq *_loop1_71_rule(Parser *p); |
| 597 | static asdl_seq *_loop0_73_rule(Parser *p); |
| 598 | static asdl_seq *_gather_72_rule(Parser *p); |
| 599 | static asdl_seq *_loop1_74_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 600 | static asdl_seq *_loop0_75_rule(Parser *p); |
| 601 | static asdl_seq *_loop0_76_rule(Parser *p); |
| 602 | static asdl_seq *_loop0_77_rule(Parser *p); |
| 603 | static asdl_seq *_loop1_78_rule(Parser *p); |
| 604 | static asdl_seq *_loop0_79_rule(Parser *p); |
| 605 | static asdl_seq *_loop1_80_rule(Parser *p); |
| 606 | static asdl_seq *_loop1_81_rule(Parser *p); |
| 607 | static asdl_seq *_loop1_82_rule(Parser *p); |
| 608 | static asdl_seq *_loop0_83_rule(Parser *p); |
| 609 | static asdl_seq *_loop1_84_rule(Parser *p); |
| 610 | static asdl_seq *_loop0_85_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 611 | static asdl_seq *_loop1_86_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 612 | static asdl_seq *_loop0_87_rule(Parser *p); |
| 613 | static asdl_seq *_loop1_88_rule(Parser *p); |
| 614 | static asdl_seq *_loop1_89_rule(Parser *p); |
| 615 | static asdl_seq *_loop1_90_rule(Parser *p); |
| 616 | static asdl_seq *_loop1_91_rule(Parser *p); |
| 617 | static void *_tmp_92_rule(Parser *p); |
| 618 | static asdl_seq *_loop0_94_rule(Parser *p); |
| 619 | static asdl_seq *_gather_93_rule(Parser *p); |
| 620 | static void *_tmp_95_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 621 | static void *_tmp_96_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 622 | static void *_tmp_97_rule(Parser *p); |
| 623 | static void *_tmp_98_rule(Parser *p); |
| 624 | static asdl_seq *_loop1_99_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 625 | static void *_tmp_100_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 626 | static void *_tmp_101_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 627 | static asdl_seq *_loop0_103_rule(Parser *p); |
| 628 | static asdl_seq *_gather_102_rule(Parser *p); |
| 629 | static asdl_seq *_loop1_104_rule(Parser *p); |
| 630 | static asdl_seq *_loop0_105_rule(Parser *p); |
| 631 | static asdl_seq *_loop0_106_rule(Parser *p); |
| 632 | static void *_tmp_107_rule(Parser *p); |
| 633 | static void *_tmp_108_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 634 | static asdl_seq *_loop0_110_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 635 | static asdl_seq *_gather_109_rule(Parser *p); |
| 636 | static asdl_seq *_loop0_112_rule(Parser *p); |
| 637 | static asdl_seq *_gather_111_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 638 | static asdl_seq *_loop0_114_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 639 | static asdl_seq *_gather_113_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 640 | static asdl_seq *_loop0_116_rule(Parser *p); |
| 641 | static asdl_seq *_gather_115_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 642 | static asdl_seq *_loop0_117_rule(Parser *p); |
| 643 | static asdl_seq *_loop0_119_rule(Parser *p); |
| 644 | static asdl_seq *_gather_118_rule(Parser *p); |
| 645 | static void *_tmp_120_rule(Parser *p); |
| 646 | static asdl_seq *_loop0_122_rule(Parser *p); |
| 647 | static asdl_seq *_gather_121_rule(Parser *p); |
| 648 | static asdl_seq *_loop0_124_rule(Parser *p); |
| 649 | static asdl_seq *_gather_123_rule(Parser *p); |
| 650 | static void *_tmp_125_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 651 | static asdl_seq *_loop0_126_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 652 | static void *_tmp_127_rule(Parser *p); |
| 653 | static void *_tmp_128_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 654 | static void *_tmp_129_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 655 | static void *_tmp_130_rule(Parser *p); |
| 656 | static asdl_seq *_loop0_131_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 657 | static void *_tmp_132_rule(Parser *p); |
| 658 | static void *_tmp_133_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 659 | static void *_tmp_134_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 660 | static void *_tmp_135_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 661 | static void *_tmp_136_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 662 | static void *_tmp_137_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 663 | static void *_tmp_138_rule(Parser *p); |
| 664 | static void *_tmp_139_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 665 | static void *_tmp_140_rule(Parser *p); |
| 666 | static void *_tmp_141_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 667 | static void *_tmp_142_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 668 | static void *_tmp_143_rule(Parser *p); |
| 669 | static void *_tmp_144_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 670 | static void *_tmp_145_rule(Parser *p); |
| 671 | static asdl_seq *_loop1_146_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 672 | static void *_tmp_147_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 673 | static void *_tmp_148_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 674 | |
| 675 | |
| 676 | // file: statements? $ |
| 677 | static mod_ty |
| 678 | file_rule(Parser *p) |
| 679 | { |
| 680 | if (p->error_indicator) { |
| 681 | return NULL; |
| 682 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 683 | mod_ty _res = NULL; |
| 684 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 685 | { // statements? $ |
| 686 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 687 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 688 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 689 | (a = statements_rule(p), 1) // statements? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 690 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 691 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 692 | ) |
| 693 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 694 | _res = _PyPegen_make_module ( p , a ); |
| 695 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 696 | p->error_indicator = 1; |
| 697 | return NULL; |
| 698 | } |
| 699 | goto done; |
| 700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 701 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 702 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 703 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 704 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 705 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | // interactive: statement_newline |
| 709 | static mod_ty |
| 710 | interactive_rule(Parser *p) |
| 711 | { |
| 712 | if (p->error_indicator) { |
| 713 | return NULL; |
| 714 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 715 | mod_ty _res = NULL; |
| 716 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 717 | { // statement_newline |
| 718 | asdl_seq* a; |
| 719 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 720 | (a = statement_newline_rule(p)) // statement_newline |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 721 | ) |
| 722 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 723 | _res = Interactive ( a , p -> arena ); |
| 724 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 725 | p->error_indicator = 1; |
| 726 | return NULL; |
| 727 | } |
| 728 | goto done; |
| 729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 730 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 731 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 732 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 733 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 734 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | // eval: expressions NEWLINE* $ |
| 738 | static mod_ty |
| 739 | eval_rule(Parser *p) |
| 740 | { |
| 741 | if (p->error_indicator) { |
| 742 | return NULL; |
| 743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 744 | mod_ty _res = NULL; |
| 745 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 746 | { // expressions NEWLINE* $ |
| 747 | asdl_seq * _loop0_1_var; |
| 748 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 749 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 750 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 751 | (a = expressions_rule(p)) // expressions |
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 | (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 754 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 755 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 756 | ) |
| 757 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 758 | _res = Expression ( a , p -> arena ); |
| 759 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 760 | p->error_indicator = 1; |
| 761 | return NULL; |
| 762 | } |
| 763 | goto done; |
| 764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 765 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 766 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 767 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 768 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 769 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 770 | } |
| 771 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 772 | // func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 773 | static mod_ty |
| 774 | func_type_rule(Parser *p) |
| 775 | { |
| 776 | if (p->error_indicator) { |
| 777 | return NULL; |
| 778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 779 | mod_ty _res = NULL; |
| 780 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 781 | { // '(' type_expressions? ')' '->' expression NEWLINE* $ |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 782 | Token * _literal; |
| 783 | Token * _literal_1; |
| 784 | Token * _literal_2; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 785 | asdl_seq * _loop0_2_var; |
| 786 | void *a; |
| 787 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 788 | Token * endmarker_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 789 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 790 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 791 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 792 | (a = type_expressions_rule(p), 1) // type_expressions? |
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_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 795 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 796 | (_literal_2 = _PyPegen_expect_token(p, 51)) // token='->' |
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 | (b = expression_rule(p)) // expression |
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 | (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 801 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 802 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 803 | ) |
| 804 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 805 | _res = FunctionType ( a , b , p -> arena ); |
| 806 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 807 | p->error_indicator = 1; |
| 808 | return NULL; |
| 809 | } |
| 810 | goto done; |
| 811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 812 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 814 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 815 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 816 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 817 | } |
| 818 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 819 | // fstring: star_expressions |
| 820 | static expr_ty |
| 821 | fstring_rule(Parser *p) |
| 822 | { |
| 823 | if (p->error_indicator) { |
| 824 | return NULL; |
| 825 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 826 | expr_ty _res = NULL; |
| 827 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 828 | { // star_expressions |
| 829 | expr_ty star_expressions_var; |
| 830 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 831 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 832 | ) |
| 833 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 834 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 835 | goto done; |
| 836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 837 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 839 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 840 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 841 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 842 | } |
| 843 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 844 | // type_expressions: |
| 845 | // | ','.expression+ ',' '*' expression ',' '**' expression |
| 846 | // | ','.expression+ ',' '*' expression |
| 847 | // | ','.expression+ ',' '**' expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 848 | // | '*' expression ',' '**' expression |
| 849 | // | '*' expression |
| 850 | // | '**' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 851 | // | ','.expression+ |
| 852 | static asdl_seq* |
| 853 | type_expressions_rule(Parser *p) |
| 854 | { |
| 855 | if (p->error_indicator) { |
| 856 | return NULL; |
| 857 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 858 | asdl_seq* _res = NULL; |
| 859 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 860 | { // ','.expression+ ',' '*' expression ',' '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 861 | Token * _literal; |
| 862 | Token * _literal_1; |
| 863 | Token * _literal_2; |
| 864 | Token * _literal_3; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 865 | asdl_seq * a; |
| 866 | expr_ty b; |
| 867 | expr_ty c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 868 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 869 | (a = _gather_3_rule(p)) // ','.expression+ |
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 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 872 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 873 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 874 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 875 | (b = expression_rule(p)) // expression |
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_2 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 878 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 879 | (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 880 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 881 | (c = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 882 | ) |
| 883 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 884 | _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); |
| 885 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 886 | p->error_indicator = 1; |
| 887 | return NULL; |
| 888 | } |
| 889 | goto done; |
| 890 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 891 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 892 | } |
| 893 | { // ','.expression+ ',' '*' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 894 | Token * _literal; |
| 895 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 896 | asdl_seq * a; |
| 897 | expr_ty b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 898 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 899 | (a = _gather_5_rule(p)) // ','.expression+ |
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 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 902 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 903 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 904 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 905 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 906 | ) |
| 907 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 908 | _res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 909 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 910 | p->error_indicator = 1; |
| 911 | return NULL; |
| 912 | } |
| 913 | goto done; |
| 914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 915 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 916 | } |
| 917 | { // ','.expression+ ',' '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 918 | Token * _literal; |
| 919 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 920 | asdl_seq * a; |
| 921 | expr_ty b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 922 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 923 | (a = _gather_7_rule(p)) // ','.expression+ |
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 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 926 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 927 | (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 928 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 929 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 930 | ) |
| 931 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 932 | _res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 933 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 934 | p->error_indicator = 1; |
| 935 | return NULL; |
| 936 | } |
| 937 | goto done; |
| 938 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 939 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 940 | } |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 941 | { // '*' expression ',' '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 942 | Token * _literal; |
| 943 | Token * _literal_1; |
| 944 | Token * _literal_2; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 945 | expr_ty a; |
| 946 | expr_ty b; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 947 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 948 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 949 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 950 | (a = expression_rule(p)) // expression |
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_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 953 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 954 | (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 955 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 956 | (b = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 957 | ) |
| 958 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 959 | _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b ); |
| 960 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 961 | p->error_indicator = 1; |
| 962 | return NULL; |
| 963 | } |
| 964 | goto done; |
| 965 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 966 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 967 | } |
| 968 | { // '*' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 969 | Token * _literal; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 970 | expr_ty a; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 971 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 972 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 973 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 974 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 975 | ) |
| 976 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 977 | _res = _PyPegen_singleton_seq ( p , a ); |
| 978 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 979 | p->error_indicator = 1; |
| 980 | return NULL; |
| 981 | } |
| 982 | goto done; |
| 983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 984 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 985 | } |
| 986 | { // '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 987 | Token * _literal; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 988 | expr_ty a; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 989 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 990 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 991 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 992 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 993 | ) |
| 994 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 995 | _res = _PyPegen_singleton_seq ( p , a ); |
| 996 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 997 | p->error_indicator = 1; |
| 998 | return NULL; |
| 999 | } |
| 1000 | goto done; |
| 1001 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1002 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1003 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1004 | { // ','.expression+ |
| 1005 | asdl_seq * _gather_9_var; |
| 1006 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1007 | (_gather_9_var = _gather_9_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1008 | ) |
| 1009 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1010 | _res = _gather_9_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1011 | goto done; |
| 1012 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1013 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1014 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1015 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1016 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1017 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1018 | } |
| 1019 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1020 | // statements: statement+ |
| 1021 | static asdl_seq* |
| 1022 | statements_rule(Parser *p) |
| 1023 | { |
| 1024 | if (p->error_indicator) { |
| 1025 | return NULL; |
| 1026 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1027 | asdl_seq* _res = NULL; |
| 1028 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1029 | { // statement+ |
| 1030 | asdl_seq * a; |
| 1031 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1032 | (a = _loop1_11_rule(p)) // statement+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1033 | ) |
| 1034 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1035 | _res = _PyPegen_seq_flatten ( p , a ); |
| 1036 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1037 | p->error_indicator = 1; |
| 1038 | return NULL; |
| 1039 | } |
| 1040 | goto done; |
| 1041 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1042 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1043 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1044 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1045 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1046 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | // statement: compound_stmt | simple_stmt |
| 1050 | static asdl_seq* |
| 1051 | statement_rule(Parser *p) |
| 1052 | { |
| 1053 | if (p->error_indicator) { |
| 1054 | return NULL; |
| 1055 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1056 | asdl_seq* _res = NULL; |
| 1057 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1058 | { // compound_stmt |
| 1059 | stmt_ty a; |
| 1060 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1061 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1062 | ) |
| 1063 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1064 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1065 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1066 | p->error_indicator = 1; |
| 1067 | return NULL; |
| 1068 | } |
| 1069 | goto done; |
| 1070 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1071 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1072 | } |
| 1073 | { // simple_stmt |
| 1074 | asdl_seq* simple_stmt_var; |
| 1075 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1076 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1077 | ) |
| 1078 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1079 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1080 | goto done; |
| 1081 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1082 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1084 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1085 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1086 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | // statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $ |
| 1090 | static asdl_seq* |
| 1091 | statement_newline_rule(Parser *p) |
| 1092 | { |
| 1093 | if (p->error_indicator) { |
| 1094 | return NULL; |
| 1095 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1096 | asdl_seq* _res = NULL; |
| 1097 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1098 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1099 | p->error_indicator = 1; |
| 1100 | return NULL; |
| 1101 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1102 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1103 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1104 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1105 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1106 | { // compound_stmt NEWLINE |
| 1107 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1108 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1109 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1110 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1111 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1112 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1113 | ) |
| 1114 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1115 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1116 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1117 | p->error_indicator = 1; |
| 1118 | return NULL; |
| 1119 | } |
| 1120 | goto done; |
| 1121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1122 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1123 | } |
| 1124 | { // simple_stmt |
| 1125 | asdl_seq* simple_stmt_var; |
| 1126 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1127 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1128 | ) |
| 1129 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1130 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1131 | goto done; |
| 1132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1133 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1134 | } |
| 1135 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1136 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1137 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1138 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1139 | ) |
| 1140 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1141 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1142 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1143 | return NULL; |
| 1144 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1145 | int _end_lineno = _token->end_lineno; |
| 1146 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1147 | int _end_col_offset = _token->end_col_offset; |
| 1148 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1149 | _res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) ); |
| 1150 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1151 | p->error_indicator = 1; |
| 1152 | return NULL; |
| 1153 | } |
| 1154 | goto done; |
| 1155 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1156 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1157 | } |
| 1158 | { // $ |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1159 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1160 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1161 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1162 | ) |
| 1163 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1164 | _res = _PyPegen_interactive_exit ( p ); |
| 1165 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1166 | p->error_indicator = 1; |
| 1167 | return NULL; |
| 1168 | } |
| 1169 | goto done; |
| 1170 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1171 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1172 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1173 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1174 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1175 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | // simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE |
| 1179 | static asdl_seq* |
| 1180 | simple_stmt_rule(Parser *p) |
| 1181 | { |
| 1182 | if (p->error_indicator) { |
| 1183 | return NULL; |
| 1184 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1185 | asdl_seq* _res = NULL; |
| 1186 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1187 | { // small_stmt !';' NEWLINE |
| 1188 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1189 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1190 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1191 | (a = small_stmt_rule(p)) // small_stmt |
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 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1194 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1195 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1196 | ) |
| 1197 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1198 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1199 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1200 | p->error_indicator = 1; |
| 1201 | return NULL; |
| 1202 | } |
| 1203 | goto done; |
| 1204 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1205 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1206 | } |
| 1207 | { // ';'.small_stmt+ ';'? NEWLINE |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1208 | void *_opt_var; |
| 1209 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1210 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1211 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1212 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1213 | (a = _gather_12_rule(p)) // ';'.small_stmt+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1214 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1215 | (_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1216 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1217 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1218 | ) |
| 1219 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1220 | _res = a; |
| 1221 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1222 | p->error_indicator = 1; |
| 1223 | return NULL; |
| 1224 | } |
| 1225 | goto done; |
| 1226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1227 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1229 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1230 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1231 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | // small_stmt: |
| 1235 | // | assignment |
| 1236 | // | star_expressions |
| 1237 | // | &'return' return_stmt |
| 1238 | // | &('import' | 'from') import_stmt |
| 1239 | // | &'raise' raise_stmt |
| 1240 | // | 'pass' |
| 1241 | // | &'del' del_stmt |
| 1242 | // | &'yield' yield_stmt |
| 1243 | // | &'assert' assert_stmt |
| 1244 | // | 'break' |
| 1245 | // | 'continue' |
| 1246 | // | &'global' global_stmt |
| 1247 | // | &'nonlocal' nonlocal_stmt |
| 1248 | static stmt_ty |
| 1249 | small_stmt_rule(Parser *p) |
| 1250 | { |
| 1251 | if (p->error_indicator) { |
| 1252 | return NULL; |
| 1253 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1254 | stmt_ty _res = NULL; |
| 1255 | if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) |
| 1256 | return _res; |
| 1257 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1258 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1259 | p->error_indicator = 1; |
| 1260 | return NULL; |
| 1261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1262 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1263 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1264 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1265 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1266 | { // assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1267 | stmt_ty assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1268 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1269 | (assignment_var = assignment_rule(p)) // assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1270 | ) |
| 1271 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1272 | _res = assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1273 | goto done; |
| 1274 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1275 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1276 | } |
| 1277 | { // star_expressions |
| 1278 | expr_ty e; |
| 1279 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1280 | (e = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1281 | ) |
| 1282 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1283 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1284 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1285 | return NULL; |
| 1286 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1287 | int _end_lineno = _token->end_lineno; |
| 1288 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1289 | int _end_col_offset = _token->end_col_offset; |
| 1290 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1291 | _res = _Py_Expr ( e , EXTRA ); |
| 1292 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1293 | p->error_indicator = 1; |
| 1294 | return NULL; |
| 1295 | } |
| 1296 | goto done; |
| 1297 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1298 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1299 | } |
| 1300 | { // &'return' return_stmt |
| 1301 | stmt_ty return_stmt_var; |
| 1302 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1303 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1304 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1305 | (return_stmt_var = return_stmt_rule(p)) // return_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1306 | ) |
| 1307 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1308 | _res = return_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1309 | goto done; |
| 1310 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1311 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1312 | } |
| 1313 | { // &('import' | 'from') import_stmt |
| 1314 | stmt_ty import_stmt_var; |
| 1315 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1316 | _PyPegen_lookahead(1, _tmp_14_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1317 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1318 | (import_stmt_var = import_stmt_rule(p)) // import_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1319 | ) |
| 1320 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1321 | _res = import_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1322 | goto done; |
| 1323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1324 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1325 | } |
| 1326 | { // &'raise' raise_stmt |
| 1327 | stmt_ty raise_stmt_var; |
| 1328 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1329 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1330 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1331 | (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1332 | ) |
| 1333 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1334 | _res = raise_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1335 | goto done; |
| 1336 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1337 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1338 | } |
| 1339 | { // 'pass' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1340 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1341 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1342 | (_keyword = _PyPegen_expect_token(p, 502)) // token='pass' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1343 | ) |
| 1344 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1345 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1346 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1347 | return NULL; |
| 1348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1349 | int _end_lineno = _token->end_lineno; |
| 1350 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1351 | int _end_col_offset = _token->end_col_offset; |
| 1352 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1353 | _res = _Py_Pass ( EXTRA ); |
| 1354 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1355 | p->error_indicator = 1; |
| 1356 | return NULL; |
| 1357 | } |
| 1358 | goto done; |
| 1359 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1360 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1361 | } |
| 1362 | { // &'del' del_stmt |
| 1363 | stmt_ty del_stmt_var; |
| 1364 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1365 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1366 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1367 | (del_stmt_var = del_stmt_rule(p)) // del_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1368 | ) |
| 1369 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1370 | _res = del_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1371 | goto done; |
| 1372 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1373 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1374 | } |
| 1375 | { // &'yield' yield_stmt |
| 1376 | stmt_ty yield_stmt_var; |
| 1377 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1378 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1379 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1380 | (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1381 | ) |
| 1382 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1383 | _res = yield_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1384 | goto done; |
| 1385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1386 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1387 | } |
| 1388 | { // &'assert' assert_stmt |
| 1389 | stmt_ty assert_stmt_var; |
| 1390 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1391 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1392 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1393 | (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1394 | ) |
| 1395 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1396 | _res = assert_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1397 | goto done; |
| 1398 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1399 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1400 | } |
| 1401 | { // 'break' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1402 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1403 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1404 | (_keyword = _PyPegen_expect_token(p, 506)) // token='break' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1405 | ) |
| 1406 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1407 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1408 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1409 | return NULL; |
| 1410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1411 | int _end_lineno = _token->end_lineno; |
| 1412 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1413 | int _end_col_offset = _token->end_col_offset; |
| 1414 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1415 | _res = _Py_Break ( EXTRA ); |
| 1416 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1417 | p->error_indicator = 1; |
| 1418 | return NULL; |
| 1419 | } |
| 1420 | goto done; |
| 1421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1422 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1423 | } |
| 1424 | { // 'continue' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1425 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1426 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1427 | (_keyword = _PyPegen_expect_token(p, 507)) // token='continue' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1428 | ) |
| 1429 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1430 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1431 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1432 | return NULL; |
| 1433 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1434 | int _end_lineno = _token->end_lineno; |
| 1435 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1436 | int _end_col_offset = _token->end_col_offset; |
| 1437 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1438 | _res = _Py_Continue ( EXTRA ); |
| 1439 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1440 | p->error_indicator = 1; |
| 1441 | return NULL; |
| 1442 | } |
| 1443 | goto done; |
| 1444 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1445 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1446 | } |
| 1447 | { // &'global' global_stmt |
| 1448 | stmt_ty global_stmt_var; |
| 1449 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1450 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1451 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1452 | (global_stmt_var = global_stmt_rule(p)) // global_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1453 | ) |
| 1454 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1455 | _res = global_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1456 | goto done; |
| 1457 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1458 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1459 | } |
| 1460 | { // &'nonlocal' nonlocal_stmt |
| 1461 | stmt_ty nonlocal_stmt_var; |
| 1462 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1463 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1464 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1465 | (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1466 | ) |
| 1467 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1468 | _res = nonlocal_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1469 | goto done; |
| 1470 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1471 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1473 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1474 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1475 | _PyPegen_insert_memo(p, _mark, small_stmt_type, _res); |
| 1476 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1477 | } |
| 1478 | |
| 1479 | // compound_stmt: |
| 1480 | // | &('def' | '@' | ASYNC) function_def |
| 1481 | // | &'if' if_stmt |
| 1482 | // | &('class' | '@') class_def |
| 1483 | // | &('with' | ASYNC) with_stmt |
| 1484 | // | &('for' | ASYNC) for_stmt |
| 1485 | // | &'try' try_stmt |
| 1486 | // | &'while' while_stmt |
| 1487 | static stmt_ty |
| 1488 | compound_stmt_rule(Parser *p) |
| 1489 | { |
| 1490 | if (p->error_indicator) { |
| 1491 | return NULL; |
| 1492 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1493 | stmt_ty _res = NULL; |
| 1494 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1495 | { // &('def' | '@' | ASYNC) function_def |
| 1496 | stmt_ty function_def_var; |
| 1497 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1498 | _PyPegen_lookahead(1, _tmp_15_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1499 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1500 | (function_def_var = function_def_rule(p)) // function_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1501 | ) |
| 1502 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1503 | _res = function_def_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1504 | goto done; |
| 1505 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1506 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1507 | } |
| 1508 | { // &'if' if_stmt |
| 1509 | stmt_ty if_stmt_var; |
| 1510 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1511 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1512 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1513 | (if_stmt_var = if_stmt_rule(p)) // if_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1514 | ) |
| 1515 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1516 | _res = if_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1517 | goto done; |
| 1518 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1519 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1520 | } |
| 1521 | { // &('class' | '@') class_def |
| 1522 | stmt_ty class_def_var; |
| 1523 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1524 | _PyPegen_lookahead(1, _tmp_16_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1525 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1526 | (class_def_var = class_def_rule(p)) // class_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1527 | ) |
| 1528 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1529 | _res = class_def_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1530 | goto done; |
| 1531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1532 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1533 | } |
| 1534 | { // &('with' | ASYNC) with_stmt |
| 1535 | stmt_ty with_stmt_var; |
| 1536 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1537 | _PyPegen_lookahead(1, _tmp_17_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1538 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1539 | (with_stmt_var = with_stmt_rule(p)) // with_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1540 | ) |
| 1541 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1542 | _res = with_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1543 | goto done; |
| 1544 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1545 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1546 | } |
| 1547 | { // &('for' | ASYNC) for_stmt |
| 1548 | stmt_ty for_stmt_var; |
| 1549 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1550 | _PyPegen_lookahead(1, _tmp_18_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1551 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1552 | (for_stmt_var = for_stmt_rule(p)) // for_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1553 | ) |
| 1554 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1555 | _res = for_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1556 | goto done; |
| 1557 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1558 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1559 | } |
| 1560 | { // &'try' try_stmt |
| 1561 | stmt_ty try_stmt_var; |
| 1562 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1563 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1564 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1565 | (try_stmt_var = try_stmt_rule(p)) // try_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1566 | ) |
| 1567 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1568 | _res = try_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1569 | goto done; |
| 1570 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1571 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1572 | } |
| 1573 | { // &'while' while_stmt |
| 1574 | stmt_ty while_stmt_var; |
| 1575 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1576 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1577 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1578 | (while_stmt_var = while_stmt_rule(p)) // while_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1579 | ) |
| 1580 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1581 | _res = while_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1582 | goto done; |
| 1583 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1584 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1586 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1587 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1588 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1589 | } |
| 1590 | |
| 1591 | // assignment: |
| 1592 | // | NAME ':' expression ['=' annotated_rhs] |
| 1593 | // | ('(' 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] | 1594 | // | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1595 | // | target augassign (yield_expr | star_expressions) |
| 1596 | // | invalid_assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1597 | static stmt_ty |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1598 | assignment_rule(Parser *p) |
| 1599 | { |
| 1600 | if (p->error_indicator) { |
| 1601 | return NULL; |
| 1602 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1603 | stmt_ty _res = NULL; |
| 1604 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1605 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1606 | p->error_indicator = 1; |
| 1607 | return NULL; |
| 1608 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1609 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1610 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1611 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1612 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1613 | { // NAME ':' expression ['=' annotated_rhs] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1614 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1615 | expr_ty a; |
| 1616 | expr_ty b; |
| 1617 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1618 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1619 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1620 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1621 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1624 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1625 | (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1626 | ) |
| 1627 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1628 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1629 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1630 | return NULL; |
| 1631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1632 | int _end_lineno = _token->end_lineno; |
| 1633 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1634 | int _end_col_offset = _token->end_col_offset; |
| 1635 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1636 | _res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) ); |
| 1637 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1638 | p->error_indicator = 1; |
| 1639 | return NULL; |
| 1640 | } |
| 1641 | goto done; |
| 1642 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1643 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1644 | } |
| 1645 | { // ('(' 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] | 1646 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1647 | void *a; |
| 1648 | expr_ty b; |
| 1649 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1650 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1651 | (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] | 1652 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1653 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1656 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1657 | (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1658 | ) |
| 1659 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1660 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1661 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1662 | return NULL; |
| 1663 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1664 | int _end_lineno = _token->end_lineno; |
| 1665 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1666 | int _end_col_offset = _token->end_col_offset; |
| 1667 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1668 | _res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) ); |
| 1669 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1670 | p->error_indicator = 1; |
| 1671 | return NULL; |
| 1672 | } |
| 1673 | goto done; |
| 1674 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1675 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1676 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1677 | { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1678 | asdl_seq * a; |
| 1679 | void *b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1680 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1681 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1682 | (a = _loop1_22_rule(p)) // ((star_targets '='))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1683 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1684 | (b = _tmp_23_rule(p)) // yield_expr | star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1685 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1686 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1687 | ) |
| 1688 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1689 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1690 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1691 | return NULL; |
| 1692 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1693 | int _end_lineno = _token->end_lineno; |
| 1694 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1695 | int _end_col_offset = _token->end_col_offset; |
| 1696 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1697 | _res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 1698 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1699 | p->error_indicator = 1; |
| 1700 | return NULL; |
| 1701 | } |
| 1702 | goto done; |
| 1703 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1704 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1705 | } |
| 1706 | { // target augassign (yield_expr | star_expressions) |
| 1707 | expr_ty a; |
| 1708 | AugOperator* b; |
| 1709 | void *c; |
| 1710 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1711 | (a = target_rule(p)) // target |
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 | (b = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1714 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1715 | (c = _tmp_24_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1716 | ) |
| 1717 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1718 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1719 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1720 | return NULL; |
| 1721 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1722 | int _end_lineno = _token->end_lineno; |
| 1723 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1724 | int _end_col_offset = _token->end_col_offset; |
| 1725 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1726 | _res = _Py_AugAssign ( a , b -> kind , c , EXTRA ); |
| 1727 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1728 | p->error_indicator = 1; |
| 1729 | return NULL; |
| 1730 | } |
| 1731 | goto done; |
| 1732 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1733 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1734 | } |
| 1735 | { // invalid_assignment |
| 1736 | void *invalid_assignment_var; |
| 1737 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1738 | (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1739 | ) |
| 1740 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1741 | _res = invalid_assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1742 | goto done; |
| 1743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1744 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1745 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1746 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1747 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1748 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1749 | } |
| 1750 | |
| 1751 | // augassign: |
| 1752 | // | '+=' |
| 1753 | // | '-=' |
| 1754 | // | '*=' |
| 1755 | // | '@=' |
| 1756 | // | '/=' |
| 1757 | // | '%=' |
| 1758 | // | '&=' |
| 1759 | // | '|=' |
| 1760 | // | '^=' |
| 1761 | // | '<<=' |
| 1762 | // | '>>=' |
| 1763 | // | '**=' |
| 1764 | // | '//=' |
| 1765 | static AugOperator* |
| 1766 | augassign_rule(Parser *p) |
| 1767 | { |
| 1768 | if (p->error_indicator) { |
| 1769 | return NULL; |
| 1770 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1771 | AugOperator* _res = NULL; |
| 1772 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1773 | { // '+=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1774 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1775 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1776 | (_literal = _PyPegen_expect_token(p, 36)) // token='+=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1777 | ) |
| 1778 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1779 | _res = _PyPegen_augoperator ( p , Add ); |
| 1780 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1781 | p->error_indicator = 1; |
| 1782 | return NULL; |
| 1783 | } |
| 1784 | goto done; |
| 1785 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1786 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1787 | } |
| 1788 | { // '-=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1789 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1790 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1791 | (_literal = _PyPegen_expect_token(p, 37)) // token='-=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1792 | ) |
| 1793 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1794 | _res = _PyPegen_augoperator ( p , Sub ); |
| 1795 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1796 | p->error_indicator = 1; |
| 1797 | return NULL; |
| 1798 | } |
| 1799 | goto done; |
| 1800 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1801 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1802 | } |
| 1803 | { // '*=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1804 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1805 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1806 | (_literal = _PyPegen_expect_token(p, 38)) // token='*=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1807 | ) |
| 1808 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1809 | _res = _PyPegen_augoperator ( p , Mult ); |
| 1810 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1811 | p->error_indicator = 1; |
| 1812 | return NULL; |
| 1813 | } |
| 1814 | goto done; |
| 1815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1816 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1817 | } |
| 1818 | { // '@=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1819 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1820 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1821 | (_literal = _PyPegen_expect_token(p, 50)) // token='@=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1822 | ) |
| 1823 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1824 | _res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) ); |
| 1825 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1826 | p->error_indicator = 1; |
| 1827 | return NULL; |
| 1828 | } |
| 1829 | goto done; |
| 1830 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1831 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1832 | } |
| 1833 | { // '/=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1834 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1835 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1836 | (_literal = _PyPegen_expect_token(p, 39)) // token='/=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1837 | ) |
| 1838 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1839 | _res = _PyPegen_augoperator ( p , Div ); |
| 1840 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1841 | p->error_indicator = 1; |
| 1842 | return NULL; |
| 1843 | } |
| 1844 | goto done; |
| 1845 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1846 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1847 | } |
| 1848 | { // '%=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1849 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1850 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1851 | (_literal = _PyPegen_expect_token(p, 40)) // token='%=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1852 | ) |
| 1853 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1854 | _res = _PyPegen_augoperator ( p , Mod ); |
| 1855 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1856 | p->error_indicator = 1; |
| 1857 | return NULL; |
| 1858 | } |
| 1859 | goto done; |
| 1860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1861 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1862 | } |
| 1863 | { // '&=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1864 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1865 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1866 | (_literal = _PyPegen_expect_token(p, 41)) // token='&=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1867 | ) |
| 1868 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1869 | _res = _PyPegen_augoperator ( p , BitAnd ); |
| 1870 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1871 | p->error_indicator = 1; |
| 1872 | return NULL; |
| 1873 | } |
| 1874 | goto done; |
| 1875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1876 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1877 | } |
| 1878 | { // '|=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1879 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1880 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1881 | (_literal = _PyPegen_expect_token(p, 42)) // token='|=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1882 | ) |
| 1883 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1884 | _res = _PyPegen_augoperator ( p , BitOr ); |
| 1885 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1886 | p->error_indicator = 1; |
| 1887 | return NULL; |
| 1888 | } |
| 1889 | goto done; |
| 1890 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1891 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1892 | } |
| 1893 | { // '^=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1894 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1895 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1896 | (_literal = _PyPegen_expect_token(p, 43)) // token='^=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1897 | ) |
| 1898 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1899 | _res = _PyPegen_augoperator ( p , BitXor ); |
| 1900 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1901 | p->error_indicator = 1; |
| 1902 | return NULL; |
| 1903 | } |
| 1904 | goto done; |
| 1905 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1906 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1907 | } |
| 1908 | { // '<<=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1909 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1910 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1911 | (_literal = _PyPegen_expect_token(p, 44)) // token='<<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1912 | ) |
| 1913 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1914 | _res = _PyPegen_augoperator ( p , LShift ); |
| 1915 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1916 | p->error_indicator = 1; |
| 1917 | return NULL; |
| 1918 | } |
| 1919 | goto done; |
| 1920 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1921 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1922 | } |
| 1923 | { // '>>=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1924 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1925 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1926 | (_literal = _PyPegen_expect_token(p, 45)) // token='>>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1927 | ) |
| 1928 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1929 | _res = _PyPegen_augoperator ( p , RShift ); |
| 1930 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1931 | p->error_indicator = 1; |
| 1932 | return NULL; |
| 1933 | } |
| 1934 | goto done; |
| 1935 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1936 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1937 | } |
| 1938 | { // '**=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1939 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1940 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1941 | (_literal = _PyPegen_expect_token(p, 46)) // token='**=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1942 | ) |
| 1943 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1944 | _res = _PyPegen_augoperator ( p , Pow ); |
| 1945 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1946 | p->error_indicator = 1; |
| 1947 | return NULL; |
| 1948 | } |
| 1949 | goto done; |
| 1950 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1951 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1952 | } |
| 1953 | { // '//=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1954 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1955 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1956 | (_literal = _PyPegen_expect_token(p, 48)) // token='//=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1957 | ) |
| 1958 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1959 | _res = _PyPegen_augoperator ( p , FloorDiv ); |
| 1960 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1961 | p->error_indicator = 1; |
| 1962 | return NULL; |
| 1963 | } |
| 1964 | goto done; |
| 1965 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1966 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1967 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1968 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1969 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1970 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1971 | } |
| 1972 | |
| 1973 | // global_stmt: 'global' ','.NAME+ |
| 1974 | static stmt_ty |
| 1975 | global_stmt_rule(Parser *p) |
| 1976 | { |
| 1977 | if (p->error_indicator) { |
| 1978 | return NULL; |
| 1979 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1980 | stmt_ty _res = NULL; |
| 1981 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1982 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1983 | p->error_indicator = 1; |
| 1984 | return NULL; |
| 1985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1986 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1987 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1988 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1989 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1990 | { // 'global' ','.NAME+ |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1991 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1992 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1993 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1994 | (_keyword = _PyPegen_expect_token(p, 508)) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1995 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1996 | (a = _gather_25_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1997 | ) |
| 1998 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1999 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2000 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2001 | return NULL; |
| 2002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2003 | int _end_lineno = _token->end_lineno; |
| 2004 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2005 | int _end_col_offset = _token->end_col_offset; |
| 2006 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2007 | _res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2008 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2009 | p->error_indicator = 1; |
| 2010 | return NULL; |
| 2011 | } |
| 2012 | goto done; |
| 2013 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2014 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2015 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2016 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2017 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2018 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2019 | } |
| 2020 | |
| 2021 | // nonlocal_stmt: 'nonlocal' ','.NAME+ |
| 2022 | static stmt_ty |
| 2023 | nonlocal_stmt_rule(Parser *p) |
| 2024 | { |
| 2025 | if (p->error_indicator) { |
| 2026 | return NULL; |
| 2027 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2028 | stmt_ty _res = NULL; |
| 2029 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2030 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2031 | p->error_indicator = 1; |
| 2032 | return NULL; |
| 2033 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2034 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2035 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2036 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2037 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2038 | { // 'nonlocal' ','.NAME+ |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2039 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2040 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2041 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2042 | (_keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2043 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2044 | (a = _gather_27_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2045 | ) |
| 2046 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2047 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2048 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2049 | return NULL; |
| 2050 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2051 | int _end_lineno = _token->end_lineno; |
| 2052 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2053 | int _end_col_offset = _token->end_col_offset; |
| 2054 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2055 | _res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2056 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2057 | p->error_indicator = 1; |
| 2058 | return NULL; |
| 2059 | } |
| 2060 | goto done; |
| 2061 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2062 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2063 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2064 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2065 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2066 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2067 | } |
| 2068 | |
| 2069 | // yield_stmt: yield_expr |
| 2070 | static stmt_ty |
| 2071 | yield_stmt_rule(Parser *p) |
| 2072 | { |
| 2073 | if (p->error_indicator) { |
| 2074 | return NULL; |
| 2075 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2076 | stmt_ty _res = NULL; |
| 2077 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2078 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2079 | p->error_indicator = 1; |
| 2080 | return NULL; |
| 2081 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2082 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2083 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2084 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2085 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2086 | { // yield_expr |
| 2087 | expr_ty y; |
| 2088 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2089 | (y = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2090 | ) |
| 2091 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2092 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2093 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2094 | return NULL; |
| 2095 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2096 | int _end_lineno = _token->end_lineno; |
| 2097 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2098 | int _end_col_offset = _token->end_col_offset; |
| 2099 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2100 | _res = _Py_Expr ( y , EXTRA ); |
| 2101 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2102 | p->error_indicator = 1; |
| 2103 | return NULL; |
| 2104 | } |
| 2105 | goto done; |
| 2106 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2107 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2109 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2110 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2111 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2112 | } |
| 2113 | |
| 2114 | // assert_stmt: 'assert' expression [',' expression] |
| 2115 | static stmt_ty |
| 2116 | assert_stmt_rule(Parser *p) |
| 2117 | { |
| 2118 | if (p->error_indicator) { |
| 2119 | return NULL; |
| 2120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2121 | stmt_ty _res = NULL; |
| 2122 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2123 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2124 | p->error_indicator = 1; |
| 2125 | return NULL; |
| 2126 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2127 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2128 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2129 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2130 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2131 | { // 'assert' expression [',' expression] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2132 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2133 | expr_ty a; |
| 2134 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2135 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2136 | (_keyword = _PyPegen_expect_token(p, 505)) // token='assert' |
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 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2139 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2140 | (b = _tmp_29_rule(p), 1) // [',' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2141 | ) |
| 2142 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2143 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2144 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2145 | return NULL; |
| 2146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2147 | int _end_lineno = _token->end_lineno; |
| 2148 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2149 | int _end_col_offset = _token->end_col_offset; |
| 2150 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2151 | _res = _Py_Assert ( a , b , EXTRA ); |
| 2152 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2153 | p->error_indicator = 1; |
| 2154 | return NULL; |
| 2155 | } |
| 2156 | goto done; |
| 2157 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2158 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2159 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2160 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2161 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2162 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2163 | } |
| 2164 | |
| 2165 | // del_stmt: 'del' del_targets |
| 2166 | static stmt_ty |
| 2167 | del_stmt_rule(Parser *p) |
| 2168 | { |
| 2169 | if (p->error_indicator) { |
| 2170 | return NULL; |
| 2171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2172 | stmt_ty _res = NULL; |
| 2173 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2174 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2175 | p->error_indicator = 1; |
| 2176 | return NULL; |
| 2177 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2178 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2179 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2180 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2181 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2182 | { // 'del' del_targets |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2183 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2184 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2185 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2186 | (_keyword = _PyPegen_expect_token(p, 503)) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2187 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2188 | (a = del_targets_rule(p)) // del_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2189 | ) |
| 2190 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2191 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2192 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2193 | return NULL; |
| 2194 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2195 | int _end_lineno = _token->end_lineno; |
| 2196 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2197 | int _end_col_offset = _token->end_col_offset; |
| 2198 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2199 | _res = _Py_Delete ( a , EXTRA ); |
| 2200 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2201 | p->error_indicator = 1; |
| 2202 | return NULL; |
| 2203 | } |
| 2204 | goto done; |
| 2205 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2206 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2208 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2209 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2210 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2211 | } |
| 2212 | |
| 2213 | // import_stmt: import_name | import_from |
| 2214 | static stmt_ty |
| 2215 | import_stmt_rule(Parser *p) |
| 2216 | { |
| 2217 | if (p->error_indicator) { |
| 2218 | return NULL; |
| 2219 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2220 | stmt_ty _res = NULL; |
| 2221 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2222 | { // import_name |
| 2223 | stmt_ty import_name_var; |
| 2224 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2225 | (import_name_var = import_name_rule(p)) // import_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2226 | ) |
| 2227 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2228 | _res = import_name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2229 | goto done; |
| 2230 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2231 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2232 | } |
| 2233 | { // import_from |
| 2234 | stmt_ty import_from_var; |
| 2235 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2236 | (import_from_var = import_from_rule(p)) // import_from |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2237 | ) |
| 2238 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2239 | _res = import_from_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2240 | goto done; |
| 2241 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2242 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2244 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2245 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2246 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2247 | } |
| 2248 | |
| 2249 | // import_name: 'import' dotted_as_names |
| 2250 | static stmt_ty |
| 2251 | import_name_rule(Parser *p) |
| 2252 | { |
| 2253 | if (p->error_indicator) { |
| 2254 | return NULL; |
| 2255 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2256 | stmt_ty _res = NULL; |
| 2257 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2258 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2259 | p->error_indicator = 1; |
| 2260 | return NULL; |
| 2261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2262 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2263 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2264 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2265 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2266 | { // 'import' dotted_as_names |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2267 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2268 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2269 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2270 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2271 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2272 | (a = dotted_as_names_rule(p)) // dotted_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2273 | ) |
| 2274 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2275 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2276 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2277 | return NULL; |
| 2278 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2279 | int _end_lineno = _token->end_lineno; |
| 2280 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2281 | int _end_col_offset = _token->end_col_offset; |
| 2282 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2283 | _res = _Py_Import ( a , EXTRA ); |
| 2284 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2285 | p->error_indicator = 1; |
| 2286 | return NULL; |
| 2287 | } |
| 2288 | goto done; |
| 2289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2290 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2291 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2292 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2293 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2294 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2295 | } |
| 2296 | |
| 2297 | // import_from: |
| 2298 | // | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2299 | // | 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2300 | static stmt_ty |
| 2301 | import_from_rule(Parser *p) |
| 2302 | { |
| 2303 | if (p->error_indicator) { |
| 2304 | return NULL; |
| 2305 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2306 | stmt_ty _res = NULL; |
| 2307 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2308 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2309 | p->error_indicator = 1; |
| 2310 | return NULL; |
| 2311 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2312 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2313 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2314 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2315 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2316 | { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2317 | Token * _keyword; |
| 2318 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2319 | asdl_seq * a; |
| 2320 | expr_ty b; |
| 2321 | asdl_seq* c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2322 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2323 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
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 | (a = _loop0_30_rule(p)) // (('.' | '...'))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2326 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2327 | (b = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2328 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2329 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2330 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2331 | (c = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2332 | ) |
| 2333 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2334 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2335 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2336 | return NULL; |
| 2337 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2338 | int _end_lineno = _token->end_lineno; |
| 2339 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2340 | int _end_col_offset = _token->end_col_offset; |
| 2341 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2342 | _res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2343 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2344 | p->error_indicator = 1; |
| 2345 | return NULL; |
| 2346 | } |
| 2347 | goto done; |
| 2348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2349 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2350 | } |
| 2351 | { // 'from' (('.' | '...'))+ 'import' import_from_targets |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2352 | Token * _keyword; |
| 2353 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2354 | asdl_seq * a; |
| 2355 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2356 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2357 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2358 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2359 | (a = _loop1_31_rule(p)) // (('.' | '...'))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2360 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2361 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2362 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2363 | (b = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2364 | ) |
| 2365 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2366 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2367 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2368 | return NULL; |
| 2369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2370 | int _end_lineno = _token->end_lineno; |
| 2371 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2372 | int _end_col_offset = _token->end_col_offset; |
| 2373 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2374 | _res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2375 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2376 | p->error_indicator = 1; |
| 2377 | return NULL; |
| 2378 | } |
| 2379 | goto done; |
| 2380 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2381 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2382 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2383 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2384 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2385 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2386 | } |
| 2387 | |
| 2388 | // import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*' |
| 2389 | static asdl_seq* |
| 2390 | import_from_targets_rule(Parser *p) |
| 2391 | { |
| 2392 | if (p->error_indicator) { |
| 2393 | return NULL; |
| 2394 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2395 | asdl_seq* _res = NULL; |
| 2396 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2397 | { // '(' import_from_as_names ','? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2398 | Token * _literal; |
| 2399 | Token * _literal_1; |
| 2400 | void *_opt_var; |
| 2401 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2402 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2403 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2404 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2405 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2406 | (a = import_from_as_names_rule(p)) // import_from_as_names |
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 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2409 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2410 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2411 | ) |
| 2412 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2413 | _res = a; |
| 2414 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2415 | p->error_indicator = 1; |
| 2416 | return NULL; |
| 2417 | } |
| 2418 | goto done; |
| 2419 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2420 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2421 | } |
| 2422 | { // import_from_as_names |
| 2423 | asdl_seq* import_from_as_names_var; |
| 2424 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2425 | (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] | 2426 | ) |
| 2427 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2428 | _res = import_from_as_names_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2429 | goto done; |
| 2430 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2431 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2432 | } |
| 2433 | { // '*' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2434 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2435 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2436 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2437 | ) |
| 2438 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2439 | _res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) ); |
| 2440 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2441 | p->error_indicator = 1; |
| 2442 | return NULL; |
| 2443 | } |
| 2444 | goto done; |
| 2445 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2446 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2447 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2448 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2449 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2450 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2451 | } |
| 2452 | |
| 2453 | // import_from_as_names: ','.import_from_as_name+ |
| 2454 | static asdl_seq* |
| 2455 | import_from_as_names_rule(Parser *p) |
| 2456 | { |
| 2457 | if (p->error_indicator) { |
| 2458 | return NULL; |
| 2459 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2460 | asdl_seq* _res = NULL; |
| 2461 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2462 | { // ','.import_from_as_name+ |
| 2463 | asdl_seq * a; |
| 2464 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2465 | (a = _gather_32_rule(p)) // ','.import_from_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2466 | ) |
| 2467 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2468 | _res = a; |
| 2469 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2470 | p->error_indicator = 1; |
| 2471 | return NULL; |
| 2472 | } |
| 2473 | goto done; |
| 2474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2475 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2476 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2477 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2478 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2479 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2480 | } |
| 2481 | |
| 2482 | // import_from_as_name: NAME ['as' NAME] |
| 2483 | static alias_ty |
| 2484 | import_from_as_name_rule(Parser *p) |
| 2485 | { |
| 2486 | if (p->error_indicator) { |
| 2487 | return NULL; |
| 2488 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2489 | alias_ty _res = NULL; |
| 2490 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2491 | { // NAME ['as' NAME] |
| 2492 | expr_ty a; |
| 2493 | void *b; |
| 2494 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2495 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2496 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2497 | (b = _tmp_34_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2498 | ) |
| 2499 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2500 | _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2501 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2502 | p->error_indicator = 1; |
| 2503 | return NULL; |
| 2504 | } |
| 2505 | goto done; |
| 2506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2507 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2508 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2509 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2510 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2511 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2512 | } |
| 2513 | |
| 2514 | // dotted_as_names: ','.dotted_as_name+ |
| 2515 | static asdl_seq* |
| 2516 | dotted_as_names_rule(Parser *p) |
| 2517 | { |
| 2518 | if (p->error_indicator) { |
| 2519 | return NULL; |
| 2520 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2521 | asdl_seq* _res = NULL; |
| 2522 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2523 | { // ','.dotted_as_name+ |
| 2524 | asdl_seq * a; |
| 2525 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2526 | (a = _gather_35_rule(p)) // ','.dotted_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2527 | ) |
| 2528 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2529 | _res = a; |
| 2530 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2531 | p->error_indicator = 1; |
| 2532 | return NULL; |
| 2533 | } |
| 2534 | goto done; |
| 2535 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2536 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2537 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2538 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2539 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2540 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2541 | } |
| 2542 | |
| 2543 | // dotted_as_name: dotted_name ['as' NAME] |
| 2544 | static alias_ty |
| 2545 | dotted_as_name_rule(Parser *p) |
| 2546 | { |
| 2547 | if (p->error_indicator) { |
| 2548 | return NULL; |
| 2549 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2550 | alias_ty _res = NULL; |
| 2551 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2552 | { // dotted_name ['as' NAME] |
| 2553 | expr_ty a; |
| 2554 | void *b; |
| 2555 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2556 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2557 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2558 | (b = _tmp_37_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2559 | ) |
| 2560 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2561 | _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2562 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2563 | p->error_indicator = 1; |
| 2564 | return NULL; |
| 2565 | } |
| 2566 | goto done; |
| 2567 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2568 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2569 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2570 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2571 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2572 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2573 | } |
| 2574 | |
| 2575 | // Left-recursive |
| 2576 | // dotted_name: dotted_name '.' NAME | NAME |
| 2577 | static expr_ty dotted_name_raw(Parser *); |
| 2578 | static expr_ty |
| 2579 | dotted_name_rule(Parser *p) |
| 2580 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2581 | expr_ty _res = NULL; |
| 2582 | if (_PyPegen_is_memoized(p, dotted_name_type, &_res)) |
| 2583 | return _res; |
| 2584 | int _mark = p->mark; |
| 2585 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2586 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2587 | int tmpvar_0 = _PyPegen_update_memo(p, _mark, dotted_name_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2588 | if (tmpvar_0) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2589 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2590 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2591 | p->mark = _mark; |
| 2592 | void *_raw = dotted_name_raw(p); |
| 2593 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2594 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2595 | _resmark = p->mark; |
| 2596 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2597 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2598 | p->mark = _resmark; |
| 2599 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2600 | } |
| 2601 | static expr_ty |
| 2602 | dotted_name_raw(Parser *p) |
| 2603 | { |
| 2604 | if (p->error_indicator) { |
| 2605 | return NULL; |
| 2606 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2607 | expr_ty _res = NULL; |
| 2608 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2609 | { // dotted_name '.' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2610 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2611 | expr_ty a; |
| 2612 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2613 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2614 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2615 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2616 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2617 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2618 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2619 | ) |
| 2620 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2621 | _res = _PyPegen_join_names_with_dot ( p , a , b ); |
| 2622 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2623 | p->error_indicator = 1; |
| 2624 | return NULL; |
| 2625 | } |
| 2626 | goto done; |
| 2627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2628 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2629 | } |
| 2630 | { // NAME |
| 2631 | expr_ty name_var; |
| 2632 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2633 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2634 | ) |
| 2635 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2636 | _res = name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2637 | goto done; |
| 2638 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2639 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2640 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2641 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2642 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2643 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2644 | } |
| 2645 | |
| 2646 | // if_stmt: |
| 2647 | // | 'if' named_expression ':' block elif_stmt |
| 2648 | // | 'if' named_expression ':' block else_block? |
| 2649 | static stmt_ty |
| 2650 | if_stmt_rule(Parser *p) |
| 2651 | { |
| 2652 | if (p->error_indicator) { |
| 2653 | return NULL; |
| 2654 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2655 | stmt_ty _res = NULL; |
| 2656 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2657 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2658 | p->error_indicator = 1; |
| 2659 | return NULL; |
| 2660 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2661 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2662 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2663 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2664 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2665 | { // 'if' named_expression ':' block elif_stmt |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2666 | Token * _keyword; |
| 2667 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2668 | expr_ty a; |
| 2669 | asdl_seq* b; |
| 2670 | stmt_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2671 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2672 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2673 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2674 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2675 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2676 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2679 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2680 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2681 | ) |
| 2682 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2683 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2684 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2685 | return NULL; |
| 2686 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2687 | int _end_lineno = _token->end_lineno; |
| 2688 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2689 | int _end_col_offset = _token->end_col_offset; |
| 2690 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2691 | _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2692 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2693 | p->error_indicator = 1; |
| 2694 | return NULL; |
| 2695 | } |
| 2696 | goto done; |
| 2697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2698 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2699 | } |
| 2700 | { // 'if' named_expression ':' block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2701 | Token * _keyword; |
| 2702 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2703 | expr_ty a; |
| 2704 | asdl_seq* b; |
| 2705 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2706 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2707 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2708 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2709 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2710 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2711 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2714 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2715 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2716 | ) |
| 2717 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2718 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2719 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2720 | return NULL; |
| 2721 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2722 | int _end_lineno = _token->end_lineno; |
| 2723 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2724 | int _end_col_offset = _token->end_col_offset; |
| 2725 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2726 | _res = _Py_If ( a , b , c , EXTRA ); |
| 2727 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2728 | p->error_indicator = 1; |
| 2729 | return NULL; |
| 2730 | } |
| 2731 | goto done; |
| 2732 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2733 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2734 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2735 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2736 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2737 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2738 | } |
| 2739 | |
| 2740 | // elif_stmt: |
| 2741 | // | 'elif' named_expression ':' block elif_stmt |
| 2742 | // | 'elif' named_expression ':' block else_block? |
| 2743 | static stmt_ty |
| 2744 | elif_stmt_rule(Parser *p) |
| 2745 | { |
| 2746 | if (p->error_indicator) { |
| 2747 | return NULL; |
| 2748 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2749 | stmt_ty _res = NULL; |
| 2750 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2751 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2752 | p->error_indicator = 1; |
| 2753 | return NULL; |
| 2754 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2755 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2756 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2757 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2758 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2759 | { // 'elif' named_expression ':' block elif_stmt |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2760 | Token * _keyword; |
| 2761 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2762 | expr_ty a; |
| 2763 | asdl_seq* b; |
| 2764 | stmt_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2765 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2766 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2767 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2768 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2769 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2770 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2773 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2774 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2775 | ) |
| 2776 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2777 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2778 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2779 | return NULL; |
| 2780 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2781 | int _end_lineno = _token->end_lineno; |
| 2782 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2783 | int _end_col_offset = _token->end_col_offset; |
| 2784 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2785 | _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2786 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2787 | p->error_indicator = 1; |
| 2788 | return NULL; |
| 2789 | } |
| 2790 | goto done; |
| 2791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2792 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2793 | } |
| 2794 | { // 'elif' named_expression ':' block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2795 | Token * _keyword; |
| 2796 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2797 | expr_ty a; |
| 2798 | asdl_seq* b; |
| 2799 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2800 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2801 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2802 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2803 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2804 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2805 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2808 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2809 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2810 | ) |
| 2811 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2812 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2813 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2814 | return NULL; |
| 2815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2816 | int _end_lineno = _token->end_lineno; |
| 2817 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2818 | int _end_col_offset = _token->end_col_offset; |
| 2819 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2820 | _res = _Py_If ( a , b , c , EXTRA ); |
| 2821 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2822 | p->error_indicator = 1; |
| 2823 | return NULL; |
| 2824 | } |
| 2825 | goto done; |
| 2826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2827 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2829 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2830 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2831 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2832 | } |
| 2833 | |
| 2834 | // else_block: 'else' ':' block |
| 2835 | static asdl_seq* |
| 2836 | else_block_rule(Parser *p) |
| 2837 | { |
| 2838 | if (p->error_indicator) { |
| 2839 | return NULL; |
| 2840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2841 | asdl_seq* _res = NULL; |
| 2842 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2843 | { // 'else' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2844 | Token * _keyword; |
| 2845 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2846 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2847 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2848 | (_keyword = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2849 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2850 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2851 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2852 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2853 | ) |
| 2854 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2855 | _res = b; |
| 2856 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2857 | p->error_indicator = 1; |
| 2858 | return NULL; |
| 2859 | } |
| 2860 | goto done; |
| 2861 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2862 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2863 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2864 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2865 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2866 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2867 | } |
| 2868 | |
| 2869 | // while_stmt: 'while' named_expression ':' block else_block? |
| 2870 | static stmt_ty |
| 2871 | while_stmt_rule(Parser *p) |
| 2872 | { |
| 2873 | if (p->error_indicator) { |
| 2874 | return NULL; |
| 2875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2876 | stmt_ty _res = NULL; |
| 2877 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2878 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2879 | p->error_indicator = 1; |
| 2880 | return NULL; |
| 2881 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2882 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2883 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2884 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2885 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2886 | { // 'while' named_expression ':' block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2887 | Token * _keyword; |
| 2888 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2889 | expr_ty a; |
| 2890 | asdl_seq* b; |
| 2891 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2892 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2893 | (_keyword = _PyPegen_expect_token(p, 512)) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2894 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2895 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2896 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2897 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2900 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2901 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2902 | ) |
| 2903 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2904 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2905 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2906 | return NULL; |
| 2907 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2908 | int _end_lineno = _token->end_lineno; |
| 2909 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2910 | int _end_col_offset = _token->end_col_offset; |
| 2911 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2912 | _res = _Py_While ( a , b , c , EXTRA ); |
| 2913 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2914 | p->error_indicator = 1; |
| 2915 | return NULL; |
| 2916 | } |
| 2917 | goto done; |
| 2918 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2919 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2920 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2921 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2922 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2923 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2924 | } |
| 2925 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2926 | // for_stmt: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2927 | // | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
| 2928 | // | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2929 | static stmt_ty |
| 2930 | for_stmt_rule(Parser *p) |
| 2931 | { |
| 2932 | if (p->error_indicator) { |
| 2933 | return NULL; |
| 2934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2935 | stmt_ty _res = NULL; |
| 2936 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2937 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2938 | p->error_indicator = 1; |
| 2939 | return NULL; |
| 2940 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2941 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2942 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2943 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2944 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2945 | { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2946 | Token * _keyword; |
| 2947 | Token * _keyword_1; |
| 2948 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2949 | asdl_seq* b; |
| 2950 | void *el; |
| 2951 | expr_ty ex; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2952 | expr_ty t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2953 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2954 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2955 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2956 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2957 | (t = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2958 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2959 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2960 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2961 | (ex = star_expressions_rule(p)) // star_expressions |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2962 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2963 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
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 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2968 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2969 | (el = else_block_rule(p), 1) // else_block? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2970 | ) |
| 2971 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2972 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2973 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2974 | return NULL; |
| 2975 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2976 | int _end_lineno = _token->end_lineno; |
| 2977 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2978 | int _end_col_offset = _token->end_col_offset; |
| 2979 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2980 | _res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 2981 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2982 | p->error_indicator = 1; |
| 2983 | return NULL; |
| 2984 | } |
| 2985 | goto done; |
| 2986 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2987 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2988 | } |
| 2989 | { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2990 | Token * _keyword; |
| 2991 | Token * _keyword_1; |
| 2992 | Token * _literal; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2993 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2994 | asdl_seq* b; |
| 2995 | void *el; |
| 2996 | expr_ty ex; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2997 | expr_ty t; |
| 2998 | void *tc; |
| 2999 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3000 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3001 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3002 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3003 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3004 | (t = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3005 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3006 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3007 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3008 | (ex = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3009 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3010 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3011 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3012 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3013 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3014 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3015 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3016 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3017 | ) |
| 3018 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3019 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3020 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3021 | return NULL; |
| 3022 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3023 | int _end_lineno = _token->end_lineno; |
| 3024 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3025 | int _end_col_offset = _token->end_col_offset; |
| 3026 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3027 | _res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 3028 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3029 | p->error_indicator = 1; |
| 3030 | return NULL; |
| 3031 | } |
| 3032 | goto done; |
| 3033 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3034 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3035 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3036 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3037 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3038 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3039 | } |
| 3040 | |
| 3041 | // with_stmt: |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3042 | // | 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3043 | // | 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3044 | // | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3045 | // | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3046 | static stmt_ty |
| 3047 | with_stmt_rule(Parser *p) |
| 3048 | { |
| 3049 | if (p->error_indicator) { |
| 3050 | return NULL; |
| 3051 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3052 | stmt_ty _res = NULL; |
| 3053 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3054 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3055 | p->error_indicator = 1; |
| 3056 | return NULL; |
| 3057 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3058 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3059 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3060 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3061 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3062 | { // 'with' '(' ','.with_item+ ','? ')' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3063 | Token * _keyword; |
| 3064 | Token * _literal; |
| 3065 | Token * _literal_1; |
| 3066 | Token * _literal_2; |
| 3067 | void *_opt_var; |
| 3068 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3069 | asdl_seq * a; |
| 3070 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3071 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3072 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3073 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3074 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3075 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3076 | (a = _gather_38_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3077 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3078 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3079 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3080 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3081 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3082 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3083 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3084 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3085 | ) |
| 3086 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3087 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3088 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3089 | return NULL; |
| 3090 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3091 | int _end_lineno = _token->end_lineno; |
| 3092 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3093 | int _end_col_offset = _token->end_col_offset; |
| 3094 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3095 | _res = _Py_With ( a , b , NULL , EXTRA ); |
| 3096 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3097 | p->error_indicator = 1; |
| 3098 | return NULL; |
| 3099 | } |
| 3100 | goto done; |
| 3101 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3102 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3103 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3104 | { // 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3105 | Token * _keyword; |
| 3106 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3107 | asdl_seq * a; |
| 3108 | asdl_seq* b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3109 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3110 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3111 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3112 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3113 | (a = _gather_40_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3114 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3115 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3116 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3117 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3118 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3119 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3120 | ) |
| 3121 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3122 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3123 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3124 | return NULL; |
| 3125 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3126 | int _end_lineno = _token->end_lineno; |
| 3127 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3128 | int _end_col_offset = _token->end_col_offset; |
| 3129 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3130 | _res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3131 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3132 | p->error_indicator = 1; |
| 3133 | return NULL; |
| 3134 | } |
| 3135 | goto done; |
| 3136 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3137 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3138 | } |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3139 | { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3140 | Token * _keyword; |
| 3141 | Token * _literal; |
| 3142 | Token * _literal_1; |
| 3143 | Token * _literal_2; |
| 3144 | void *_opt_var; |
| 3145 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3146 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3147 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3148 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3149 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3150 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
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 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3153 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3154 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3155 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3156 | (a = _gather_42_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3157 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3158 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3159 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3160 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3161 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3162 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3163 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3164 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3165 | ) |
| 3166 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3167 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3168 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3169 | return NULL; |
| 3170 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3171 | int _end_lineno = _token->end_lineno; |
| 3172 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3173 | int _end_col_offset = _token->end_col_offset; |
| 3174 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3175 | _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) ); |
| 3176 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3177 | p->error_indicator = 1; |
| 3178 | return NULL; |
| 3179 | } |
| 3180 | goto done; |
| 3181 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3182 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3183 | } |
| 3184 | { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3185 | Token * _keyword; |
| 3186 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3187 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3188 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3189 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3190 | void *tc; |
| 3191 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3192 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3193 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3194 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3195 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3196 | (a = _gather_44_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3197 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3198 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3201 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3202 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3203 | ) |
| 3204 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3205 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3206 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3207 | return NULL; |
| 3208 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3209 | int _end_lineno = _token->end_lineno; |
| 3210 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3211 | int _end_col_offset = _token->end_col_offset; |
| 3212 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3213 | _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 3214 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3215 | p->error_indicator = 1; |
| 3216 | return NULL; |
| 3217 | } |
| 3218 | goto done; |
| 3219 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3220 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3221 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3222 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3223 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3224 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3225 | } |
| 3226 | |
| 3227 | // with_item: expression ['as' target] |
| 3228 | static withitem_ty |
| 3229 | with_item_rule(Parser *p) |
| 3230 | { |
| 3231 | if (p->error_indicator) { |
| 3232 | return NULL; |
| 3233 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3234 | withitem_ty _res = NULL; |
| 3235 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3236 | { // expression ['as' target] |
| 3237 | expr_ty e; |
| 3238 | void *o; |
| 3239 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3240 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3241 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3242 | (o = _tmp_46_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3243 | ) |
| 3244 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3245 | _res = _Py_withitem ( e , o , p -> arena ); |
| 3246 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3247 | p->error_indicator = 1; |
| 3248 | return NULL; |
| 3249 | } |
| 3250 | goto done; |
| 3251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3252 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3253 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3254 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3255 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3256 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3257 | } |
| 3258 | |
| 3259 | // try_stmt: |
| 3260 | // | 'try' ':' block finally_block |
| 3261 | // | 'try' ':' block except_block+ else_block? finally_block? |
| 3262 | static stmt_ty |
| 3263 | try_stmt_rule(Parser *p) |
| 3264 | { |
| 3265 | if (p->error_indicator) { |
| 3266 | return NULL; |
| 3267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3268 | stmt_ty _res = NULL; |
| 3269 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3270 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3271 | p->error_indicator = 1; |
| 3272 | return NULL; |
| 3273 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3274 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3275 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3276 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3277 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3278 | { // 'try' ':' block finally_block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3279 | Token * _keyword; |
| 3280 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3281 | asdl_seq* b; |
| 3282 | asdl_seq* f; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3283 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3284 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3285 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3286 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3289 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3290 | (f = finally_block_rule(p)) // finally_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3291 | ) |
| 3292 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3293 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3294 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3295 | return NULL; |
| 3296 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3297 | int _end_lineno = _token->end_lineno; |
| 3298 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3299 | int _end_col_offset = _token->end_col_offset; |
| 3300 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3301 | _res = _Py_Try ( b , NULL , NULL , f , EXTRA ); |
| 3302 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3303 | p->error_indicator = 1; |
| 3304 | return NULL; |
| 3305 | } |
| 3306 | goto done; |
| 3307 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3308 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3309 | } |
| 3310 | { // 'try' ':' block except_block+ else_block? finally_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3311 | Token * _keyword; |
| 3312 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3313 | asdl_seq* b; |
| 3314 | void *el; |
| 3315 | asdl_seq * ex; |
| 3316 | void *f; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3317 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3318 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3319 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3320 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // 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 | (ex = _loop1_47_rule(p)) // except_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 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3327 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3328 | (f = finally_block_rule(p), 1) // finally_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3329 | ) |
| 3330 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3331 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3332 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3333 | return NULL; |
| 3334 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3335 | int _end_lineno = _token->end_lineno; |
| 3336 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3337 | int _end_col_offset = _token->end_col_offset; |
| 3338 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3339 | _res = _Py_Try ( b , ex , el , f , EXTRA ); |
| 3340 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3341 | p->error_indicator = 1; |
| 3342 | return NULL; |
| 3343 | } |
| 3344 | goto done; |
| 3345 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3346 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3348 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3349 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3350 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3351 | } |
| 3352 | |
| 3353 | // except_block: 'except' expression ['as' target] ':' block | 'except' ':' block |
| 3354 | static excepthandler_ty |
| 3355 | except_block_rule(Parser *p) |
| 3356 | { |
| 3357 | if (p->error_indicator) { |
| 3358 | return NULL; |
| 3359 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3360 | excepthandler_ty _res = NULL; |
| 3361 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3362 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3363 | p->error_indicator = 1; |
| 3364 | return NULL; |
| 3365 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3366 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3367 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3368 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3369 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3370 | { // 'except' expression ['as' target] ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3371 | Token * _keyword; |
| 3372 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3373 | asdl_seq* b; |
| 3374 | expr_ty e; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3375 | void *t; |
| 3376 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3377 | (_keyword = _PyPegen_expect_token(p, 520)) // token='except' |
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 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3380 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3381 | (t = _tmp_48_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3382 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3383 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3384 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3385 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3386 | ) |
| 3387 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3388 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3389 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3390 | return NULL; |
| 3391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3392 | int _end_lineno = _token->end_lineno; |
| 3393 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3394 | int _end_col_offset = _token->end_col_offset; |
| 3395 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3396 | _res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA ); |
| 3397 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3398 | p->error_indicator = 1; |
| 3399 | return NULL; |
| 3400 | } |
| 3401 | goto done; |
| 3402 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3403 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3404 | } |
| 3405 | { // 'except' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3406 | Token * _keyword; |
| 3407 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3408 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3409 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3410 | (_keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3411 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3412 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3413 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3414 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3415 | ) |
| 3416 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3417 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3418 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3419 | return NULL; |
| 3420 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3421 | int _end_lineno = _token->end_lineno; |
| 3422 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3423 | int _end_col_offset = _token->end_col_offset; |
| 3424 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3425 | _res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA ); |
| 3426 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3427 | p->error_indicator = 1; |
| 3428 | return NULL; |
| 3429 | } |
| 3430 | goto done; |
| 3431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3432 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3433 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3434 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3435 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3436 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3437 | } |
| 3438 | |
| 3439 | // finally_block: 'finally' ':' block |
| 3440 | static asdl_seq* |
| 3441 | finally_block_rule(Parser *p) |
| 3442 | { |
| 3443 | if (p->error_indicator) { |
| 3444 | return NULL; |
| 3445 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3446 | asdl_seq* _res = NULL; |
| 3447 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3448 | { // 'finally' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3449 | Token * _keyword; |
| 3450 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3451 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3452 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3453 | (_keyword = _PyPegen_expect_token(p, 521)) // token='finally' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3454 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3455 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3456 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3457 | (a = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3458 | ) |
| 3459 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3460 | _res = a; |
| 3461 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3462 | p->error_indicator = 1; |
| 3463 | return NULL; |
| 3464 | } |
| 3465 | goto done; |
| 3466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3467 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3468 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3469 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3470 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3471 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3472 | } |
| 3473 | |
| 3474 | // return_stmt: 'return' star_expressions? |
| 3475 | static stmt_ty |
| 3476 | return_stmt_rule(Parser *p) |
| 3477 | { |
| 3478 | if (p->error_indicator) { |
| 3479 | return NULL; |
| 3480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3481 | stmt_ty _res = NULL; |
| 3482 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3483 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3484 | p->error_indicator = 1; |
| 3485 | return NULL; |
| 3486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3487 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3488 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3489 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3490 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3491 | { // 'return' star_expressions? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3492 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3493 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3494 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3495 | (_keyword = _PyPegen_expect_token(p, 500)) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3496 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3497 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3498 | ) |
| 3499 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3500 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3501 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3502 | return NULL; |
| 3503 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3504 | int _end_lineno = _token->end_lineno; |
| 3505 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3506 | int _end_col_offset = _token->end_col_offset; |
| 3507 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3508 | _res = _Py_Return ( a , EXTRA ); |
| 3509 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3510 | p->error_indicator = 1; |
| 3511 | return NULL; |
| 3512 | } |
| 3513 | goto done; |
| 3514 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3515 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3517 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3518 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3519 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3520 | } |
| 3521 | |
| 3522 | // raise_stmt: 'raise' expression ['from' expression] | 'raise' |
| 3523 | static stmt_ty |
| 3524 | raise_stmt_rule(Parser *p) |
| 3525 | { |
| 3526 | if (p->error_indicator) { |
| 3527 | return NULL; |
| 3528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3529 | stmt_ty _res = NULL; |
| 3530 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3531 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3532 | p->error_indicator = 1; |
| 3533 | return NULL; |
| 3534 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3535 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3536 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3537 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3538 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3539 | { // 'raise' expression ['from' expression] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3540 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3541 | expr_ty a; |
| 3542 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3543 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3544 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
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 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3547 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3548 | (b = _tmp_49_rule(p), 1) // ['from' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3549 | ) |
| 3550 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3551 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3552 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3553 | return NULL; |
| 3554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3555 | int _end_lineno = _token->end_lineno; |
| 3556 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3557 | int _end_col_offset = _token->end_col_offset; |
| 3558 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3559 | _res = _Py_Raise ( a , b , EXTRA ); |
| 3560 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3561 | p->error_indicator = 1; |
| 3562 | return NULL; |
| 3563 | } |
| 3564 | goto done; |
| 3565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3566 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3567 | } |
| 3568 | { // 'raise' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3569 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3570 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3571 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3572 | ) |
| 3573 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3574 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3575 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3576 | return NULL; |
| 3577 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3578 | int _end_lineno = _token->end_lineno; |
| 3579 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3580 | int _end_col_offset = _token->end_col_offset; |
| 3581 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3582 | _res = _Py_Raise ( NULL , NULL , EXTRA ); |
| 3583 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3584 | p->error_indicator = 1; |
| 3585 | return NULL; |
| 3586 | } |
| 3587 | goto done; |
| 3588 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3589 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3590 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3591 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3592 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3593 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3594 | } |
| 3595 | |
| 3596 | // function_def: decorators function_def_raw | function_def_raw |
| 3597 | static stmt_ty |
| 3598 | function_def_rule(Parser *p) |
| 3599 | { |
| 3600 | if (p->error_indicator) { |
| 3601 | return NULL; |
| 3602 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3603 | stmt_ty _res = NULL; |
| 3604 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3605 | { // decorators function_def_raw |
| 3606 | asdl_seq* d; |
| 3607 | stmt_ty f; |
| 3608 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3609 | (d = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3610 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3611 | (f = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3612 | ) |
| 3613 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3614 | _res = _PyPegen_function_def_decorators ( p , d , f ); |
| 3615 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3616 | p->error_indicator = 1; |
| 3617 | return NULL; |
| 3618 | } |
| 3619 | goto done; |
| 3620 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3621 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3622 | } |
| 3623 | { // function_def_raw |
| 3624 | stmt_ty function_def_raw_var; |
| 3625 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3626 | (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3627 | ) |
| 3628 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3629 | _res = function_def_raw_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3630 | goto done; |
| 3631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3632 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3634 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3635 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3636 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3637 | } |
| 3638 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3639 | // function_def_raw: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3640 | // | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3641 | // | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3642 | static stmt_ty |
| 3643 | function_def_raw_rule(Parser *p) |
| 3644 | { |
| 3645 | if (p->error_indicator) { |
| 3646 | return NULL; |
| 3647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3648 | stmt_ty _res = NULL; |
| 3649 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3650 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3651 | p->error_indicator = 1; |
| 3652 | return NULL; |
| 3653 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3654 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3655 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3656 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3657 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3658 | { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3659 | Token * _keyword; |
| 3660 | Token * _literal; |
| 3661 | Token * _literal_1; |
| 3662 | Token * _literal_2; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3663 | void *a; |
| 3664 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3665 | expr_ty n; |
| 3666 | void *params; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3667 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3668 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3669 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3670 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3671 | (n = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3672 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3673 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3674 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3675 | (params = params_rule(p), 1) // params? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3676 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3677 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3678 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3679 | (a = _tmp_50_rule(p), 1) // ['->' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3680 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3681 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3682 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3683 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3684 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3685 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3686 | ) |
| 3687 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3688 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3689 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3690 | return NULL; |
| 3691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3692 | int _end_lineno = _token->end_lineno; |
| 3693 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3694 | int _end_col_offset = _token->end_col_offset; |
| 3695 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3696 | _res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3697 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3698 | p->error_indicator = 1; |
| 3699 | return NULL; |
| 3700 | } |
| 3701 | goto done; |
| 3702 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3703 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3704 | } |
| 3705 | { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3706 | Token * _keyword; |
| 3707 | Token * _literal; |
| 3708 | Token * _literal_1; |
| 3709 | Token * _literal_2; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3710 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3711 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3712 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3713 | expr_ty n; |
| 3714 | void *params; |
| 3715 | void *tc; |
| 3716 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3717 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3718 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3719 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3720 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3721 | (n = _PyPegen_name_token(p)) // NAME |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3722 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3723 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3724 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3725 | (params = params_rule(p), 1) // params? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3726 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3727 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3728 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3729 | (a = _tmp_51_rule(p), 1) // ['->' expression] |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3730 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3731 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3734 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3735 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3736 | ) |
| 3737 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3738 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3739 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3740 | return NULL; |
| 3741 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3742 | int _end_lineno = _token->end_lineno; |
| 3743 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3744 | int _end_col_offset = _token->end_col_offset; |
| 3745 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3746 | _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 ) ); |
| 3747 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3748 | p->error_indicator = 1; |
| 3749 | return NULL; |
| 3750 | } |
| 3751 | goto done; |
| 3752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3753 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3754 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3755 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3756 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3757 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3758 | } |
| 3759 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3760 | // func_type_comment: |
| 3761 | // | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 3762 | // | invalid_double_type_comments |
| 3763 | // | TYPE_COMMENT |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 3764 | static Token* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3765 | func_type_comment_rule(Parser *p) |
| 3766 | { |
| 3767 | if (p->error_indicator) { |
| 3768 | return NULL; |
| 3769 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3770 | Token* _res = NULL; |
| 3771 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3772 | { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3773 | Token * newline_var; |
| 3774 | Token * t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3775 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3776 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3777 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3778 | (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3779 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3780 | _PyPegen_lookahead(1, _tmp_52_rule, p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3781 | ) |
| 3782 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3783 | _res = t; |
| 3784 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3785 | p->error_indicator = 1; |
| 3786 | return NULL; |
| 3787 | } |
| 3788 | goto done; |
| 3789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3790 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3791 | } |
| 3792 | { // invalid_double_type_comments |
| 3793 | void *invalid_double_type_comments_var; |
| 3794 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3795 | (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] | 3796 | ) |
| 3797 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3798 | _res = invalid_double_type_comments_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3799 | goto done; |
| 3800 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3801 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3802 | } |
| 3803 | { // TYPE_COMMENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3804 | Token * type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3805 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3806 | (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] | 3807 | ) |
| 3808 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3809 | _res = type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3810 | goto done; |
| 3811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3812 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3814 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3815 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3816 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3817 | } |
| 3818 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3819 | // params: invalid_parameters | parameters |
| 3820 | static arguments_ty |
| 3821 | params_rule(Parser *p) |
| 3822 | { |
| 3823 | if (p->error_indicator) { |
| 3824 | return NULL; |
| 3825 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3826 | arguments_ty _res = NULL; |
| 3827 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3828 | { // invalid_parameters |
| 3829 | void *invalid_parameters_var; |
| 3830 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3831 | (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3832 | ) |
| 3833 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3834 | _res = invalid_parameters_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3835 | goto done; |
| 3836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3837 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3838 | } |
| 3839 | { // parameters |
| 3840 | arguments_ty parameters_var; |
| 3841 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3842 | (parameters_var = parameters_rule(p)) // parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3843 | ) |
| 3844 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3845 | _res = parameters_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3846 | goto done; |
| 3847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3848 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3849 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3850 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3851 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3852 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3853 | } |
| 3854 | |
| 3855 | // parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3856 | // | slash_no_default param_no_default* param_with_default* star_etc? |
| 3857 | // | slash_with_default param_with_default* star_etc? |
| 3858 | // | param_no_default+ param_with_default* star_etc? |
| 3859 | // | param_with_default+ star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3860 | // | star_etc |
| 3861 | static arguments_ty |
| 3862 | parameters_rule(Parser *p) |
| 3863 | { |
| 3864 | if (p->error_indicator) { |
| 3865 | return NULL; |
| 3866 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3867 | arguments_ty _res = NULL; |
| 3868 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3869 | { // slash_no_default param_no_default* param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3870 | asdl_seq* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3871 | asdl_seq * b; |
| 3872 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3873 | void *d; |
| 3874 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3875 | (a = slash_no_default_rule(p)) // slash_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 | (b = _loop0_53_rule(p)) // param_no_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 | (c = _loop0_54_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3880 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3881 | (d = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3882 | ) |
| 3883 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3884 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 3885 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3886 | p->error_indicator = 1; |
| 3887 | return NULL; |
| 3888 | } |
| 3889 | goto done; |
| 3890 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3891 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3892 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3893 | { // slash_with_default param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3894 | SlashWithDefault* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3895 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3896 | void *c; |
| 3897 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3898 | (a = slash_with_default_rule(p)) // slash_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 | (b = _loop0_55_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3901 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3902 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3903 | ) |
| 3904 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3905 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 3906 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3907 | p->error_indicator = 1; |
| 3908 | return NULL; |
| 3909 | } |
| 3910 | goto done; |
| 3911 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3912 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3913 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3914 | { // param_no_default+ param_with_default* star_etc? |
| 3915 | asdl_seq * a; |
| 3916 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3917 | void *c; |
| 3918 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3919 | (a = _loop1_56_rule(p)) // param_no_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 | (b = _loop0_57_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3922 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3923 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3924 | ) |
| 3925 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3926 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 3927 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3928 | p->error_indicator = 1; |
| 3929 | return NULL; |
| 3930 | } |
| 3931 | goto done; |
| 3932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3933 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3934 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3935 | { // param_with_default+ star_etc? |
| 3936 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3937 | void *b; |
| 3938 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3939 | (a = _loop1_58_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3940 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3941 | (b = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3942 | ) |
| 3943 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3944 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 3945 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3946 | p->error_indicator = 1; |
| 3947 | return NULL; |
| 3948 | } |
| 3949 | goto done; |
| 3950 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3951 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3952 | } |
| 3953 | { // star_etc |
| 3954 | StarEtc* a; |
| 3955 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3956 | (a = star_etc_rule(p)) // star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3957 | ) |
| 3958 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3959 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 3960 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3961 | p->error_indicator = 1; |
| 3962 | return NULL; |
| 3963 | } |
| 3964 | goto done; |
| 3965 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3966 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3967 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3968 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3969 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3970 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3971 | } |
| 3972 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3973 | // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3974 | static asdl_seq* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3975 | slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3976 | { |
| 3977 | if (p->error_indicator) { |
| 3978 | return NULL; |
| 3979 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3980 | asdl_seq* _res = NULL; |
| 3981 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3982 | { // param_no_default+ '/' ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3983 | Token * _literal; |
| 3984 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3985 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3986 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3987 | (a = _loop1_59_rule(p)) // param_no_default+ |
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 = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3990 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3991 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3992 | ) |
| 3993 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3994 | _res = a; |
| 3995 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3996 | p->error_indicator = 1; |
| 3997 | return NULL; |
| 3998 | } |
| 3999 | goto done; |
| 4000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4001 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4002 | } |
| 4003 | { // param_no_default+ '/' &')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4004 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4005 | asdl_seq * a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4006 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4007 | (a = _loop1_60_rule(p)) // param_no_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4008 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4009 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4010 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4011 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4012 | ) |
| 4013 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4014 | _res = a; |
| 4015 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4016 | p->error_indicator = 1; |
| 4017 | return NULL; |
| 4018 | } |
| 4019 | goto done; |
| 4020 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4021 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4022 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4023 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4024 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4025 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4026 | } |
| 4027 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4028 | // slash_with_default: |
| 4029 | // | param_no_default* param_with_default+ '/' ',' |
| 4030 | // | param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4031 | static SlashWithDefault* |
| 4032 | slash_with_default_rule(Parser *p) |
| 4033 | { |
| 4034 | if (p->error_indicator) { |
| 4035 | return NULL; |
| 4036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4037 | SlashWithDefault* _res = NULL; |
| 4038 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4039 | { // param_no_default* param_with_default+ '/' ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4040 | Token * _literal; |
| 4041 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4042 | asdl_seq * a; |
| 4043 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4044 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4045 | (a = _loop0_61_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4046 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4047 | (b = _loop1_62_rule(p)) // param_with_default+ |
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 = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4050 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4051 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4052 | ) |
| 4053 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4054 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 4055 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4056 | p->error_indicator = 1; |
| 4057 | return NULL; |
| 4058 | } |
| 4059 | goto done; |
| 4060 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4061 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4062 | } |
| 4063 | { // param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4064 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4065 | asdl_seq * a; |
| 4066 | asdl_seq * b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4067 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4068 | (a = _loop0_63_rule(p)) // param_no_default* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4069 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4070 | (b = _loop1_64_rule(p)) // param_with_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4071 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4072 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4073 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4074 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4075 | ) |
| 4076 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4077 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 4078 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4079 | p->error_indicator = 1; |
| 4080 | return NULL; |
| 4081 | } |
| 4082 | goto done; |
| 4083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4084 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4086 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4087 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4088 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4089 | } |
| 4090 | |
| 4091 | // star_etc: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4092 | // | '*' param_no_default param_maybe_default* kwds? |
| 4093 | // | '*' ',' param_maybe_default+ kwds? |
| 4094 | // | kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4095 | // | invalid_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4096 | static StarEtc* |
| 4097 | star_etc_rule(Parser *p) |
| 4098 | { |
| 4099 | if (p->error_indicator) { |
| 4100 | return NULL; |
| 4101 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4102 | StarEtc* _res = NULL; |
| 4103 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4104 | { // '*' param_no_default param_maybe_default* kwds? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4105 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4106 | arg_ty a; |
| 4107 | asdl_seq * b; |
| 4108 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4109 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4110 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
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 | (a = param_no_default_rule(p)) // param_no_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 | (b = _loop0_65_rule(p)) // param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4115 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4116 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4117 | ) |
| 4118 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4119 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 4120 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4121 | p->error_indicator = 1; |
| 4122 | return NULL; |
| 4123 | } |
| 4124 | goto done; |
| 4125 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4126 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4127 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4128 | { // '*' ',' param_maybe_default+ kwds? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4129 | Token * _literal; |
| 4130 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4131 | asdl_seq * b; |
| 4132 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4133 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4134 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4135 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4136 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
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 | (b = _loop1_66_rule(p)) // param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4139 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4140 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4141 | ) |
| 4142 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4143 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 4144 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4145 | p->error_indicator = 1; |
| 4146 | return NULL; |
| 4147 | } |
| 4148 | goto done; |
| 4149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4150 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4151 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4152 | { // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4153 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4154 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4155 | (a = kwds_rule(p)) // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4156 | ) |
| 4157 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4158 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 4159 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4160 | p->error_indicator = 1; |
| 4161 | return NULL; |
| 4162 | } |
| 4163 | goto done; |
| 4164 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4165 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4166 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4167 | { // invalid_star_etc |
| 4168 | void *invalid_star_etc_var; |
| 4169 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4170 | (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4171 | ) |
| 4172 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4173 | _res = invalid_star_etc_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4174 | goto done; |
| 4175 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4176 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4177 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4178 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4179 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4180 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4181 | } |
| 4182 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4183 | // kwds: '**' param_no_default |
| 4184 | static arg_ty |
| 4185 | kwds_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4186 | { |
| 4187 | if (p->error_indicator) { |
| 4188 | return NULL; |
| 4189 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4190 | arg_ty _res = NULL; |
| 4191 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4192 | { // '**' param_no_default |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4193 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4194 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4195 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4196 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4197 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4198 | (a = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4199 | ) |
| 4200 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4201 | _res = a; |
| 4202 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4203 | p->error_indicator = 1; |
| 4204 | return NULL; |
| 4205 | } |
| 4206 | goto done; |
| 4207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4208 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4209 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4210 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4211 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4212 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4213 | } |
| 4214 | |
| 4215 | // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' |
| 4216 | static arg_ty |
| 4217 | param_no_default_rule(Parser *p) |
| 4218 | { |
| 4219 | if (p->error_indicator) { |
| 4220 | return NULL; |
| 4221 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4222 | arg_ty _res = NULL; |
| 4223 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4224 | { // param ',' TYPE_COMMENT? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4225 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4226 | arg_ty a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4227 | void *tc; |
| 4228 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4229 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4230 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4231 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4232 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4233 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4234 | ) |
| 4235 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4236 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 4237 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4238 | p->error_indicator = 1; |
| 4239 | return NULL; |
| 4240 | } |
| 4241 | goto done; |
| 4242 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4243 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4244 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4245 | { // param TYPE_COMMENT? &')' |
| 4246 | arg_ty a; |
| 4247 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4248 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4249 | (a = param_rule(p)) // param |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4252 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4253 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4254 | ) |
| 4255 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4256 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 4257 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4258 | p->error_indicator = 1; |
| 4259 | return NULL; |
| 4260 | } |
| 4261 | goto done; |
| 4262 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4263 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4264 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4265 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4266 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4267 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4268 | } |
| 4269 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4270 | // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4271 | static NameDefaultPair* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4272 | param_with_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4273 | { |
| 4274 | if (p->error_indicator) { |
| 4275 | return NULL; |
| 4276 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4277 | NameDefaultPair* _res = NULL; |
| 4278 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4279 | { // param default ',' TYPE_COMMENT? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4280 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4281 | arg_ty a; |
| 4282 | expr_ty c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4283 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4284 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4285 | (a = param_rule(p)) // param |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4286 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4287 | (c = default_rule(p)) // default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4288 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4289 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4290 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4291 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4292 | ) |
| 4293 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4294 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4295 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4296 | p->error_indicator = 1; |
| 4297 | return NULL; |
| 4298 | } |
| 4299 | goto done; |
| 4300 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4301 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4302 | } |
| 4303 | { // param default TYPE_COMMENT? &')' |
| 4304 | arg_ty a; |
| 4305 | expr_ty c; |
| 4306 | void *tc; |
| 4307 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4308 | (a = param_rule(p)) // param |
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 | (c = default_rule(p)) // default |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4313 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4314 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4315 | ) |
| 4316 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4317 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4318 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4319 | p->error_indicator = 1; |
| 4320 | return NULL; |
| 4321 | } |
| 4322 | goto done; |
| 4323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4324 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4325 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4326 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4327 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4328 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4329 | } |
| 4330 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4331 | // param_maybe_default: |
| 4332 | // | param default? ',' TYPE_COMMENT? |
| 4333 | // | param default? TYPE_COMMENT? &')' |
| 4334 | static NameDefaultPair* |
| 4335 | param_maybe_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4336 | { |
| 4337 | if (p->error_indicator) { |
| 4338 | return NULL; |
| 4339 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4340 | NameDefaultPair* _res = NULL; |
| 4341 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4342 | { // param default? ',' TYPE_COMMENT? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4343 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4344 | arg_ty a; |
| 4345 | void *c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4346 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4347 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4348 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4349 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4350 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4351 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4352 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4353 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4354 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4355 | ) |
| 4356 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4357 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4358 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4359 | p->error_indicator = 1; |
| 4360 | return NULL; |
| 4361 | } |
| 4362 | goto done; |
| 4363 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4364 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4365 | } |
| 4366 | { // param default? TYPE_COMMENT? &')' |
| 4367 | arg_ty a; |
| 4368 | void *c; |
| 4369 | void *tc; |
| 4370 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4371 | (a = param_rule(p)) // param |
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 | (c = default_rule(p), 1) // default? |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4376 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4377 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4378 | ) |
| 4379 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4380 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4381 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4382 | p->error_indicator = 1; |
| 4383 | return NULL; |
| 4384 | } |
| 4385 | goto done; |
| 4386 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4387 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4388 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4389 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4390 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4391 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4392 | } |
| 4393 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4394 | // param: NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4395 | static arg_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4396 | param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4397 | { |
| 4398 | if (p->error_indicator) { |
| 4399 | return NULL; |
| 4400 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4401 | arg_ty _res = NULL; |
| 4402 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4403 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4404 | p->error_indicator = 1; |
| 4405 | return NULL; |
| 4406 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4407 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4408 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4409 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4410 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4411 | { // NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4412 | expr_ty a; |
| 4413 | void *b; |
| 4414 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4415 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4416 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4417 | (b = annotation_rule(p), 1) // annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4418 | ) |
| 4419 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4420 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4421 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4422 | return NULL; |
| 4423 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4424 | int _end_lineno = _token->end_lineno; |
| 4425 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4426 | int _end_col_offset = _token->end_col_offset; |
| 4427 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4428 | _res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); |
| 4429 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4430 | p->error_indicator = 1; |
| 4431 | return NULL; |
| 4432 | } |
| 4433 | goto done; |
| 4434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4435 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4436 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4437 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4438 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4439 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4440 | } |
| 4441 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4442 | // annotation: ':' expression |
| 4443 | static expr_ty |
| 4444 | annotation_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4445 | { |
| 4446 | if (p->error_indicator) { |
| 4447 | return NULL; |
| 4448 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4449 | expr_ty _res = NULL; |
| 4450 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4451 | { // ':' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4452 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4453 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4454 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4455 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4456 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4457 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4458 | ) |
| 4459 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4460 | _res = a; |
| 4461 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4462 | p->error_indicator = 1; |
| 4463 | return NULL; |
| 4464 | } |
| 4465 | goto done; |
| 4466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4467 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4468 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4469 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4470 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4471 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4472 | } |
| 4473 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4474 | // default: '=' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4475 | static expr_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4476 | default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4477 | { |
| 4478 | if (p->error_indicator) { |
| 4479 | return NULL; |
| 4480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4481 | expr_ty _res = NULL; |
| 4482 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4483 | { // '=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4484 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4485 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4486 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4487 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4488 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4489 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4490 | ) |
| 4491 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4492 | _res = a; |
| 4493 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4494 | p->error_indicator = 1; |
| 4495 | return NULL; |
| 4496 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4497 | goto done; |
| 4498 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4499 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4501 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4502 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4503 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4504 | } |
| 4505 | |
| 4506 | // decorators: (('@' named_expression NEWLINE))+ |
| 4507 | static asdl_seq* |
| 4508 | decorators_rule(Parser *p) |
| 4509 | { |
| 4510 | if (p->error_indicator) { |
| 4511 | return NULL; |
| 4512 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4513 | asdl_seq* _res = NULL; |
| 4514 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4515 | { // (('@' named_expression NEWLINE))+ |
| 4516 | asdl_seq * a; |
| 4517 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4518 | (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4519 | ) |
| 4520 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4521 | _res = a; |
| 4522 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4523 | p->error_indicator = 1; |
| 4524 | return NULL; |
| 4525 | } |
| 4526 | goto done; |
| 4527 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4528 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4529 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4530 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4531 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4532 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4533 | } |
| 4534 | |
| 4535 | // class_def: decorators class_def_raw | class_def_raw |
| 4536 | static stmt_ty |
| 4537 | class_def_rule(Parser *p) |
| 4538 | { |
| 4539 | if (p->error_indicator) { |
| 4540 | return NULL; |
| 4541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4542 | stmt_ty _res = NULL; |
| 4543 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4544 | { // decorators class_def_raw |
| 4545 | asdl_seq* a; |
| 4546 | stmt_ty b; |
| 4547 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4548 | (a = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4549 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4550 | (b = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4551 | ) |
| 4552 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4553 | _res = _PyPegen_class_def_decorators ( p , a , b ); |
| 4554 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4555 | p->error_indicator = 1; |
| 4556 | return NULL; |
| 4557 | } |
| 4558 | goto done; |
| 4559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4560 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4561 | } |
| 4562 | { // class_def_raw |
| 4563 | stmt_ty class_def_raw_var; |
| 4564 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4565 | (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4566 | ) |
| 4567 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4568 | _res = class_def_raw_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4569 | goto done; |
| 4570 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4571 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4572 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4573 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4574 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4575 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4576 | } |
| 4577 | |
| 4578 | // class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block |
| 4579 | static stmt_ty |
| 4580 | class_def_raw_rule(Parser *p) |
| 4581 | { |
| 4582 | if (p->error_indicator) { |
| 4583 | return NULL; |
| 4584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4585 | stmt_ty _res = NULL; |
| 4586 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4587 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4588 | p->error_indicator = 1; |
| 4589 | return NULL; |
| 4590 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4591 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4592 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4593 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4594 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4595 | { // 'class' NAME ['(' arguments? ')'] ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4596 | Token * _keyword; |
| 4597 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4598 | expr_ty a; |
| 4599 | void *b; |
| 4600 | asdl_seq* c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4601 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4602 | (_keyword = _PyPegen_expect_token(p, 523)) // token='class' |
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 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4605 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4606 | (b = _tmp_68_rule(p), 1) // ['(' arguments? ')'] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4607 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4608 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4609 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4610 | (c = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4611 | ) |
| 4612 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4613 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4614 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4615 | return NULL; |
| 4616 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4617 | int _end_lineno = _token->end_lineno; |
| 4618 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4619 | int _end_col_offset = _token->end_col_offset; |
| 4620 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4621 | _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 ); |
| 4622 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4623 | p->error_indicator = 1; |
| 4624 | return NULL; |
| 4625 | } |
| 4626 | goto done; |
| 4627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4628 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4629 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4630 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4631 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4632 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4633 | } |
| 4634 | |
| 4635 | // block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block |
| 4636 | static asdl_seq* |
| 4637 | block_rule(Parser *p) |
| 4638 | { |
| 4639 | if (p->error_indicator) { |
| 4640 | return NULL; |
| 4641 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4642 | asdl_seq* _res = NULL; |
| 4643 | if (_PyPegen_is_memoized(p, block_type, &_res)) |
| 4644 | return _res; |
| 4645 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4646 | { // NEWLINE INDENT statements DEDENT |
| 4647 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4648 | Token * dedent_var; |
| 4649 | Token * indent_var; |
| 4650 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4651 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4652 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
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 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
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 | (a = statements_rule(p)) // statements |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4657 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4658 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4659 | ) |
| 4660 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4661 | _res = a; |
| 4662 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4663 | p->error_indicator = 1; |
| 4664 | return NULL; |
| 4665 | } |
| 4666 | goto done; |
| 4667 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4668 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4669 | } |
| 4670 | { // simple_stmt |
| 4671 | asdl_seq* simple_stmt_var; |
| 4672 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4673 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4674 | ) |
| 4675 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4676 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4677 | goto done; |
| 4678 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4679 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4680 | } |
| 4681 | { // invalid_block |
| 4682 | void *invalid_block_var; |
| 4683 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4684 | (invalid_block_var = invalid_block_rule(p)) // invalid_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4685 | ) |
| 4686 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4687 | _res = invalid_block_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4688 | goto done; |
| 4689 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4690 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4692 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4693 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4694 | _PyPegen_insert_memo(p, _mark, block_type, _res); |
| 4695 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4696 | } |
| 4697 | |
| 4698 | // expressions_list: ','.star_expression+ ','? |
| 4699 | static asdl_seq* |
| 4700 | expressions_list_rule(Parser *p) |
| 4701 | { |
| 4702 | if (p->error_indicator) { |
| 4703 | return NULL; |
| 4704 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4705 | asdl_seq* _res = NULL; |
| 4706 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4707 | { // ','.star_expression+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4708 | void *_opt_var; |
| 4709 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4710 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4711 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4712 | (a = _gather_69_rule(p)) // ','.star_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4713 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4714 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4715 | ) |
| 4716 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4717 | _res = a; |
| 4718 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4719 | p->error_indicator = 1; |
| 4720 | return NULL; |
| 4721 | } |
| 4722 | goto done; |
| 4723 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4724 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4725 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4726 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4727 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4728 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4729 | } |
| 4730 | |
| 4731 | // star_expressions: |
| 4732 | // | star_expression ((',' star_expression))+ ','? |
| 4733 | // | star_expression ',' |
| 4734 | // | star_expression |
| 4735 | static expr_ty |
| 4736 | star_expressions_rule(Parser *p) |
| 4737 | { |
| 4738 | if (p->error_indicator) { |
| 4739 | return NULL; |
| 4740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4741 | expr_ty _res = NULL; |
| 4742 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4743 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4744 | p->error_indicator = 1; |
| 4745 | return NULL; |
| 4746 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4747 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4748 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4749 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4750 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4751 | { // star_expression ((',' star_expression))+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4752 | void *_opt_var; |
| 4753 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4754 | expr_ty a; |
| 4755 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4756 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4757 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4758 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4759 | (b = _loop1_71_rule(p)) // ((',' star_expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4760 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4761 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4762 | ) |
| 4763 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4764 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4765 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4766 | return NULL; |
| 4767 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4768 | int _end_lineno = _token->end_lineno; |
| 4769 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4770 | int _end_col_offset = _token->end_col_offset; |
| 4771 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4772 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 4773 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4774 | p->error_indicator = 1; |
| 4775 | return NULL; |
| 4776 | } |
| 4777 | goto done; |
| 4778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4779 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4780 | } |
| 4781 | { // star_expression ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4782 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4783 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4784 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4785 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4786 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4787 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4788 | ) |
| 4789 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4790 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4791 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4792 | return NULL; |
| 4793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4794 | int _end_lineno = _token->end_lineno; |
| 4795 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4796 | int _end_col_offset = _token->end_col_offset; |
| 4797 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4798 | _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 4799 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4800 | p->error_indicator = 1; |
| 4801 | return NULL; |
| 4802 | } |
| 4803 | goto done; |
| 4804 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4805 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4806 | } |
| 4807 | { // star_expression |
| 4808 | expr_ty star_expression_var; |
| 4809 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4810 | (star_expression_var = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4811 | ) |
| 4812 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4813 | _res = star_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4814 | goto done; |
| 4815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4816 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4817 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4818 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4819 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4820 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4821 | } |
| 4822 | |
| 4823 | // star_expression: '*' bitwise_or | expression |
| 4824 | static expr_ty |
| 4825 | star_expression_rule(Parser *p) |
| 4826 | { |
| 4827 | if (p->error_indicator) { |
| 4828 | return NULL; |
| 4829 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4830 | expr_ty _res = NULL; |
| 4831 | if (_PyPegen_is_memoized(p, star_expression_type, &_res)) |
| 4832 | return _res; |
| 4833 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4834 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4835 | p->error_indicator = 1; |
| 4836 | return NULL; |
| 4837 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4838 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4839 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4840 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4841 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4842 | { // '*' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4843 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4844 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4845 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4846 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4847 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4848 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4849 | ) |
| 4850 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4851 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4852 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4853 | return NULL; |
| 4854 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4855 | int _end_lineno = _token->end_lineno; |
| 4856 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4857 | int _end_col_offset = _token->end_col_offset; |
| 4858 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4859 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 4860 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4861 | p->error_indicator = 1; |
| 4862 | return NULL; |
| 4863 | } |
| 4864 | goto done; |
| 4865 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4866 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4867 | } |
| 4868 | { // expression |
| 4869 | expr_ty expression_var; |
| 4870 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4871 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4872 | ) |
| 4873 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4874 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4875 | goto done; |
| 4876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4877 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4879 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4880 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4881 | _PyPegen_insert_memo(p, _mark, star_expression_type, _res); |
| 4882 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4883 | } |
| 4884 | |
| 4885 | // star_named_expressions: ','.star_named_expression+ ','? |
| 4886 | static asdl_seq* |
| 4887 | star_named_expressions_rule(Parser *p) |
| 4888 | { |
| 4889 | if (p->error_indicator) { |
| 4890 | return NULL; |
| 4891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4892 | asdl_seq* _res = NULL; |
| 4893 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4894 | { // ','.star_named_expression+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4895 | void *_opt_var; |
| 4896 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4897 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4898 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4899 | (a = _gather_72_rule(p)) // ','.star_named_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4900 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4901 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4902 | ) |
| 4903 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4904 | _res = a; |
| 4905 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4906 | p->error_indicator = 1; |
| 4907 | return NULL; |
| 4908 | } |
| 4909 | goto done; |
| 4910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4911 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4913 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4914 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4915 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4916 | } |
| 4917 | |
| 4918 | // star_named_expression: '*' bitwise_or | named_expression |
| 4919 | static expr_ty |
| 4920 | star_named_expression_rule(Parser *p) |
| 4921 | { |
| 4922 | if (p->error_indicator) { |
| 4923 | return NULL; |
| 4924 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4925 | expr_ty _res = NULL; |
| 4926 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4927 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4928 | p->error_indicator = 1; |
| 4929 | return NULL; |
| 4930 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4931 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4932 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4933 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4934 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4935 | { // '*' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4936 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4937 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4938 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4939 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4940 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4941 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4942 | ) |
| 4943 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4944 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4945 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4946 | return NULL; |
| 4947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4948 | int _end_lineno = _token->end_lineno; |
| 4949 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4950 | int _end_col_offset = _token->end_col_offset; |
| 4951 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4952 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 4953 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4954 | p->error_indicator = 1; |
| 4955 | return NULL; |
| 4956 | } |
| 4957 | goto done; |
| 4958 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4959 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4960 | } |
| 4961 | { // named_expression |
| 4962 | expr_ty named_expression_var; |
| 4963 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4964 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4965 | ) |
| 4966 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4967 | _res = named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4968 | goto done; |
| 4969 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4970 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4971 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4972 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4973 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4974 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4975 | } |
| 4976 | |
| 4977 | // named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression |
| 4978 | static expr_ty |
| 4979 | named_expression_rule(Parser *p) |
| 4980 | { |
| 4981 | if (p->error_indicator) { |
| 4982 | return NULL; |
| 4983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4984 | expr_ty _res = NULL; |
| 4985 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4986 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4987 | p->error_indicator = 1; |
| 4988 | return NULL; |
| 4989 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4990 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4991 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4992 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4993 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4994 | { // NAME ':=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4995 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4996 | expr_ty a; |
| 4997 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4998 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4999 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5000 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5001 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5002 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5003 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5004 | ) |
| 5005 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5006 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5007 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5008 | return NULL; |
| 5009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5010 | int _end_lineno = _token->end_lineno; |
| 5011 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5012 | int _end_col_offset = _token->end_col_offset; |
| 5013 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5014 | _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); |
| 5015 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5016 | p->error_indicator = 1; |
| 5017 | return NULL; |
| 5018 | } |
| 5019 | goto done; |
| 5020 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5021 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5022 | } |
| 5023 | { // expression !':=' |
| 5024 | expr_ty expression_var; |
| 5025 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5026 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5027 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5028 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5029 | ) |
| 5030 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5031 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5032 | goto done; |
| 5033 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5034 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5035 | } |
| 5036 | { // invalid_named_expression |
| 5037 | void *invalid_named_expression_var; |
| 5038 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5039 | (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5040 | ) |
| 5041 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5042 | _res = invalid_named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5043 | goto done; |
| 5044 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5045 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5046 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5047 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5048 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5049 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5050 | } |
| 5051 | |
| 5052 | // annotated_rhs: yield_expr | star_expressions |
| 5053 | static expr_ty |
| 5054 | annotated_rhs_rule(Parser *p) |
| 5055 | { |
| 5056 | if (p->error_indicator) { |
| 5057 | return NULL; |
| 5058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5059 | expr_ty _res = NULL; |
| 5060 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5061 | { // yield_expr |
| 5062 | expr_ty yield_expr_var; |
| 5063 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5064 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5065 | ) |
| 5066 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5067 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5068 | goto done; |
| 5069 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5070 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5071 | } |
| 5072 | { // star_expressions |
| 5073 | expr_ty star_expressions_var; |
| 5074 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5075 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5076 | ) |
| 5077 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5078 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5079 | goto done; |
| 5080 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5081 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5083 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5084 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5085 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5086 | } |
| 5087 | |
| 5088 | // expressions: expression ((',' expression))+ ','? | expression ',' | expression |
| 5089 | static expr_ty |
| 5090 | expressions_rule(Parser *p) |
| 5091 | { |
| 5092 | if (p->error_indicator) { |
| 5093 | return NULL; |
| 5094 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5095 | expr_ty _res = NULL; |
| 5096 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5097 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5098 | p->error_indicator = 1; |
| 5099 | return NULL; |
| 5100 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5101 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5102 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5103 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5104 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5105 | { // expression ((',' expression))+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5106 | void *_opt_var; |
| 5107 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5108 | expr_ty a; |
| 5109 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5110 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5111 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5112 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5113 | (b = _loop1_74_rule(p)) // ((',' expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5114 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5115 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5116 | ) |
| 5117 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5118 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5119 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5120 | return NULL; |
| 5121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5122 | int _end_lineno = _token->end_lineno; |
| 5123 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5124 | int _end_col_offset = _token->end_col_offset; |
| 5125 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5126 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 5127 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5128 | p->error_indicator = 1; |
| 5129 | return NULL; |
| 5130 | } |
| 5131 | goto done; |
| 5132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5133 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5134 | } |
| 5135 | { // expression ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5136 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5137 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5138 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5139 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5140 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5141 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5142 | ) |
| 5143 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5144 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5145 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5146 | return NULL; |
| 5147 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5148 | int _end_lineno = _token->end_lineno; |
| 5149 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5150 | int _end_col_offset = _token->end_col_offset; |
| 5151 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5152 | _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 5153 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5154 | p->error_indicator = 1; |
| 5155 | return NULL; |
| 5156 | } |
| 5157 | goto done; |
| 5158 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5159 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5160 | } |
| 5161 | { // expression |
| 5162 | expr_ty expression_var; |
| 5163 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5164 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5165 | ) |
| 5166 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5167 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5168 | goto done; |
| 5169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5170 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5172 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5173 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5174 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5175 | } |
| 5176 | |
| 5177 | // expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef |
| 5178 | static expr_ty |
| 5179 | expression_rule(Parser *p) |
| 5180 | { |
| 5181 | if (p->error_indicator) { |
| 5182 | return NULL; |
| 5183 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5184 | expr_ty _res = NULL; |
| 5185 | if (_PyPegen_is_memoized(p, expression_type, &_res)) |
| 5186 | return _res; |
| 5187 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5188 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5189 | p->error_indicator = 1; |
| 5190 | return NULL; |
| 5191 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5192 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5193 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5194 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5195 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5196 | { // disjunction 'if' disjunction 'else' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5197 | Token * _keyword; |
| 5198 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5199 | expr_ty a; |
| 5200 | expr_ty b; |
| 5201 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5202 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5203 | (a = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5204 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5205 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5206 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5207 | (b = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5208 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5209 | (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5210 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5211 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5212 | ) |
| 5213 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5214 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5215 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5216 | return NULL; |
| 5217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5218 | int _end_lineno = _token->end_lineno; |
| 5219 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5220 | int _end_col_offset = _token->end_col_offset; |
| 5221 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5222 | _res = _Py_IfExp ( b , a , c , EXTRA ); |
| 5223 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5224 | p->error_indicator = 1; |
| 5225 | return NULL; |
| 5226 | } |
| 5227 | goto done; |
| 5228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5229 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5230 | } |
| 5231 | { // disjunction |
| 5232 | expr_ty disjunction_var; |
| 5233 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5234 | (disjunction_var = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5235 | ) |
| 5236 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5237 | _res = disjunction_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5238 | goto done; |
| 5239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5240 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5241 | } |
| 5242 | { // lambdef |
| 5243 | expr_ty lambdef_var; |
| 5244 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5245 | (lambdef_var = lambdef_rule(p)) // lambdef |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5246 | ) |
| 5247 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5248 | _res = lambdef_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5249 | goto done; |
| 5250 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5251 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5253 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5254 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5255 | _PyPegen_insert_memo(p, _mark, expression_type, _res); |
| 5256 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5257 | } |
| 5258 | |
| 5259 | // lambdef: 'lambda' lambda_parameters? ':' expression |
| 5260 | static expr_ty |
| 5261 | lambdef_rule(Parser *p) |
| 5262 | { |
| 5263 | if (p->error_indicator) { |
| 5264 | return NULL; |
| 5265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5266 | expr_ty _res = NULL; |
| 5267 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5268 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5269 | p->error_indicator = 1; |
| 5270 | return NULL; |
| 5271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5272 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5273 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5274 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5275 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5276 | { // 'lambda' lambda_parameters? ':' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5277 | Token * _keyword; |
| 5278 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5279 | void *a; |
| 5280 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5281 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5282 | (_keyword = _PyPegen_expect_token(p, 524)) // token='lambda' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5283 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5284 | (a = lambda_parameters_rule(p), 1) // lambda_parameters? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5285 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5286 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5287 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5288 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5289 | ) |
| 5290 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5291 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5292 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5293 | return NULL; |
| 5294 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5295 | int _end_lineno = _token->end_lineno; |
| 5296 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5297 | int _end_col_offset = _token->end_col_offset; |
| 5298 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5299 | _res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); |
| 5300 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5301 | p->error_indicator = 1; |
| 5302 | return NULL; |
| 5303 | } |
| 5304 | goto done; |
| 5305 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5306 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5307 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5308 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5309 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5310 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5311 | } |
| 5312 | |
| 5313 | // lambda_parameters: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5314 | // | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 5315 | // | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 5316 | // | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5317 | // | lambda_param_with_default+ lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5318 | // | lambda_star_etc |
| 5319 | static arguments_ty |
| 5320 | lambda_parameters_rule(Parser *p) |
| 5321 | { |
| 5322 | if (p->error_indicator) { |
| 5323 | return NULL; |
| 5324 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5325 | arguments_ty _res = NULL; |
| 5326 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5327 | { // 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] | 5328 | asdl_seq* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5329 | asdl_seq * b; |
| 5330 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5331 | void *d; |
| 5332 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5333 | (a = lambda_slash_no_default_rule(p)) // lambda_slash_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 | (b = _loop0_75_rule(p)) // lambda_param_no_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 | (c = _loop0_76_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5338 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5339 | (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5340 | ) |
| 5341 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5342 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 5343 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5344 | p->error_indicator = 1; |
| 5345 | return NULL; |
| 5346 | } |
| 5347 | goto done; |
| 5348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5349 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5350 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5351 | { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5352 | SlashWithDefault* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5353 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5354 | void *c; |
| 5355 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5356 | (a = lambda_slash_with_default_rule(p)) // lambda_slash_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 | (b = _loop0_77_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5359 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5360 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5361 | ) |
| 5362 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5363 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 5364 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5365 | p->error_indicator = 1; |
| 5366 | return NULL; |
| 5367 | } |
| 5368 | goto done; |
| 5369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5370 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5371 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5372 | { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5373 | asdl_seq * a; |
| 5374 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5375 | void *c; |
| 5376 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5377 | (a = _loop1_78_rule(p)) // lambda_param_no_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 | (b = _loop0_79_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5380 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5381 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5382 | ) |
| 5383 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5384 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 5385 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5386 | p->error_indicator = 1; |
| 5387 | return NULL; |
| 5388 | } |
| 5389 | goto done; |
| 5390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5391 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5392 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5393 | { // lambda_param_with_default+ lambda_star_etc? |
| 5394 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5395 | void *b; |
| 5396 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5397 | (a = _loop1_80_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5398 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5399 | (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5400 | ) |
| 5401 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5402 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 5403 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5404 | p->error_indicator = 1; |
| 5405 | return NULL; |
| 5406 | } |
| 5407 | goto done; |
| 5408 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5409 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5410 | } |
| 5411 | { // lambda_star_etc |
| 5412 | StarEtc* a; |
| 5413 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5414 | (a = lambda_star_etc_rule(p)) // lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5415 | ) |
| 5416 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5417 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 5418 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5419 | p->error_indicator = 1; |
| 5420 | return NULL; |
| 5421 | } |
| 5422 | goto done; |
| 5423 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5424 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5425 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5426 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5427 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5428 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5429 | } |
| 5430 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5431 | // lambda_slash_no_default: |
| 5432 | // | lambda_param_no_default+ '/' ',' |
| 5433 | // | lambda_param_no_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5434 | static asdl_seq* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5435 | lambda_slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5436 | { |
| 5437 | if (p->error_indicator) { |
| 5438 | return NULL; |
| 5439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5440 | asdl_seq* _res = NULL; |
| 5441 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5442 | { // lambda_param_no_default+ '/' ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5443 | Token * _literal; |
| 5444 | Token * _literal_1; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5445 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5446 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5447 | (a = _loop1_81_rule(p)) // lambda_param_no_default+ |
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 = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5450 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5451 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5452 | ) |
| 5453 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5454 | _res = a; |
| 5455 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5456 | p->error_indicator = 1; |
| 5457 | return NULL; |
| 5458 | } |
| 5459 | goto done; |
| 5460 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5461 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5462 | } |
| 5463 | { // lambda_param_no_default+ '/' &':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5464 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5465 | asdl_seq * a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5466 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5467 | (a = _loop1_82_rule(p)) // lambda_param_no_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5468 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5469 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5470 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5471 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5472 | ) |
| 5473 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5474 | _res = a; |
| 5475 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5476 | p->error_indicator = 1; |
| 5477 | return NULL; |
| 5478 | } |
| 5479 | goto done; |
| 5480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5481 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5482 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5483 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5484 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5485 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5486 | } |
| 5487 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5488 | // lambda_slash_with_default: |
| 5489 | // | lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 5490 | // | lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5491 | static SlashWithDefault* |
| 5492 | lambda_slash_with_default_rule(Parser *p) |
| 5493 | { |
| 5494 | if (p->error_indicator) { |
| 5495 | return NULL; |
| 5496 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5497 | SlashWithDefault* _res = NULL; |
| 5498 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5499 | { // lambda_param_no_default* lambda_param_with_default+ '/' ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5500 | Token * _literal; |
| 5501 | Token * _literal_1; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5502 | asdl_seq * a; |
| 5503 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5504 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5505 | (a = _loop0_83_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5506 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5507 | (b = _loop1_84_rule(p)) // lambda_param_with_default+ |
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 = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5510 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5511 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5512 | ) |
| 5513 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5514 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 5515 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5516 | p->error_indicator = 1; |
| 5517 | return NULL; |
| 5518 | } |
| 5519 | goto done; |
| 5520 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5521 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5522 | } |
| 5523 | { // lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5524 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5525 | asdl_seq * a; |
| 5526 | asdl_seq * b; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5527 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5528 | (a = _loop0_85_rule(p)) // lambda_param_no_default* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5529 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5530 | (b = _loop1_86_rule(p)) // lambda_param_with_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5531 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5532 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5533 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5534 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5535 | ) |
| 5536 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5537 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 5538 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5539 | p->error_indicator = 1; |
| 5540 | return NULL; |
| 5541 | } |
| 5542 | goto done; |
| 5543 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5544 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5545 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5546 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5547 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5548 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5549 | } |
| 5550 | |
| 5551 | // lambda_star_etc: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5552 | // | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 5553 | // | '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 5554 | // | lambda_kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5555 | // | invalid_lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5556 | static StarEtc* |
| 5557 | lambda_star_etc_rule(Parser *p) |
| 5558 | { |
| 5559 | if (p->error_indicator) { |
| 5560 | return NULL; |
| 5561 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5562 | StarEtc* _res = NULL; |
| 5563 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5564 | { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5565 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5566 | arg_ty a; |
| 5567 | asdl_seq * b; |
| 5568 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5569 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5570 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
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 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_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 | (b = _loop0_87_rule(p)) // lambda_param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5575 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5576 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5577 | ) |
| 5578 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5579 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 5580 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5581 | p->error_indicator = 1; |
| 5582 | return NULL; |
| 5583 | } |
| 5584 | goto done; |
| 5585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5586 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5587 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5588 | { // '*' ',' lambda_param_maybe_default+ lambda_kwds? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5589 | Token * _literal; |
| 5590 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5591 | asdl_seq * b; |
| 5592 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5593 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5594 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5595 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5596 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
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 | (b = _loop1_88_rule(p)) // lambda_param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5599 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5600 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5601 | ) |
| 5602 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5603 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 5604 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5605 | p->error_indicator = 1; |
| 5606 | return NULL; |
| 5607 | } |
| 5608 | goto done; |
| 5609 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5610 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5611 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5612 | { // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5613 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5614 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5615 | (a = lambda_kwds_rule(p)) // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5616 | ) |
| 5617 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5618 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 5619 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5620 | p->error_indicator = 1; |
| 5621 | return NULL; |
| 5622 | } |
| 5623 | goto done; |
| 5624 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5625 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5626 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5627 | { // invalid_lambda_star_etc |
| 5628 | void *invalid_lambda_star_etc_var; |
| 5629 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5630 | (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] | 5631 | ) |
| 5632 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5633 | _res = invalid_lambda_star_etc_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5634 | goto done; |
| 5635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5636 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5637 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5638 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5639 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5640 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5641 | } |
| 5642 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5643 | // lambda_kwds: '**' lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5644 | static arg_ty |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5645 | lambda_kwds_rule(Parser *p) |
| 5646 | { |
| 5647 | if (p->error_indicator) { |
| 5648 | return NULL; |
| 5649 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5650 | arg_ty _res = NULL; |
| 5651 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5652 | { // '**' lambda_param_no_default |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5653 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5654 | arg_ty a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5655 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5656 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5657 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5658 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5659 | ) |
| 5660 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5661 | _res = a; |
| 5662 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5663 | p->error_indicator = 1; |
| 5664 | return NULL; |
| 5665 | } |
| 5666 | goto done; |
| 5667 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5668 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5670 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5671 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5672 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5673 | } |
| 5674 | |
| 5675 | // lambda_param_no_default: lambda_param ',' | lambda_param &':' |
| 5676 | static arg_ty |
| 5677 | lambda_param_no_default_rule(Parser *p) |
| 5678 | { |
| 5679 | if (p->error_indicator) { |
| 5680 | return NULL; |
| 5681 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5682 | arg_ty _res = NULL; |
| 5683 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5684 | { // lambda_param ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5685 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5686 | arg_ty a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5687 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5688 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5689 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5690 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5691 | ) |
| 5692 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5693 | _res = a; |
| 5694 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5695 | p->error_indicator = 1; |
| 5696 | return NULL; |
| 5697 | } |
| 5698 | goto done; |
| 5699 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5700 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5701 | } |
| 5702 | { // lambda_param &':' |
| 5703 | arg_ty a; |
| 5704 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5705 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5706 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5707 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5708 | ) |
| 5709 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5710 | _res = a; |
| 5711 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5712 | p->error_indicator = 1; |
| 5713 | return NULL; |
| 5714 | } |
| 5715 | goto done; |
| 5716 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5717 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5718 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5719 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5720 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5721 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5722 | } |
| 5723 | |
| 5724 | // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' |
| 5725 | static NameDefaultPair* |
| 5726 | lambda_param_with_default_rule(Parser *p) |
| 5727 | { |
| 5728 | if (p->error_indicator) { |
| 5729 | return NULL; |
| 5730 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5731 | NameDefaultPair* _res = NULL; |
| 5732 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5733 | { // lambda_param default ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5734 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5735 | arg_ty a; |
| 5736 | expr_ty c; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5737 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5738 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5739 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5740 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5741 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5742 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5743 | ) |
| 5744 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5745 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5746 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5747 | p->error_indicator = 1; |
| 5748 | return NULL; |
| 5749 | } |
| 5750 | goto done; |
| 5751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5752 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5753 | } |
| 5754 | { // lambda_param default &':' |
| 5755 | arg_ty a; |
| 5756 | expr_ty c; |
| 5757 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5758 | (a = lambda_param_rule(p)) // lambda_param |
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 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5761 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5762 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5763 | ) |
| 5764 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5765 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5766 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5767 | p->error_indicator = 1; |
| 5768 | return NULL; |
| 5769 | } |
| 5770 | goto done; |
| 5771 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5772 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5774 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5775 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5776 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5777 | } |
| 5778 | |
| 5779 | // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' |
| 5780 | static NameDefaultPair* |
| 5781 | lambda_param_maybe_default_rule(Parser *p) |
| 5782 | { |
| 5783 | if (p->error_indicator) { |
| 5784 | return NULL; |
| 5785 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5786 | NameDefaultPair* _res = NULL; |
| 5787 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5788 | { // lambda_param default? ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5789 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5790 | arg_ty a; |
| 5791 | void *c; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5792 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5793 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5794 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5795 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5796 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5797 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5798 | ) |
| 5799 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5800 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5801 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5802 | p->error_indicator = 1; |
| 5803 | return NULL; |
| 5804 | } |
| 5805 | goto done; |
| 5806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5807 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5808 | } |
| 5809 | { // lambda_param default? &':' |
| 5810 | arg_ty a; |
| 5811 | void *c; |
| 5812 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5813 | (a = lambda_param_rule(p)) // lambda_param |
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 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5816 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5817 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5818 | ) |
| 5819 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5820 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5821 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5822 | p->error_indicator = 1; |
| 5823 | return NULL; |
| 5824 | } |
| 5825 | goto done; |
| 5826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5827 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5829 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5830 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5831 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5832 | } |
| 5833 | |
| 5834 | // lambda_param: NAME |
| 5835 | static arg_ty |
| 5836 | lambda_param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5837 | { |
| 5838 | if (p->error_indicator) { |
| 5839 | return NULL; |
| 5840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5841 | arg_ty _res = NULL; |
| 5842 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5843 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5844 | p->error_indicator = 1; |
| 5845 | return NULL; |
| 5846 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5847 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5848 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5849 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5850 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5851 | { // NAME |
| 5852 | expr_ty a; |
| 5853 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5854 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5855 | ) |
| 5856 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5857 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5858 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5859 | return NULL; |
| 5860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5861 | int _end_lineno = _token->end_lineno; |
| 5862 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5863 | int _end_col_offset = _token->end_col_offset; |
| 5864 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5865 | _res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); |
| 5866 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5867 | p->error_indicator = 1; |
| 5868 | return NULL; |
| 5869 | } |
| 5870 | goto done; |
| 5871 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5872 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5873 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5874 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5875 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5876 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5877 | } |
| 5878 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5879 | // disjunction: conjunction (('or' conjunction))+ | conjunction |
| 5880 | static expr_ty |
| 5881 | disjunction_rule(Parser *p) |
| 5882 | { |
| 5883 | if (p->error_indicator) { |
| 5884 | return NULL; |
| 5885 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5886 | expr_ty _res = NULL; |
| 5887 | if (_PyPegen_is_memoized(p, disjunction_type, &_res)) |
| 5888 | return _res; |
| 5889 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5890 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5891 | p->error_indicator = 1; |
| 5892 | return NULL; |
| 5893 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5894 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5895 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5896 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5897 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5898 | { // conjunction (('or' conjunction))+ |
| 5899 | expr_ty a; |
| 5900 | asdl_seq * b; |
| 5901 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5902 | (a = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5903 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5904 | (b = _loop1_89_rule(p)) // (('or' conjunction))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5905 | ) |
| 5906 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5907 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5908 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5909 | return NULL; |
| 5910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5911 | int _end_lineno = _token->end_lineno; |
| 5912 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5913 | int _end_col_offset = _token->end_col_offset; |
| 5914 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5915 | _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5916 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5917 | p->error_indicator = 1; |
| 5918 | return NULL; |
| 5919 | } |
| 5920 | goto done; |
| 5921 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5922 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5923 | } |
| 5924 | { // conjunction |
| 5925 | expr_ty conjunction_var; |
| 5926 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5927 | (conjunction_var = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5928 | ) |
| 5929 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5930 | _res = conjunction_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5931 | goto done; |
| 5932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5933 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5935 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5936 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5937 | _PyPegen_insert_memo(p, _mark, disjunction_type, _res); |
| 5938 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5939 | } |
| 5940 | |
| 5941 | // conjunction: inversion (('and' inversion))+ | inversion |
| 5942 | static expr_ty |
| 5943 | conjunction_rule(Parser *p) |
| 5944 | { |
| 5945 | if (p->error_indicator) { |
| 5946 | return NULL; |
| 5947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5948 | expr_ty _res = NULL; |
| 5949 | if (_PyPegen_is_memoized(p, conjunction_type, &_res)) |
| 5950 | return _res; |
| 5951 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5952 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5953 | p->error_indicator = 1; |
| 5954 | return NULL; |
| 5955 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5956 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5957 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5958 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5959 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5960 | { // inversion (('and' inversion))+ |
| 5961 | expr_ty a; |
| 5962 | asdl_seq * b; |
| 5963 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5964 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5965 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5966 | (b = _loop1_90_rule(p)) // (('and' inversion))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5967 | ) |
| 5968 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5969 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5970 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5971 | return NULL; |
| 5972 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5973 | int _end_lineno = _token->end_lineno; |
| 5974 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5975 | int _end_col_offset = _token->end_col_offset; |
| 5976 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5977 | _res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5978 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5979 | p->error_indicator = 1; |
| 5980 | return NULL; |
| 5981 | } |
| 5982 | goto done; |
| 5983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5984 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5985 | } |
| 5986 | { // inversion |
| 5987 | expr_ty inversion_var; |
| 5988 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5989 | (inversion_var = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5990 | ) |
| 5991 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5992 | _res = inversion_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5993 | goto done; |
| 5994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5995 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5997 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5998 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5999 | _PyPegen_insert_memo(p, _mark, conjunction_type, _res); |
| 6000 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6001 | } |
| 6002 | |
| 6003 | // inversion: 'not' inversion | comparison |
| 6004 | static expr_ty |
| 6005 | inversion_rule(Parser *p) |
| 6006 | { |
| 6007 | if (p->error_indicator) { |
| 6008 | return NULL; |
| 6009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6010 | expr_ty _res = NULL; |
| 6011 | if (_PyPegen_is_memoized(p, inversion_type, &_res)) |
| 6012 | return _res; |
| 6013 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6014 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6015 | p->error_indicator = 1; |
| 6016 | return NULL; |
| 6017 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6018 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6019 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6020 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6021 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6022 | { // 'not' inversion |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6023 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6024 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6025 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6026 | (_keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6027 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6028 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6029 | ) |
| 6030 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6031 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6032 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6033 | return NULL; |
| 6034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6035 | int _end_lineno = _token->end_lineno; |
| 6036 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6037 | int _end_col_offset = _token->end_col_offset; |
| 6038 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6039 | _res = _Py_UnaryOp ( Not , a , EXTRA ); |
| 6040 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6041 | p->error_indicator = 1; |
| 6042 | return NULL; |
| 6043 | } |
| 6044 | goto done; |
| 6045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6046 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6047 | } |
| 6048 | { // comparison |
| 6049 | expr_ty comparison_var; |
| 6050 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6051 | (comparison_var = comparison_rule(p)) // comparison |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6052 | ) |
| 6053 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6054 | _res = comparison_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6055 | goto done; |
| 6056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6057 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6059 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6060 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6061 | _PyPegen_insert_memo(p, _mark, inversion_type, _res); |
| 6062 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6063 | } |
| 6064 | |
| 6065 | // comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or |
| 6066 | static expr_ty |
| 6067 | comparison_rule(Parser *p) |
| 6068 | { |
| 6069 | if (p->error_indicator) { |
| 6070 | return NULL; |
| 6071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6072 | expr_ty _res = NULL; |
| 6073 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6074 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6075 | p->error_indicator = 1; |
| 6076 | return NULL; |
| 6077 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6078 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6079 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6080 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6081 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6082 | { // bitwise_or compare_op_bitwise_or_pair+ |
| 6083 | expr_ty a; |
| 6084 | asdl_seq * b; |
| 6085 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6086 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6087 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6088 | (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6089 | ) |
| 6090 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6091 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6092 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6093 | return NULL; |
| 6094 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6095 | int _end_lineno = _token->end_lineno; |
| 6096 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6097 | int _end_col_offset = _token->end_col_offset; |
| 6098 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6099 | _res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); |
| 6100 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6101 | p->error_indicator = 1; |
| 6102 | return NULL; |
| 6103 | } |
| 6104 | goto done; |
| 6105 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6106 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6107 | } |
| 6108 | { // bitwise_or |
| 6109 | expr_ty bitwise_or_var; |
| 6110 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6111 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6112 | ) |
| 6113 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6114 | _res = bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6115 | goto done; |
| 6116 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6117 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6118 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6119 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6120 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6121 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6122 | } |
| 6123 | |
| 6124 | // compare_op_bitwise_or_pair: |
| 6125 | // | eq_bitwise_or |
| 6126 | // | noteq_bitwise_or |
| 6127 | // | lte_bitwise_or |
| 6128 | // | lt_bitwise_or |
| 6129 | // | gte_bitwise_or |
| 6130 | // | gt_bitwise_or |
| 6131 | // | notin_bitwise_or |
| 6132 | // | in_bitwise_or |
| 6133 | // | isnot_bitwise_or |
| 6134 | // | is_bitwise_or |
| 6135 | static CmpopExprPair* |
| 6136 | compare_op_bitwise_or_pair_rule(Parser *p) |
| 6137 | { |
| 6138 | if (p->error_indicator) { |
| 6139 | return NULL; |
| 6140 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6141 | CmpopExprPair* _res = NULL; |
| 6142 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6143 | { // eq_bitwise_or |
| 6144 | CmpopExprPair* eq_bitwise_or_var; |
| 6145 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6146 | (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6147 | ) |
| 6148 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6149 | _res = eq_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6150 | goto done; |
| 6151 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6152 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6153 | } |
| 6154 | { // noteq_bitwise_or |
| 6155 | CmpopExprPair* noteq_bitwise_or_var; |
| 6156 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6157 | (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6158 | ) |
| 6159 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6160 | _res = noteq_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6161 | goto done; |
| 6162 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6163 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6164 | } |
| 6165 | { // lte_bitwise_or |
| 6166 | CmpopExprPair* lte_bitwise_or_var; |
| 6167 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6168 | (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6169 | ) |
| 6170 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6171 | _res = lte_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6172 | goto done; |
| 6173 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6174 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6175 | } |
| 6176 | { // lt_bitwise_or |
| 6177 | CmpopExprPair* lt_bitwise_or_var; |
| 6178 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6179 | (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6180 | ) |
| 6181 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6182 | _res = lt_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6183 | goto done; |
| 6184 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6185 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6186 | } |
| 6187 | { // gte_bitwise_or |
| 6188 | CmpopExprPair* gte_bitwise_or_var; |
| 6189 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6190 | (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6191 | ) |
| 6192 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6193 | _res = gte_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6194 | goto done; |
| 6195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6196 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6197 | } |
| 6198 | { // gt_bitwise_or |
| 6199 | CmpopExprPair* gt_bitwise_or_var; |
| 6200 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6201 | (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6202 | ) |
| 6203 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6204 | _res = gt_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6205 | goto done; |
| 6206 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6207 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6208 | } |
| 6209 | { // notin_bitwise_or |
| 6210 | CmpopExprPair* notin_bitwise_or_var; |
| 6211 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6212 | (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6213 | ) |
| 6214 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6215 | _res = notin_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6216 | goto done; |
| 6217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6218 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6219 | } |
| 6220 | { // in_bitwise_or |
| 6221 | CmpopExprPair* in_bitwise_or_var; |
| 6222 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6223 | (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6224 | ) |
| 6225 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6226 | _res = in_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6227 | goto done; |
| 6228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6229 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6230 | } |
| 6231 | { // isnot_bitwise_or |
| 6232 | CmpopExprPair* isnot_bitwise_or_var; |
| 6233 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6234 | (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6235 | ) |
| 6236 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6237 | _res = isnot_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6238 | goto done; |
| 6239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6240 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6241 | } |
| 6242 | { // is_bitwise_or |
| 6243 | CmpopExprPair* is_bitwise_or_var; |
| 6244 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6245 | (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6246 | ) |
| 6247 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6248 | _res = is_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6249 | goto done; |
| 6250 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6251 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6253 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6254 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6255 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6256 | } |
| 6257 | |
| 6258 | // eq_bitwise_or: '==' bitwise_or |
| 6259 | static CmpopExprPair* |
| 6260 | eq_bitwise_or_rule(Parser *p) |
| 6261 | { |
| 6262 | if (p->error_indicator) { |
| 6263 | return NULL; |
| 6264 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6265 | CmpopExprPair* _res = NULL; |
| 6266 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6267 | { // '==' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6268 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6269 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6270 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6271 | (_literal = _PyPegen_expect_token(p, 27)) // token='==' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6272 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6273 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6274 | ) |
| 6275 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6276 | _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); |
| 6277 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6278 | p->error_indicator = 1; |
| 6279 | return NULL; |
| 6280 | } |
| 6281 | goto done; |
| 6282 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6283 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6285 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6286 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6287 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6288 | } |
| 6289 | |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6290 | // noteq_bitwise_or: ('!=') bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6291 | static CmpopExprPair* |
| 6292 | noteq_bitwise_or_rule(Parser *p) |
| 6293 | { |
| 6294 | if (p->error_indicator) { |
| 6295 | return NULL; |
| 6296 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6297 | CmpopExprPair* _res = NULL; |
| 6298 | int _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6299 | { // ('!=') bitwise_or |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6300 | void *_tmp_92_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6301 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6302 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6303 | (_tmp_92_var = _tmp_92_rule(p)) // '!=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6304 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6305 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6306 | ) |
| 6307 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6308 | _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); |
| 6309 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6310 | p->error_indicator = 1; |
| 6311 | return NULL; |
| 6312 | } |
| 6313 | goto done; |
| 6314 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6315 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6316 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6317 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6318 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6319 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6320 | } |
| 6321 | |
| 6322 | // lte_bitwise_or: '<=' bitwise_or |
| 6323 | static CmpopExprPair* |
| 6324 | lte_bitwise_or_rule(Parser *p) |
| 6325 | { |
| 6326 | if (p->error_indicator) { |
| 6327 | return NULL; |
| 6328 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6329 | CmpopExprPair* _res = NULL; |
| 6330 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6331 | { // '<=' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6332 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6333 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6334 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6335 | (_literal = _PyPegen_expect_token(p, 29)) // token='<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6336 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6337 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6338 | ) |
| 6339 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6340 | _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); |
| 6341 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6342 | p->error_indicator = 1; |
| 6343 | return NULL; |
| 6344 | } |
| 6345 | goto done; |
| 6346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6347 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6349 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6350 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6351 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6352 | } |
| 6353 | |
| 6354 | // lt_bitwise_or: '<' bitwise_or |
| 6355 | static CmpopExprPair* |
| 6356 | lt_bitwise_or_rule(Parser *p) |
| 6357 | { |
| 6358 | if (p->error_indicator) { |
| 6359 | return NULL; |
| 6360 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6361 | CmpopExprPair* _res = NULL; |
| 6362 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6363 | { // '<' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6364 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6365 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6366 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6367 | (_literal = _PyPegen_expect_token(p, 20)) // token='<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6368 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6369 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6370 | ) |
| 6371 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6372 | _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); |
| 6373 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6374 | p->error_indicator = 1; |
| 6375 | return NULL; |
| 6376 | } |
| 6377 | goto done; |
| 6378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6379 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6380 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6381 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6382 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6383 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6384 | } |
| 6385 | |
| 6386 | // gte_bitwise_or: '>=' bitwise_or |
| 6387 | static CmpopExprPair* |
| 6388 | gte_bitwise_or_rule(Parser *p) |
| 6389 | { |
| 6390 | if (p->error_indicator) { |
| 6391 | return NULL; |
| 6392 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6393 | CmpopExprPair* _res = NULL; |
| 6394 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6395 | { // '>=' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6396 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6397 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6398 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6399 | (_literal = _PyPegen_expect_token(p, 30)) // token='>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6400 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6401 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6402 | ) |
| 6403 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6404 | _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); |
| 6405 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6406 | p->error_indicator = 1; |
| 6407 | return NULL; |
| 6408 | } |
| 6409 | goto done; |
| 6410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6411 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6412 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6413 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6414 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6415 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6416 | } |
| 6417 | |
| 6418 | // gt_bitwise_or: '>' bitwise_or |
| 6419 | static CmpopExprPair* |
| 6420 | gt_bitwise_or_rule(Parser *p) |
| 6421 | { |
| 6422 | if (p->error_indicator) { |
| 6423 | return NULL; |
| 6424 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6425 | CmpopExprPair* _res = NULL; |
| 6426 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6427 | { // '>' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6428 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6429 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6430 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6431 | (_literal = _PyPegen_expect_token(p, 21)) // token='>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6432 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6433 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6434 | ) |
| 6435 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6436 | _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); |
| 6437 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6438 | p->error_indicator = 1; |
| 6439 | return NULL; |
| 6440 | } |
| 6441 | goto done; |
| 6442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6443 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6444 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6445 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6446 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6447 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6448 | } |
| 6449 | |
| 6450 | // notin_bitwise_or: 'not' 'in' bitwise_or |
| 6451 | static CmpopExprPair* |
| 6452 | notin_bitwise_or_rule(Parser *p) |
| 6453 | { |
| 6454 | if (p->error_indicator) { |
| 6455 | return NULL; |
| 6456 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6457 | CmpopExprPair* _res = NULL; |
| 6458 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6459 | { // 'not' 'in' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6460 | Token * _keyword; |
| 6461 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6462 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6463 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6464 | (_keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6465 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6466 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6467 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6468 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6469 | ) |
| 6470 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6471 | _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); |
| 6472 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6473 | p->error_indicator = 1; |
| 6474 | return NULL; |
| 6475 | } |
| 6476 | goto done; |
| 6477 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6478 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6480 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6481 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6482 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6483 | } |
| 6484 | |
| 6485 | // in_bitwise_or: 'in' bitwise_or |
| 6486 | static CmpopExprPair* |
| 6487 | in_bitwise_or_rule(Parser *p) |
| 6488 | { |
| 6489 | if (p->error_indicator) { |
| 6490 | return NULL; |
| 6491 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6492 | CmpopExprPair* _res = NULL; |
| 6493 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6494 | { // 'in' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6495 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6496 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6497 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6498 | (_keyword = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6499 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6500 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6501 | ) |
| 6502 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6503 | _res = _PyPegen_cmpop_expr_pair ( p , In , a ); |
| 6504 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6505 | p->error_indicator = 1; |
| 6506 | return NULL; |
| 6507 | } |
| 6508 | goto done; |
| 6509 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6510 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6512 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6513 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6514 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6515 | } |
| 6516 | |
| 6517 | // isnot_bitwise_or: 'is' 'not' bitwise_or |
| 6518 | static CmpopExprPair* |
| 6519 | isnot_bitwise_or_rule(Parser *p) |
| 6520 | { |
| 6521 | if (p->error_indicator) { |
| 6522 | return NULL; |
| 6523 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6524 | CmpopExprPair* _res = NULL; |
| 6525 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6526 | { // 'is' 'not' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6527 | Token * _keyword; |
| 6528 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6529 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6530 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6531 | (_keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6532 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6533 | (_keyword_1 = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6534 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6535 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6536 | ) |
| 6537 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6538 | _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); |
| 6539 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6540 | p->error_indicator = 1; |
| 6541 | return NULL; |
| 6542 | } |
| 6543 | goto done; |
| 6544 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6545 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6546 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6547 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6548 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6549 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6550 | } |
| 6551 | |
| 6552 | // is_bitwise_or: 'is' bitwise_or |
| 6553 | static CmpopExprPair* |
| 6554 | is_bitwise_or_rule(Parser *p) |
| 6555 | { |
| 6556 | if (p->error_indicator) { |
| 6557 | return NULL; |
| 6558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6559 | CmpopExprPair* _res = NULL; |
| 6560 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6561 | { // 'is' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6562 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6563 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6564 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6565 | (_keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6566 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6567 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6568 | ) |
| 6569 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6570 | _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); |
| 6571 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6572 | p->error_indicator = 1; |
| 6573 | return NULL; |
| 6574 | } |
| 6575 | goto done; |
| 6576 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6577 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6578 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6579 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6580 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6581 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6582 | } |
| 6583 | |
| 6584 | // Left-recursive |
| 6585 | // bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor |
| 6586 | static expr_ty bitwise_or_raw(Parser *); |
| 6587 | static expr_ty |
| 6588 | bitwise_or_rule(Parser *p) |
| 6589 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6590 | expr_ty _res = NULL; |
| 6591 | if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) |
| 6592 | return _res; |
| 6593 | int _mark = p->mark; |
| 6594 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6595 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6596 | int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6597 | if (tmpvar_1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6598 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6599 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6600 | p->mark = _mark; |
| 6601 | void *_raw = bitwise_or_raw(p); |
| 6602 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6603 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6604 | _resmark = p->mark; |
| 6605 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6606 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6607 | p->mark = _resmark; |
| 6608 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6609 | } |
| 6610 | static expr_ty |
| 6611 | bitwise_or_raw(Parser *p) |
| 6612 | { |
| 6613 | if (p->error_indicator) { |
| 6614 | return NULL; |
| 6615 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6616 | expr_ty _res = NULL; |
| 6617 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6618 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6619 | p->error_indicator = 1; |
| 6620 | return NULL; |
| 6621 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6622 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6623 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6624 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6625 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6626 | { // bitwise_or '|' bitwise_xor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6627 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6628 | expr_ty a; |
| 6629 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6630 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6631 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6632 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6633 | (_literal = _PyPegen_expect_token(p, 18)) // token='|' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6634 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6635 | (b = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6636 | ) |
| 6637 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6638 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6639 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6640 | return NULL; |
| 6641 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6642 | int _end_lineno = _token->end_lineno; |
| 6643 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6644 | int _end_col_offset = _token->end_col_offset; |
| 6645 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6646 | _res = _Py_BinOp ( a , BitOr , b , EXTRA ); |
| 6647 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6648 | p->error_indicator = 1; |
| 6649 | return NULL; |
| 6650 | } |
| 6651 | goto done; |
| 6652 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6653 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6654 | } |
| 6655 | { // bitwise_xor |
| 6656 | expr_ty bitwise_xor_var; |
| 6657 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6658 | (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6659 | ) |
| 6660 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6661 | _res = bitwise_xor_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6662 | goto done; |
| 6663 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6664 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6666 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6667 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6668 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6669 | } |
| 6670 | |
| 6671 | // Left-recursive |
| 6672 | // bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and |
| 6673 | static expr_ty bitwise_xor_raw(Parser *); |
| 6674 | static expr_ty |
| 6675 | bitwise_xor_rule(Parser *p) |
| 6676 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6677 | expr_ty _res = NULL; |
| 6678 | if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) |
| 6679 | return _res; |
| 6680 | int _mark = p->mark; |
| 6681 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6682 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6683 | int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6684 | if (tmpvar_2) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6685 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6686 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6687 | p->mark = _mark; |
| 6688 | void *_raw = bitwise_xor_raw(p); |
| 6689 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6690 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6691 | _resmark = p->mark; |
| 6692 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6693 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6694 | p->mark = _resmark; |
| 6695 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6696 | } |
| 6697 | static expr_ty |
| 6698 | bitwise_xor_raw(Parser *p) |
| 6699 | { |
| 6700 | if (p->error_indicator) { |
| 6701 | return NULL; |
| 6702 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6703 | expr_ty _res = NULL; |
| 6704 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6705 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6706 | p->error_indicator = 1; |
| 6707 | return NULL; |
| 6708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6709 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6710 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6711 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6712 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6713 | { // bitwise_xor '^' bitwise_and |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6714 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6715 | expr_ty a; |
| 6716 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6717 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6718 | (a = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6719 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6720 | (_literal = _PyPegen_expect_token(p, 32)) // token='^' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6721 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6722 | (b = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6723 | ) |
| 6724 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6725 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6726 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6727 | return NULL; |
| 6728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6729 | int _end_lineno = _token->end_lineno; |
| 6730 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6731 | int _end_col_offset = _token->end_col_offset; |
| 6732 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6733 | _res = _Py_BinOp ( a , BitXor , b , EXTRA ); |
| 6734 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6735 | p->error_indicator = 1; |
| 6736 | return NULL; |
| 6737 | } |
| 6738 | goto done; |
| 6739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6740 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6741 | } |
| 6742 | { // bitwise_and |
| 6743 | expr_ty bitwise_and_var; |
| 6744 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6745 | (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6746 | ) |
| 6747 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6748 | _res = bitwise_and_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6749 | goto done; |
| 6750 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6751 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6753 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6754 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6755 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6756 | } |
| 6757 | |
| 6758 | // Left-recursive |
| 6759 | // bitwise_and: bitwise_and '&' shift_expr | shift_expr |
| 6760 | static expr_ty bitwise_and_raw(Parser *); |
| 6761 | static expr_ty |
| 6762 | bitwise_and_rule(Parser *p) |
| 6763 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6764 | expr_ty _res = NULL; |
| 6765 | if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) |
| 6766 | return _res; |
| 6767 | int _mark = p->mark; |
| 6768 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6769 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6770 | int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6771 | if (tmpvar_3) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6772 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6774 | p->mark = _mark; |
| 6775 | void *_raw = bitwise_and_raw(p); |
| 6776 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6777 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6778 | _resmark = p->mark; |
| 6779 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6780 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6781 | p->mark = _resmark; |
| 6782 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6783 | } |
| 6784 | static expr_ty |
| 6785 | bitwise_and_raw(Parser *p) |
| 6786 | { |
| 6787 | if (p->error_indicator) { |
| 6788 | return NULL; |
| 6789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6790 | expr_ty _res = NULL; |
| 6791 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6792 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6793 | p->error_indicator = 1; |
| 6794 | return NULL; |
| 6795 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6796 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6797 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6798 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6799 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6800 | { // bitwise_and '&' shift_expr |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6801 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6802 | expr_ty a; |
| 6803 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6804 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6805 | (a = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6806 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6807 | (_literal = _PyPegen_expect_token(p, 19)) // token='&' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6808 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6809 | (b = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6810 | ) |
| 6811 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6812 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6813 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6814 | return NULL; |
| 6815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6816 | int _end_lineno = _token->end_lineno; |
| 6817 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6818 | int _end_col_offset = _token->end_col_offset; |
| 6819 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6820 | _res = _Py_BinOp ( a , BitAnd , b , EXTRA ); |
| 6821 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6822 | p->error_indicator = 1; |
| 6823 | return NULL; |
| 6824 | } |
| 6825 | goto done; |
| 6826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6827 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6828 | } |
| 6829 | { // shift_expr |
| 6830 | expr_ty shift_expr_var; |
| 6831 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6832 | (shift_expr_var = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6833 | ) |
| 6834 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6835 | _res = shift_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6836 | goto done; |
| 6837 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6838 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6839 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6840 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6841 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6842 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6843 | } |
| 6844 | |
| 6845 | // Left-recursive |
| 6846 | // shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum |
| 6847 | static expr_ty shift_expr_raw(Parser *); |
| 6848 | static expr_ty |
| 6849 | shift_expr_rule(Parser *p) |
| 6850 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6851 | expr_ty _res = NULL; |
| 6852 | if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) |
| 6853 | return _res; |
| 6854 | int _mark = p->mark; |
| 6855 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6856 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6857 | int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6858 | if (tmpvar_4) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6859 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6861 | p->mark = _mark; |
| 6862 | void *_raw = shift_expr_raw(p); |
| 6863 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6864 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6865 | _resmark = p->mark; |
| 6866 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6867 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6868 | p->mark = _resmark; |
| 6869 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6870 | } |
| 6871 | static expr_ty |
| 6872 | shift_expr_raw(Parser *p) |
| 6873 | { |
| 6874 | if (p->error_indicator) { |
| 6875 | return NULL; |
| 6876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6877 | expr_ty _res = NULL; |
| 6878 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6879 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6880 | p->error_indicator = 1; |
| 6881 | return NULL; |
| 6882 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6883 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6884 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6885 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6886 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6887 | { // shift_expr '<<' sum |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6888 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6889 | expr_ty a; |
| 6890 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6891 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6892 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6893 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6894 | (_literal = _PyPegen_expect_token(p, 33)) // token='<<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6895 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6896 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6897 | ) |
| 6898 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6899 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6900 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6901 | return NULL; |
| 6902 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6903 | int _end_lineno = _token->end_lineno; |
| 6904 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6905 | int _end_col_offset = _token->end_col_offset; |
| 6906 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6907 | _res = _Py_BinOp ( a , LShift , b , EXTRA ); |
| 6908 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6909 | p->error_indicator = 1; |
| 6910 | return NULL; |
| 6911 | } |
| 6912 | goto done; |
| 6913 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6914 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6915 | } |
| 6916 | { // shift_expr '>>' sum |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6917 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6918 | expr_ty a; |
| 6919 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6920 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6921 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6922 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6923 | (_literal = _PyPegen_expect_token(p, 34)) // token='>>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6924 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6925 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6926 | ) |
| 6927 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6928 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6929 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6930 | return NULL; |
| 6931 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6932 | int _end_lineno = _token->end_lineno; |
| 6933 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6934 | int _end_col_offset = _token->end_col_offset; |
| 6935 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6936 | _res = _Py_BinOp ( a , RShift , b , EXTRA ); |
| 6937 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6938 | p->error_indicator = 1; |
| 6939 | return NULL; |
| 6940 | } |
| 6941 | goto done; |
| 6942 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6943 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6944 | } |
| 6945 | { // sum |
| 6946 | expr_ty sum_var; |
| 6947 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6948 | (sum_var = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6949 | ) |
| 6950 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6951 | _res = sum_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6952 | goto done; |
| 6953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6954 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6955 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6956 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6957 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6958 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6959 | } |
| 6960 | |
| 6961 | // Left-recursive |
| 6962 | // sum: sum '+' term | sum '-' term | term |
| 6963 | static expr_ty sum_raw(Parser *); |
| 6964 | static expr_ty |
| 6965 | sum_rule(Parser *p) |
| 6966 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6967 | expr_ty _res = NULL; |
| 6968 | if (_PyPegen_is_memoized(p, sum_type, &_res)) |
| 6969 | return _res; |
| 6970 | int _mark = p->mark; |
| 6971 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6972 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6973 | int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6974 | if (tmpvar_5) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6975 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6976 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6977 | p->mark = _mark; |
| 6978 | void *_raw = sum_raw(p); |
| 6979 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6980 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6981 | _resmark = p->mark; |
| 6982 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6984 | p->mark = _resmark; |
| 6985 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6986 | } |
| 6987 | static expr_ty |
| 6988 | sum_raw(Parser *p) |
| 6989 | { |
| 6990 | if (p->error_indicator) { |
| 6991 | return NULL; |
| 6992 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6993 | expr_ty _res = NULL; |
| 6994 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6995 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6996 | p->error_indicator = 1; |
| 6997 | return NULL; |
| 6998 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6999 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7000 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7001 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7002 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7003 | { // sum '+' term |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7004 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7005 | expr_ty a; |
| 7006 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7007 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7008 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7009 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7010 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7011 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7012 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7013 | ) |
| 7014 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7015 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7016 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7017 | return NULL; |
| 7018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7019 | int _end_lineno = _token->end_lineno; |
| 7020 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7021 | int _end_col_offset = _token->end_col_offset; |
| 7022 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7023 | _res = _Py_BinOp ( a , Add , b , EXTRA ); |
| 7024 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7025 | p->error_indicator = 1; |
| 7026 | return NULL; |
| 7027 | } |
| 7028 | goto done; |
| 7029 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7030 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7031 | } |
| 7032 | { // sum '-' term |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7033 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7034 | expr_ty a; |
| 7035 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7036 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7037 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7038 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7039 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7040 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7041 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7042 | ) |
| 7043 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7044 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7045 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7046 | return NULL; |
| 7047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7048 | int _end_lineno = _token->end_lineno; |
| 7049 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7050 | int _end_col_offset = _token->end_col_offset; |
| 7051 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7052 | _res = _Py_BinOp ( a , Sub , b , EXTRA ); |
| 7053 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7054 | p->error_indicator = 1; |
| 7055 | return NULL; |
| 7056 | } |
| 7057 | goto done; |
| 7058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7059 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7060 | } |
| 7061 | { // term |
| 7062 | expr_ty term_var; |
| 7063 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7064 | (term_var = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7065 | ) |
| 7066 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7067 | _res = term_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7068 | goto done; |
| 7069 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7070 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7072 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7073 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7074 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7075 | } |
| 7076 | |
| 7077 | // Left-recursive |
| 7078 | // term: |
| 7079 | // | term '*' factor |
| 7080 | // | term '/' factor |
| 7081 | // | term '//' factor |
| 7082 | // | term '%' factor |
| 7083 | // | term '@' factor |
| 7084 | // | factor |
| 7085 | static expr_ty term_raw(Parser *); |
| 7086 | static expr_ty |
| 7087 | term_rule(Parser *p) |
| 7088 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7089 | expr_ty _res = NULL; |
| 7090 | if (_PyPegen_is_memoized(p, term_type, &_res)) |
| 7091 | return _res; |
| 7092 | int _mark = p->mark; |
| 7093 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7094 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7095 | int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7096 | if (tmpvar_6) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7097 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7098 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7099 | p->mark = _mark; |
| 7100 | void *_raw = term_raw(p); |
| 7101 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7102 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7103 | _resmark = p->mark; |
| 7104 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7105 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7106 | p->mark = _resmark; |
| 7107 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7108 | } |
| 7109 | static expr_ty |
| 7110 | term_raw(Parser *p) |
| 7111 | { |
| 7112 | if (p->error_indicator) { |
| 7113 | return NULL; |
| 7114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7115 | expr_ty _res = NULL; |
| 7116 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7117 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7118 | p->error_indicator = 1; |
| 7119 | return NULL; |
| 7120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7121 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7122 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7123 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7124 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7125 | { // term '*' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7126 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7127 | expr_ty a; |
| 7128 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7129 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7130 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7131 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7132 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7133 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7134 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7135 | ) |
| 7136 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7137 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7138 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7139 | return NULL; |
| 7140 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7141 | int _end_lineno = _token->end_lineno; |
| 7142 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7143 | int _end_col_offset = _token->end_col_offset; |
| 7144 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7145 | _res = _Py_BinOp ( a , Mult , b , EXTRA ); |
| 7146 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7147 | p->error_indicator = 1; |
| 7148 | return NULL; |
| 7149 | } |
| 7150 | goto done; |
| 7151 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7152 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7153 | } |
| 7154 | { // term '/' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7155 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7156 | expr_ty a; |
| 7157 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7158 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7159 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7160 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7161 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7162 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7163 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7164 | ) |
| 7165 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7166 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7167 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7168 | return NULL; |
| 7169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7170 | int _end_lineno = _token->end_lineno; |
| 7171 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7172 | int _end_col_offset = _token->end_col_offset; |
| 7173 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7174 | _res = _Py_BinOp ( a , Div , b , EXTRA ); |
| 7175 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7176 | p->error_indicator = 1; |
| 7177 | return NULL; |
| 7178 | } |
| 7179 | goto done; |
| 7180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7181 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7182 | } |
| 7183 | { // term '//' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7184 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7185 | expr_ty a; |
| 7186 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7187 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7188 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7189 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7190 | (_literal = _PyPegen_expect_token(p, 47)) // token='//' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7191 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7192 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7193 | ) |
| 7194 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7195 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7196 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7197 | return NULL; |
| 7198 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7199 | int _end_lineno = _token->end_lineno; |
| 7200 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7201 | int _end_col_offset = _token->end_col_offset; |
| 7202 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7203 | _res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); |
| 7204 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7205 | p->error_indicator = 1; |
| 7206 | return NULL; |
| 7207 | } |
| 7208 | goto done; |
| 7209 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7210 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7211 | } |
| 7212 | { // term '%' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7213 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7214 | expr_ty a; |
| 7215 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7216 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7217 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7218 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7219 | (_literal = _PyPegen_expect_token(p, 24)) // token='%' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7220 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7221 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7222 | ) |
| 7223 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7224 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7225 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7226 | return NULL; |
| 7227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7228 | int _end_lineno = _token->end_lineno; |
| 7229 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7230 | int _end_col_offset = _token->end_col_offset; |
| 7231 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7232 | _res = _Py_BinOp ( a , Mod , b , EXTRA ); |
| 7233 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7234 | p->error_indicator = 1; |
| 7235 | return NULL; |
| 7236 | } |
| 7237 | goto done; |
| 7238 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7239 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7240 | } |
| 7241 | { // term '@' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7242 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7243 | expr_ty a; |
| 7244 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7245 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7246 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7247 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7248 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7249 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7250 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7251 | ) |
| 7252 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7253 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7254 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7255 | return NULL; |
| 7256 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7257 | int _end_lineno = _token->end_lineno; |
| 7258 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7259 | int _end_col_offset = _token->end_col_offset; |
| 7260 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7261 | _res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) ); |
| 7262 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7263 | p->error_indicator = 1; |
| 7264 | return NULL; |
| 7265 | } |
| 7266 | goto done; |
| 7267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7268 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7269 | } |
| 7270 | { // factor |
| 7271 | expr_ty factor_var; |
| 7272 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7273 | (factor_var = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7274 | ) |
| 7275 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7276 | _res = factor_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7277 | goto done; |
| 7278 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7279 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7280 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7281 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7282 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7283 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7284 | } |
| 7285 | |
| 7286 | // factor: '+' factor | '-' factor | '~' factor | power |
| 7287 | static expr_ty |
| 7288 | factor_rule(Parser *p) |
| 7289 | { |
| 7290 | if (p->error_indicator) { |
| 7291 | return NULL; |
| 7292 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7293 | expr_ty _res = NULL; |
| 7294 | if (_PyPegen_is_memoized(p, factor_type, &_res)) |
| 7295 | return _res; |
| 7296 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7297 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7298 | p->error_indicator = 1; |
| 7299 | return NULL; |
| 7300 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7301 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7302 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7303 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7304 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7305 | { // '+' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7306 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7307 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7308 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7309 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7310 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7311 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7312 | ) |
| 7313 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7314 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7315 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7316 | return NULL; |
| 7317 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7318 | int _end_lineno = _token->end_lineno; |
| 7319 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7320 | int _end_col_offset = _token->end_col_offset; |
| 7321 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7322 | _res = _Py_UnaryOp ( UAdd , a , EXTRA ); |
| 7323 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7324 | p->error_indicator = 1; |
| 7325 | return NULL; |
| 7326 | } |
| 7327 | goto done; |
| 7328 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7329 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7330 | } |
| 7331 | { // '-' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7332 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7333 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7334 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7335 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7336 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7337 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7338 | ) |
| 7339 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7340 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7341 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7342 | return NULL; |
| 7343 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7344 | int _end_lineno = _token->end_lineno; |
| 7345 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7346 | int _end_col_offset = _token->end_col_offset; |
| 7347 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7348 | _res = _Py_UnaryOp ( USub , a , EXTRA ); |
| 7349 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7350 | p->error_indicator = 1; |
| 7351 | return NULL; |
| 7352 | } |
| 7353 | goto done; |
| 7354 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7355 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7356 | } |
| 7357 | { // '~' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7358 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7359 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7360 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7361 | (_literal = _PyPegen_expect_token(p, 31)) // token='~' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7362 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7363 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7364 | ) |
| 7365 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7366 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7367 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7368 | return NULL; |
| 7369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7370 | int _end_lineno = _token->end_lineno; |
| 7371 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7372 | int _end_col_offset = _token->end_col_offset; |
| 7373 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7374 | _res = _Py_UnaryOp ( Invert , a , EXTRA ); |
| 7375 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7376 | p->error_indicator = 1; |
| 7377 | return NULL; |
| 7378 | } |
| 7379 | goto done; |
| 7380 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7381 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7382 | } |
| 7383 | { // power |
| 7384 | expr_ty power_var; |
| 7385 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7386 | (power_var = power_rule(p)) // power |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7387 | ) |
| 7388 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7389 | _res = power_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7390 | goto done; |
| 7391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7392 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7393 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7394 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7395 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7396 | _PyPegen_insert_memo(p, _mark, factor_type, _res); |
| 7397 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7398 | } |
| 7399 | |
| 7400 | // power: await_primary '**' factor | await_primary |
| 7401 | static expr_ty |
| 7402 | power_rule(Parser *p) |
| 7403 | { |
| 7404 | if (p->error_indicator) { |
| 7405 | return NULL; |
| 7406 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7407 | expr_ty _res = NULL; |
| 7408 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7409 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7410 | p->error_indicator = 1; |
| 7411 | return NULL; |
| 7412 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7413 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7414 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7415 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7416 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7417 | { // await_primary '**' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7418 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7419 | expr_ty a; |
| 7420 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7421 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7422 | (a = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7423 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7424 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7425 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7426 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7427 | ) |
| 7428 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7429 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7430 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7431 | return NULL; |
| 7432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7433 | int _end_lineno = _token->end_lineno; |
| 7434 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7435 | int _end_col_offset = _token->end_col_offset; |
| 7436 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7437 | _res = _Py_BinOp ( a , Pow , b , EXTRA ); |
| 7438 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7439 | p->error_indicator = 1; |
| 7440 | return NULL; |
| 7441 | } |
| 7442 | goto done; |
| 7443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7444 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7445 | } |
| 7446 | { // await_primary |
| 7447 | expr_ty await_primary_var; |
| 7448 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7449 | (await_primary_var = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7450 | ) |
| 7451 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7452 | _res = await_primary_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7453 | goto done; |
| 7454 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7455 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7456 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7457 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7458 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7459 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7460 | } |
| 7461 | |
| 7462 | // await_primary: AWAIT primary | primary |
| 7463 | static expr_ty |
| 7464 | await_primary_rule(Parser *p) |
| 7465 | { |
| 7466 | if (p->error_indicator) { |
| 7467 | return NULL; |
| 7468 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7469 | expr_ty _res = NULL; |
| 7470 | if (_PyPegen_is_memoized(p, await_primary_type, &_res)) |
| 7471 | return _res; |
| 7472 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7473 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7474 | p->error_indicator = 1; |
| 7475 | return NULL; |
| 7476 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7477 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7478 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7479 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7480 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7481 | { // AWAIT primary |
| 7482 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7483 | Token * await_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7484 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7485 | (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7486 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7487 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7488 | ) |
| 7489 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7490 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7491 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7492 | return NULL; |
| 7493 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7494 | int _end_lineno = _token->end_lineno; |
| 7495 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7496 | int _end_col_offset = _token->end_col_offset; |
| 7497 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7498 | _res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); |
| 7499 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7500 | p->error_indicator = 1; |
| 7501 | return NULL; |
| 7502 | } |
| 7503 | goto done; |
| 7504 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7505 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7506 | } |
| 7507 | { // primary |
| 7508 | expr_ty primary_var; |
| 7509 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7510 | (primary_var = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7511 | ) |
| 7512 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7513 | _res = primary_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7514 | goto done; |
| 7515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7516 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7517 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7518 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7519 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7520 | _PyPegen_insert_memo(p, _mark, await_primary_type, _res); |
| 7521 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7522 | } |
| 7523 | |
| 7524 | // Left-recursive |
| 7525 | // primary: |
| 7526 | // | primary '.' NAME |
| 7527 | // | primary genexp |
| 7528 | // | primary '(' arguments? ')' |
| 7529 | // | primary '[' slices ']' |
| 7530 | // | atom |
| 7531 | static expr_ty primary_raw(Parser *); |
| 7532 | static expr_ty |
| 7533 | primary_rule(Parser *p) |
| 7534 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7535 | expr_ty _res = NULL; |
| 7536 | if (_PyPegen_is_memoized(p, primary_type, &_res)) |
| 7537 | return _res; |
| 7538 | int _mark = p->mark; |
| 7539 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7540 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7541 | int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7542 | if (tmpvar_7) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7543 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7544 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7545 | p->mark = _mark; |
| 7546 | void *_raw = primary_raw(p); |
| 7547 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7548 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7549 | _resmark = p->mark; |
| 7550 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7551 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7552 | p->mark = _resmark; |
| 7553 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7554 | } |
| 7555 | static expr_ty |
| 7556 | primary_raw(Parser *p) |
| 7557 | { |
| 7558 | if (p->error_indicator) { |
| 7559 | return NULL; |
| 7560 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7561 | expr_ty _res = NULL; |
| 7562 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7563 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7564 | p->error_indicator = 1; |
| 7565 | return NULL; |
| 7566 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7567 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7568 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7569 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7570 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7571 | { // primary '.' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7572 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7573 | expr_ty a; |
| 7574 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7575 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7576 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7577 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7578 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7579 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7580 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7581 | ) |
| 7582 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7583 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7584 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7585 | return NULL; |
| 7586 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7587 | int _end_lineno = _token->end_lineno; |
| 7588 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7589 | int _end_col_offset = _token->end_col_offset; |
| 7590 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7591 | _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 7592 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7593 | p->error_indicator = 1; |
| 7594 | return NULL; |
| 7595 | } |
| 7596 | goto done; |
| 7597 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7598 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7599 | } |
| 7600 | { // primary genexp |
| 7601 | expr_ty a; |
| 7602 | expr_ty b; |
| 7603 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7604 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7605 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7606 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7607 | ) |
| 7608 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7609 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7610 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7611 | return NULL; |
| 7612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7613 | int _end_lineno = _token->end_lineno; |
| 7614 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7615 | int _end_col_offset = _token->end_col_offset; |
| 7616 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7617 | _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 7618 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7619 | p->error_indicator = 1; |
| 7620 | return NULL; |
| 7621 | } |
| 7622 | goto done; |
| 7623 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7624 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7625 | } |
| 7626 | { // primary '(' arguments? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7627 | Token * _literal; |
| 7628 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7629 | expr_ty a; |
| 7630 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7631 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7632 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7633 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7634 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7635 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7636 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7637 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7638 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7639 | ) |
| 7640 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7641 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7642 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7643 | return NULL; |
| 7644 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7645 | int _end_lineno = _token->end_lineno; |
| 7646 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7647 | int _end_col_offset = _token->end_col_offset; |
| 7648 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7649 | _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 7650 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7651 | p->error_indicator = 1; |
| 7652 | return NULL; |
| 7653 | } |
| 7654 | goto done; |
| 7655 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7656 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7657 | } |
| 7658 | { // primary '[' slices ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7659 | Token * _literal; |
| 7660 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7661 | expr_ty a; |
| 7662 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7663 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7664 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7665 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7666 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7667 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7668 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7669 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7670 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7671 | ) |
| 7672 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7673 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7674 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7675 | return NULL; |
| 7676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7677 | int _end_lineno = _token->end_lineno; |
| 7678 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7679 | int _end_col_offset = _token->end_col_offset; |
| 7680 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7681 | _res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 7682 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7683 | p->error_indicator = 1; |
| 7684 | return NULL; |
| 7685 | } |
| 7686 | goto done; |
| 7687 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7688 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7689 | } |
| 7690 | { // atom |
| 7691 | expr_ty atom_var; |
| 7692 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7693 | (atom_var = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7694 | ) |
| 7695 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7696 | _res = atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7697 | goto done; |
| 7698 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7699 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7701 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7702 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7703 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7704 | } |
| 7705 | |
| 7706 | // slices: slice !',' | ','.slice+ ','? |
| 7707 | static expr_ty |
| 7708 | slices_rule(Parser *p) |
| 7709 | { |
| 7710 | if (p->error_indicator) { |
| 7711 | return NULL; |
| 7712 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7713 | expr_ty _res = NULL; |
| 7714 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7715 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7716 | p->error_indicator = 1; |
| 7717 | return NULL; |
| 7718 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7719 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7720 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7721 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7722 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7723 | { // slice !',' |
| 7724 | expr_ty a; |
| 7725 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7726 | (a = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7727 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7728 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7729 | ) |
| 7730 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7731 | _res = a; |
| 7732 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7733 | p->error_indicator = 1; |
| 7734 | return NULL; |
| 7735 | } |
| 7736 | goto done; |
| 7737 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7738 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7739 | } |
| 7740 | { // ','.slice+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7741 | void *_opt_var; |
| 7742 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7743 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7744 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7745 | (a = _gather_93_rule(p)) // ','.slice+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7746 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7747 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7748 | ) |
| 7749 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7750 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7751 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7752 | return NULL; |
| 7753 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7754 | int _end_lineno = _token->end_lineno; |
| 7755 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7756 | int _end_col_offset = _token->end_col_offset; |
| 7757 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7758 | _res = _Py_Tuple ( a , Load , EXTRA ); |
| 7759 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7760 | p->error_indicator = 1; |
| 7761 | return NULL; |
| 7762 | } |
| 7763 | goto done; |
| 7764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7765 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7766 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7767 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7768 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7769 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7770 | } |
| 7771 | |
| 7772 | // slice: expression? ':' expression? [':' expression?] | expression |
| 7773 | static expr_ty |
| 7774 | slice_rule(Parser *p) |
| 7775 | { |
| 7776 | if (p->error_indicator) { |
| 7777 | return NULL; |
| 7778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7779 | expr_ty _res = NULL; |
| 7780 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7781 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7782 | p->error_indicator = 1; |
| 7783 | return NULL; |
| 7784 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7785 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7786 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7787 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7788 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7789 | { // expression? ':' expression? [':' expression?] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7790 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7791 | void *a; |
| 7792 | void *b; |
| 7793 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7794 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7795 | (a = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7796 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7797 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7800 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7801 | (c = _tmp_95_rule(p), 1) // [':' expression?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7802 | ) |
| 7803 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7804 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7805 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7806 | return NULL; |
| 7807 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7808 | int _end_lineno = _token->end_lineno; |
| 7809 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7810 | int _end_col_offset = _token->end_col_offset; |
| 7811 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7812 | _res = _Py_Slice ( a , b , c , EXTRA ); |
| 7813 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7814 | p->error_indicator = 1; |
| 7815 | return NULL; |
| 7816 | } |
| 7817 | goto done; |
| 7818 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7819 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7820 | } |
| 7821 | { // expression |
| 7822 | expr_ty a; |
| 7823 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7824 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7825 | ) |
| 7826 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7827 | _res = a; |
| 7828 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7829 | p->error_indicator = 1; |
| 7830 | return NULL; |
| 7831 | } |
| 7832 | goto done; |
| 7833 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7834 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7835 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7836 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7837 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7838 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7839 | } |
| 7840 | |
| 7841 | // atom: |
| 7842 | // | NAME |
| 7843 | // | 'True' |
| 7844 | // | 'False' |
| 7845 | // | 'None' |
| 7846 | // | '__new_parser__' |
| 7847 | // | &STRING strings |
| 7848 | // | NUMBER |
| 7849 | // | &'(' (tuple | group | genexp) |
| 7850 | // | &'[' (list | listcomp) |
| 7851 | // | &'{' (dict | set | dictcomp | setcomp) |
| 7852 | // | '...' |
| 7853 | static expr_ty |
| 7854 | atom_rule(Parser *p) |
| 7855 | { |
| 7856 | if (p->error_indicator) { |
| 7857 | return NULL; |
| 7858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7859 | expr_ty _res = NULL; |
| 7860 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7861 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7862 | p->error_indicator = 1; |
| 7863 | return NULL; |
| 7864 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7865 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7866 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7867 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7868 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7869 | { // NAME |
| 7870 | expr_ty name_var; |
| 7871 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7872 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7873 | ) |
| 7874 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7875 | _res = name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7876 | goto done; |
| 7877 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7878 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7879 | } |
| 7880 | { // 'True' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7881 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7882 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7883 | (_keyword = _PyPegen_expect_token(p, 527)) // token='True' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7884 | ) |
| 7885 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7886 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7887 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7888 | return NULL; |
| 7889 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7890 | int _end_lineno = _token->end_lineno; |
| 7891 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7892 | int _end_col_offset = _token->end_col_offset; |
| 7893 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7894 | _res = _Py_Constant ( Py_True , NULL , EXTRA ); |
| 7895 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7896 | p->error_indicator = 1; |
| 7897 | return NULL; |
| 7898 | } |
| 7899 | goto done; |
| 7900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7901 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7902 | } |
| 7903 | { // 'False' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7904 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7905 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7906 | (_keyword = _PyPegen_expect_token(p, 528)) // token='False' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7907 | ) |
| 7908 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7909 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7910 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7911 | return NULL; |
| 7912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7913 | int _end_lineno = _token->end_lineno; |
| 7914 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7915 | int _end_col_offset = _token->end_col_offset; |
| 7916 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7917 | _res = _Py_Constant ( Py_False , NULL , EXTRA ); |
| 7918 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7919 | p->error_indicator = 1; |
| 7920 | return NULL; |
| 7921 | } |
| 7922 | goto done; |
| 7923 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7924 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7925 | } |
| 7926 | { // 'None' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7927 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7928 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7929 | (_keyword = _PyPegen_expect_token(p, 529)) // token='None' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7930 | ) |
| 7931 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7932 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7933 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7934 | return NULL; |
| 7935 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7936 | int _end_lineno = _token->end_lineno; |
| 7937 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7938 | int _end_col_offset = _token->end_col_offset; |
| 7939 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7940 | _res = _Py_Constant ( Py_None , NULL , EXTRA ); |
| 7941 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7942 | p->error_indicator = 1; |
| 7943 | return NULL; |
| 7944 | } |
| 7945 | goto done; |
| 7946 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7947 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7948 | } |
| 7949 | { // '__new_parser__' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7950 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7951 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7952 | (_keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7953 | ) |
| 7954 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7955 | _res = RAISE_SYNTAX_ERROR ( "You found it!" ); |
| 7956 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7957 | p->error_indicator = 1; |
| 7958 | return NULL; |
| 7959 | } |
| 7960 | goto done; |
| 7961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7962 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7963 | } |
| 7964 | { // &STRING strings |
| 7965 | expr_ty strings_var; |
| 7966 | if ( |
| 7967 | _PyPegen_lookahead(1, _PyPegen_string_token, p) |
| 7968 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7969 | (strings_var = strings_rule(p)) // strings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7970 | ) |
| 7971 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7972 | _res = strings_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7973 | goto done; |
| 7974 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7975 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7976 | } |
| 7977 | { // NUMBER |
| 7978 | expr_ty number_var; |
| 7979 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7980 | (number_var = _PyPegen_number_token(p)) // NUMBER |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7981 | ) |
| 7982 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7983 | _res = number_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7984 | goto done; |
| 7985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7986 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7987 | } |
| 7988 | { // &'(' (tuple | group | genexp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7989 | void *_tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7990 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7991 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7992 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7993 | (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7994 | ) |
| 7995 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7996 | _res = _tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7997 | goto done; |
| 7998 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7999 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8000 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8001 | { // &'[' (list | listcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8002 | void *_tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8003 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8004 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8005 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8006 | (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8007 | ) |
| 8008 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8009 | _res = _tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8010 | goto done; |
| 8011 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8012 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8013 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8014 | { // &'{' (dict | set | dictcomp | setcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8015 | void *_tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8016 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8017 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8018 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8019 | (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8020 | ) |
| 8021 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8022 | _res = _tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8023 | goto done; |
| 8024 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8025 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8026 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8027 | { // '...' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8028 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8029 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8030 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8031 | ) |
| 8032 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8033 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8034 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8035 | return NULL; |
| 8036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8037 | int _end_lineno = _token->end_lineno; |
| 8038 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8039 | int _end_col_offset = _token->end_col_offset; |
| 8040 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8041 | _res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); |
| 8042 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8043 | p->error_indicator = 1; |
| 8044 | return NULL; |
| 8045 | } |
| 8046 | goto done; |
| 8047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8048 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8049 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8050 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8051 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8052 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8053 | } |
| 8054 | |
| 8055 | // strings: STRING+ |
| 8056 | static expr_ty |
| 8057 | strings_rule(Parser *p) |
| 8058 | { |
| 8059 | if (p->error_indicator) { |
| 8060 | return NULL; |
| 8061 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8062 | expr_ty _res = NULL; |
| 8063 | if (_PyPegen_is_memoized(p, strings_type, &_res)) |
| 8064 | return _res; |
| 8065 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8066 | { // STRING+ |
| 8067 | asdl_seq * a; |
| 8068 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8069 | (a = _loop1_99_rule(p)) // STRING+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8070 | ) |
| 8071 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8072 | _res = _PyPegen_concatenate_strings ( p , a ); |
| 8073 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8074 | p->error_indicator = 1; |
| 8075 | return NULL; |
| 8076 | } |
| 8077 | goto done; |
| 8078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8079 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8080 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8081 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8082 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8083 | _PyPegen_insert_memo(p, _mark, strings_type, _res); |
| 8084 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8085 | } |
| 8086 | |
| 8087 | // list: '[' star_named_expressions? ']' |
| 8088 | static expr_ty |
| 8089 | list_rule(Parser *p) |
| 8090 | { |
| 8091 | if (p->error_indicator) { |
| 8092 | return NULL; |
| 8093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8094 | expr_ty _res = NULL; |
| 8095 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8096 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8097 | p->error_indicator = 1; |
| 8098 | return NULL; |
| 8099 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8100 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8101 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8102 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8103 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8104 | { // '[' star_named_expressions? ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8105 | Token * _literal; |
| 8106 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8107 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8108 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8109 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8110 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8111 | (a = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8112 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8113 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8114 | ) |
| 8115 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8116 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8117 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8118 | return NULL; |
| 8119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8120 | int _end_lineno = _token->end_lineno; |
| 8121 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8122 | int _end_col_offset = _token->end_col_offset; |
| 8123 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8124 | _res = _Py_List ( a , Load , EXTRA ); |
| 8125 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8126 | p->error_indicator = 1; |
| 8127 | return NULL; |
| 8128 | } |
| 8129 | goto done; |
| 8130 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8131 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8133 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8134 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8135 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8136 | } |
| 8137 | |
| 8138 | // listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension |
| 8139 | static expr_ty |
| 8140 | listcomp_rule(Parser *p) |
| 8141 | { |
| 8142 | if (p->error_indicator) { |
| 8143 | return NULL; |
| 8144 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8145 | expr_ty _res = NULL; |
| 8146 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8147 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8148 | p->error_indicator = 1; |
| 8149 | return NULL; |
| 8150 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8151 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8152 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8153 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8154 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8155 | { // '[' named_expression for_if_clauses ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8156 | Token * _literal; |
| 8157 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8158 | expr_ty a; |
| 8159 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8160 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8161 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
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 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8164 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8165 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8166 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8167 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8168 | ) |
| 8169 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8170 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8171 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8172 | return NULL; |
| 8173 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8174 | int _end_lineno = _token->end_lineno; |
| 8175 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8176 | int _end_col_offset = _token->end_col_offset; |
| 8177 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8178 | _res = _Py_ListComp ( a , b , EXTRA ); |
| 8179 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8180 | p->error_indicator = 1; |
| 8181 | return NULL; |
| 8182 | } |
| 8183 | goto done; |
| 8184 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8185 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8186 | } |
| 8187 | { // invalid_comprehension |
| 8188 | void *invalid_comprehension_var; |
| 8189 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8190 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8191 | ) |
| 8192 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8193 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8194 | goto done; |
| 8195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8196 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8197 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8198 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8199 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8200 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8201 | } |
| 8202 | |
| 8203 | // tuple: '(' [star_named_expression ',' star_named_expressions?] ')' |
| 8204 | static expr_ty |
| 8205 | tuple_rule(Parser *p) |
| 8206 | { |
| 8207 | if (p->error_indicator) { |
| 8208 | return NULL; |
| 8209 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8210 | expr_ty _res = NULL; |
| 8211 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8212 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8213 | p->error_indicator = 1; |
| 8214 | return NULL; |
| 8215 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8216 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8217 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8218 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8219 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8220 | { // '(' [star_named_expression ',' star_named_expressions?] ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8221 | Token * _literal; |
| 8222 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8223 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8224 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8225 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8226 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8227 | (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8228 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8229 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8230 | ) |
| 8231 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8232 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8233 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8234 | return NULL; |
| 8235 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8236 | int _end_lineno = _token->end_lineno; |
| 8237 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8238 | int _end_col_offset = _token->end_col_offset; |
| 8239 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8240 | _res = _Py_Tuple ( a , Load , EXTRA ); |
| 8241 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8242 | p->error_indicator = 1; |
| 8243 | return NULL; |
| 8244 | } |
| 8245 | goto done; |
| 8246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8247 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8249 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8250 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8251 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8252 | } |
| 8253 | |
| 8254 | // group: '(' (yield_expr | named_expression) ')' |
| 8255 | static expr_ty |
| 8256 | group_rule(Parser *p) |
| 8257 | { |
| 8258 | if (p->error_indicator) { |
| 8259 | return NULL; |
| 8260 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8261 | expr_ty _res = NULL; |
| 8262 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8263 | { // '(' (yield_expr | named_expression) ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8264 | Token * _literal; |
| 8265 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8266 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8267 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8268 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8269 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8270 | (a = _tmp_101_rule(p)) // yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8271 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8272 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8273 | ) |
| 8274 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8275 | _res = a; |
| 8276 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8277 | p->error_indicator = 1; |
| 8278 | return NULL; |
| 8279 | } |
| 8280 | goto done; |
| 8281 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8282 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8283 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8284 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8285 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8286 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8287 | } |
| 8288 | |
| 8289 | // genexp: '(' expression for_if_clauses ')' | invalid_comprehension |
| 8290 | static expr_ty |
| 8291 | genexp_rule(Parser *p) |
| 8292 | { |
| 8293 | if (p->error_indicator) { |
| 8294 | return NULL; |
| 8295 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8296 | expr_ty _res = NULL; |
| 8297 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8298 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8299 | p->error_indicator = 1; |
| 8300 | return NULL; |
| 8301 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8302 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8303 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8304 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8305 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8306 | { // '(' expression for_if_clauses ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8307 | Token * _literal; |
| 8308 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8309 | expr_ty a; |
| 8310 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8311 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8312 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8315 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8316 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8317 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8318 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8319 | ) |
| 8320 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8321 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8322 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8323 | return NULL; |
| 8324 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8325 | int _end_lineno = _token->end_lineno; |
| 8326 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8327 | int _end_col_offset = _token->end_col_offset; |
| 8328 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8329 | _res = _Py_GeneratorExp ( a , b , EXTRA ); |
| 8330 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8331 | p->error_indicator = 1; |
| 8332 | return NULL; |
| 8333 | } |
| 8334 | goto done; |
| 8335 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8336 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8337 | } |
| 8338 | { // invalid_comprehension |
| 8339 | void *invalid_comprehension_var; |
| 8340 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8341 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8342 | ) |
| 8343 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8344 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8345 | goto done; |
| 8346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8347 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8349 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8350 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8351 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8352 | } |
| 8353 | |
| 8354 | // set: '{' expressions_list '}' |
| 8355 | static expr_ty |
| 8356 | set_rule(Parser *p) |
| 8357 | { |
| 8358 | if (p->error_indicator) { |
| 8359 | return NULL; |
| 8360 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8361 | expr_ty _res = NULL; |
| 8362 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8363 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8364 | p->error_indicator = 1; |
| 8365 | return NULL; |
| 8366 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8367 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8368 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8369 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8370 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8371 | { // '{' expressions_list '}' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8372 | Token * _literal; |
| 8373 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8374 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8375 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8376 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8377 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8378 | (a = expressions_list_rule(p)) // expressions_list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8379 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8380 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8381 | ) |
| 8382 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8383 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8384 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8385 | return NULL; |
| 8386 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8387 | int _end_lineno = _token->end_lineno; |
| 8388 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8389 | int _end_col_offset = _token->end_col_offset; |
| 8390 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8391 | _res = _Py_Set ( a , EXTRA ); |
| 8392 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8393 | p->error_indicator = 1; |
| 8394 | return NULL; |
| 8395 | } |
| 8396 | goto done; |
| 8397 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8398 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8400 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8401 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8402 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8403 | } |
| 8404 | |
| 8405 | // setcomp: '{' expression for_if_clauses '}' | invalid_comprehension |
| 8406 | static expr_ty |
| 8407 | setcomp_rule(Parser *p) |
| 8408 | { |
| 8409 | if (p->error_indicator) { |
| 8410 | return NULL; |
| 8411 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8412 | expr_ty _res = NULL; |
| 8413 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8414 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8415 | p->error_indicator = 1; |
| 8416 | return NULL; |
| 8417 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8418 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8419 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8420 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8421 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8422 | { // '{' expression for_if_clauses '}' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8423 | Token * _literal; |
| 8424 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8425 | expr_ty a; |
| 8426 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8427 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8428 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
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 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8431 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8432 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8433 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8434 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8435 | ) |
| 8436 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8437 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8438 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8439 | return NULL; |
| 8440 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8441 | int _end_lineno = _token->end_lineno; |
| 8442 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8443 | int _end_col_offset = _token->end_col_offset; |
| 8444 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8445 | _res = _Py_SetComp ( a , b , EXTRA ); |
| 8446 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8447 | p->error_indicator = 1; |
| 8448 | return NULL; |
| 8449 | } |
| 8450 | goto done; |
| 8451 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8452 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8453 | } |
| 8454 | { // invalid_comprehension |
| 8455 | void *invalid_comprehension_var; |
| 8456 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8457 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8458 | ) |
| 8459 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8460 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8461 | goto done; |
| 8462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8463 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8464 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8465 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8466 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8467 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8468 | } |
| 8469 | |
| 8470 | // dict: '{' kvpairs? '}' |
| 8471 | static expr_ty |
| 8472 | dict_rule(Parser *p) |
| 8473 | { |
| 8474 | if (p->error_indicator) { |
| 8475 | return NULL; |
| 8476 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8477 | expr_ty _res = NULL; |
| 8478 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8479 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8480 | p->error_indicator = 1; |
| 8481 | return NULL; |
| 8482 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8483 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8484 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8485 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8486 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8487 | { // '{' kvpairs? '}' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8488 | Token * _literal; |
| 8489 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8490 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8491 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8492 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8493 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8494 | (a = kvpairs_rule(p), 1) // kvpairs? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8495 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8496 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8497 | ) |
| 8498 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8499 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8500 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8501 | return NULL; |
| 8502 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8503 | int _end_lineno = _token->end_lineno; |
| 8504 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8505 | int _end_col_offset = _token->end_col_offset; |
| 8506 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8507 | _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); |
| 8508 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8509 | p->error_indicator = 1; |
| 8510 | return NULL; |
| 8511 | } |
| 8512 | goto done; |
| 8513 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8514 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8516 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8517 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8518 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8519 | } |
| 8520 | |
| 8521 | // dictcomp: '{' kvpair for_if_clauses '}' |
| 8522 | static expr_ty |
| 8523 | dictcomp_rule(Parser *p) |
| 8524 | { |
| 8525 | if (p->error_indicator) { |
| 8526 | return NULL; |
| 8527 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8528 | expr_ty _res = NULL; |
| 8529 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8530 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8531 | p->error_indicator = 1; |
| 8532 | return NULL; |
| 8533 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8534 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8535 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8536 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8537 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8538 | { // '{' kvpair for_if_clauses '}' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8539 | Token * _literal; |
| 8540 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8541 | KeyValuePair* a; |
| 8542 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8543 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8544 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
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 | (a = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8547 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8548 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8549 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8550 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8551 | ) |
| 8552 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8553 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8554 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8555 | return NULL; |
| 8556 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8557 | int _end_lineno = _token->end_lineno; |
| 8558 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8559 | int _end_col_offset = _token->end_col_offset; |
| 8560 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8561 | _res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); |
| 8562 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8563 | p->error_indicator = 1; |
| 8564 | return NULL; |
| 8565 | } |
| 8566 | goto done; |
| 8567 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8568 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8569 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8570 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8571 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8572 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8573 | } |
| 8574 | |
| 8575 | // kvpairs: ','.kvpair+ ','? |
| 8576 | static asdl_seq* |
| 8577 | kvpairs_rule(Parser *p) |
| 8578 | { |
| 8579 | if (p->error_indicator) { |
| 8580 | return NULL; |
| 8581 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8582 | asdl_seq* _res = NULL; |
| 8583 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8584 | { // ','.kvpair+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8585 | void *_opt_var; |
| 8586 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8587 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8588 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8589 | (a = _gather_102_rule(p)) // ','.kvpair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8590 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8591 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8592 | ) |
| 8593 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8594 | _res = a; |
| 8595 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8596 | p->error_indicator = 1; |
| 8597 | return NULL; |
| 8598 | } |
| 8599 | goto done; |
| 8600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8601 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8602 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8603 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8604 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8605 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8606 | } |
| 8607 | |
| 8608 | // kvpair: '**' bitwise_or | expression ':' expression |
| 8609 | static KeyValuePair* |
| 8610 | kvpair_rule(Parser *p) |
| 8611 | { |
| 8612 | if (p->error_indicator) { |
| 8613 | return NULL; |
| 8614 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8615 | KeyValuePair* _res = NULL; |
| 8616 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8617 | { // '**' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8618 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8619 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8620 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8621 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8622 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8623 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8624 | ) |
| 8625 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8626 | _res = _PyPegen_key_value_pair ( p , NULL , a ); |
| 8627 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8628 | p->error_indicator = 1; |
| 8629 | return NULL; |
| 8630 | } |
| 8631 | goto done; |
| 8632 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8633 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8634 | } |
| 8635 | { // expression ':' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8636 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8637 | expr_ty a; |
| 8638 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8639 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8640 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8641 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8642 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8643 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8644 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8645 | ) |
| 8646 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8647 | _res = _PyPegen_key_value_pair ( p , a , b ); |
| 8648 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8649 | p->error_indicator = 1; |
| 8650 | return NULL; |
| 8651 | } |
| 8652 | goto done; |
| 8653 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8654 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8655 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8656 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8657 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8658 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8659 | } |
| 8660 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8661 | // for_if_clauses: for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8662 | static asdl_seq* |
| 8663 | for_if_clauses_rule(Parser *p) |
| 8664 | { |
| 8665 | if (p->error_indicator) { |
| 8666 | return NULL; |
| 8667 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8668 | asdl_seq* _res = NULL; |
| 8669 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8670 | { // for_if_clause+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8671 | asdl_seq * _loop1_104_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8672 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8673 | (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8674 | ) |
| 8675 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8676 | _res = _loop1_104_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8677 | goto done; |
| 8678 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8679 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8680 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8681 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8682 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8683 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8684 | } |
| 8685 | |
| 8686 | // for_if_clause: |
| 8687 | // | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8688 | // | 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8689 | static comprehension_ty |
| 8690 | for_if_clause_rule(Parser *p) |
| 8691 | { |
| 8692 | if (p->error_indicator) { |
| 8693 | return NULL; |
| 8694 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8695 | comprehension_ty _res = NULL; |
| 8696 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8697 | { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8698 | Token * _keyword; |
| 8699 | Token * _keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8700 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8701 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8702 | expr_ty b; |
| 8703 | asdl_seq * c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8704 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8705 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8706 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8707 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8708 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8709 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8710 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8711 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
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 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8714 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8715 | (c = _loop0_105_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8716 | ) |
| 8717 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8718 | _res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); |
| 8719 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8720 | p->error_indicator = 1; |
| 8721 | return NULL; |
| 8722 | } |
| 8723 | goto done; |
| 8724 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8725 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8726 | } |
| 8727 | { // 'for' star_targets 'in' disjunction (('if' disjunction))* |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8728 | Token * _keyword; |
| 8729 | Token * _keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8730 | expr_ty a; |
| 8731 | expr_ty b; |
| 8732 | asdl_seq * c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8733 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8734 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8735 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8736 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8737 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8738 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
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 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8741 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8742 | (c = _loop0_106_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8743 | ) |
| 8744 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8745 | _res = _Py_comprehension ( a , b , c , 0 , p -> arena ); |
| 8746 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8747 | p->error_indicator = 1; |
| 8748 | return NULL; |
| 8749 | } |
| 8750 | goto done; |
| 8751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8752 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8753 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8754 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8755 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8756 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8757 | } |
| 8758 | |
| 8759 | // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? |
| 8760 | static expr_ty |
| 8761 | yield_expr_rule(Parser *p) |
| 8762 | { |
| 8763 | if (p->error_indicator) { |
| 8764 | return NULL; |
| 8765 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8766 | expr_ty _res = NULL; |
| 8767 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8768 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8769 | p->error_indicator = 1; |
| 8770 | return NULL; |
| 8771 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8772 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8773 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8774 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8775 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8776 | { // 'yield' 'from' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8777 | Token * _keyword; |
| 8778 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8779 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8780 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8781 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8782 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8783 | (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8784 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8785 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8786 | ) |
| 8787 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8788 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8789 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8790 | return NULL; |
| 8791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8792 | int _end_lineno = _token->end_lineno; |
| 8793 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8794 | int _end_col_offset = _token->end_col_offset; |
| 8795 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8796 | _res = _Py_YieldFrom ( a , EXTRA ); |
| 8797 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8798 | p->error_indicator = 1; |
| 8799 | return NULL; |
| 8800 | } |
| 8801 | goto done; |
| 8802 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8803 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8804 | } |
| 8805 | { // 'yield' star_expressions? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8806 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8807 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8808 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8809 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8810 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8811 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8812 | ) |
| 8813 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8814 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8815 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8816 | return NULL; |
| 8817 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8818 | int _end_lineno = _token->end_lineno; |
| 8819 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8820 | int _end_col_offset = _token->end_col_offset; |
| 8821 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8822 | _res = _Py_Yield ( a , EXTRA ); |
| 8823 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8824 | p->error_indicator = 1; |
| 8825 | return NULL; |
| 8826 | } |
| 8827 | goto done; |
| 8828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8829 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8830 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8831 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8832 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8833 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8834 | } |
| 8835 | |
| 8836 | // arguments: args ','? &')' | incorrect_arguments |
| 8837 | static expr_ty |
| 8838 | arguments_rule(Parser *p) |
| 8839 | { |
| 8840 | if (p->error_indicator) { |
| 8841 | return NULL; |
| 8842 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8843 | expr_ty _res = NULL; |
| 8844 | if (_PyPegen_is_memoized(p, arguments_type, &_res)) |
| 8845 | return _res; |
| 8846 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8847 | { // args ','? &')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8848 | void *_opt_var; |
| 8849 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8850 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8851 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8852 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8853 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8854 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8855 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8856 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8857 | ) |
| 8858 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8859 | _res = a; |
| 8860 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8861 | p->error_indicator = 1; |
| 8862 | return NULL; |
| 8863 | } |
| 8864 | goto done; |
| 8865 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8866 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8867 | } |
| 8868 | { // incorrect_arguments |
| 8869 | void *incorrect_arguments_var; |
| 8870 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8871 | (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8872 | ) |
| 8873 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8874 | _res = incorrect_arguments_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8875 | goto done; |
| 8876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8877 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8879 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8880 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8881 | _PyPegen_insert_memo(p, _mark, arguments_type, _res); |
| 8882 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8883 | } |
| 8884 | |
| 8885 | // args: starred_expression [',' args] | kwargs | named_expression [',' args] |
| 8886 | static expr_ty |
| 8887 | args_rule(Parser *p) |
| 8888 | { |
| 8889 | if (p->error_indicator) { |
| 8890 | return NULL; |
| 8891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8892 | expr_ty _res = NULL; |
| 8893 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8894 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8895 | p->error_indicator = 1; |
| 8896 | return NULL; |
| 8897 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8898 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8899 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8900 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8901 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8902 | { // starred_expression [',' args] |
| 8903 | expr_ty a; |
| 8904 | void *b; |
| 8905 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8906 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8907 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8908 | (b = _tmp_107_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8909 | ) |
| 8910 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8911 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8912 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8913 | return NULL; |
| 8914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8915 | int _end_lineno = _token->end_lineno; |
| 8916 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8917 | int _end_col_offset = _token->end_col_offset; |
| 8918 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8919 | _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 ); |
| 8920 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8921 | p->error_indicator = 1; |
| 8922 | return NULL; |
| 8923 | } |
| 8924 | goto done; |
| 8925 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8926 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8927 | } |
| 8928 | { // kwargs |
| 8929 | asdl_seq* a; |
| 8930 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8931 | (a = kwargs_rule(p)) // kwargs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8932 | ) |
| 8933 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8934 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8935 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8936 | return NULL; |
| 8937 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8938 | int _end_lineno = _token->end_lineno; |
| 8939 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8940 | int _end_col_offset = _token->end_col_offset; |
| 8941 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8942 | _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 ); |
| 8943 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8944 | p->error_indicator = 1; |
| 8945 | return NULL; |
| 8946 | } |
| 8947 | goto done; |
| 8948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8949 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8950 | } |
| 8951 | { // named_expression [',' args] |
| 8952 | expr_ty a; |
| 8953 | void *b; |
| 8954 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8955 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8956 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8957 | (b = _tmp_108_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8958 | ) |
| 8959 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8960 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8961 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8962 | return NULL; |
| 8963 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8964 | int _end_lineno = _token->end_lineno; |
| 8965 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8966 | int _end_col_offset = _token->end_col_offset; |
| 8967 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8968 | _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 ); |
| 8969 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8970 | p->error_indicator = 1; |
| 8971 | return NULL; |
| 8972 | } |
| 8973 | goto done; |
| 8974 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8975 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8976 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8977 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8978 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8979 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8980 | } |
| 8981 | |
| 8982 | // kwargs: |
| 8983 | // | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 8984 | // | ','.kwarg_or_starred+ |
| 8985 | // | ','.kwarg_or_double_starred+ |
| 8986 | static asdl_seq* |
| 8987 | kwargs_rule(Parser *p) |
| 8988 | { |
| 8989 | if (p->error_indicator) { |
| 8990 | return NULL; |
| 8991 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8992 | asdl_seq* _res = NULL; |
| 8993 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8994 | { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8995 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8996 | asdl_seq * a; |
| 8997 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8998 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8999 | (a = _gather_109_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9000 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9001 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9002 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9003 | (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9004 | ) |
| 9005 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9006 | _res = _PyPegen_join_sequences ( p , a , b ); |
| 9007 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9008 | p->error_indicator = 1; |
| 9009 | return NULL; |
| 9010 | } |
| 9011 | goto done; |
| 9012 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9013 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9014 | } |
| 9015 | { // ','.kwarg_or_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9016 | asdl_seq * _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9017 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9018 | (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9019 | ) |
| 9020 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9021 | _res = _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9022 | goto done; |
| 9023 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9024 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9025 | } |
| 9026 | { // ','.kwarg_or_double_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9027 | asdl_seq * _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9028 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9029 | (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9030 | ) |
| 9031 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9032 | _res = _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9033 | goto done; |
| 9034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9035 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9037 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9038 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9039 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9040 | } |
| 9041 | |
| 9042 | // starred_expression: '*' expression |
| 9043 | static expr_ty |
| 9044 | starred_expression_rule(Parser *p) |
| 9045 | { |
| 9046 | if (p->error_indicator) { |
| 9047 | return NULL; |
| 9048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9049 | expr_ty _res = NULL; |
| 9050 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9051 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9052 | p->error_indicator = 1; |
| 9053 | return NULL; |
| 9054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9055 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9056 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9057 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9058 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9059 | { // '*' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9060 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9061 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9062 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9063 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9064 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9065 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9066 | ) |
| 9067 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9068 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9069 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9070 | return NULL; |
| 9071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9072 | int _end_lineno = _token->end_lineno; |
| 9073 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9074 | int _end_col_offset = _token->end_col_offset; |
| 9075 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9076 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 9077 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9078 | p->error_indicator = 1; |
| 9079 | return NULL; |
| 9080 | } |
| 9081 | goto done; |
| 9082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9083 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9084 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9085 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9086 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9087 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9088 | } |
| 9089 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9090 | // kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9091 | static KeywordOrStarred* |
| 9092 | kwarg_or_starred_rule(Parser *p) |
| 9093 | { |
| 9094 | if (p->error_indicator) { |
| 9095 | return NULL; |
| 9096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9097 | KeywordOrStarred* _res = NULL; |
| 9098 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9099 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9100 | p->error_indicator = 1; |
| 9101 | return NULL; |
| 9102 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9103 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9104 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9105 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9106 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9107 | { // NAME '=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9108 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9109 | expr_ty a; |
| 9110 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9111 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9112 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9113 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9114 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9115 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9116 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9117 | ) |
| 9118 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9119 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9120 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9121 | return NULL; |
| 9122 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9123 | int _end_lineno = _token->end_lineno; |
| 9124 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9125 | int _end_col_offset = _token->end_col_offset; |
| 9126 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9127 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9128 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9129 | p->error_indicator = 1; |
| 9130 | return NULL; |
| 9131 | } |
| 9132 | goto done; |
| 9133 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9134 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9135 | } |
| 9136 | { // starred_expression |
| 9137 | expr_ty a; |
| 9138 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9139 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9140 | ) |
| 9141 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9142 | _res = _PyPegen_keyword_or_starred ( p , a , 0 ); |
| 9143 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9144 | p->error_indicator = 1; |
| 9145 | return NULL; |
| 9146 | } |
| 9147 | goto done; |
| 9148 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9149 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9150 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9151 | { // invalid_kwarg |
| 9152 | void *invalid_kwarg_var; |
| 9153 | if ( |
| 9154 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 9155 | ) |
| 9156 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9157 | _res = invalid_kwarg_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9158 | goto done; |
| 9159 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9160 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9161 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9162 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9163 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9164 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9165 | } |
| 9166 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9167 | // kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9168 | static KeywordOrStarred* |
| 9169 | kwarg_or_double_starred_rule(Parser *p) |
| 9170 | { |
| 9171 | if (p->error_indicator) { |
| 9172 | return NULL; |
| 9173 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9174 | KeywordOrStarred* _res = NULL; |
| 9175 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9176 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9177 | p->error_indicator = 1; |
| 9178 | return NULL; |
| 9179 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9180 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9181 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9182 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9183 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9184 | { // NAME '=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9185 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9186 | expr_ty a; |
| 9187 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9188 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9189 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9190 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9191 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9192 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9193 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9194 | ) |
| 9195 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9196 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9197 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9198 | return NULL; |
| 9199 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9200 | int _end_lineno = _token->end_lineno; |
| 9201 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9202 | int _end_col_offset = _token->end_col_offset; |
| 9203 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9204 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9205 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9206 | p->error_indicator = 1; |
| 9207 | return NULL; |
| 9208 | } |
| 9209 | goto done; |
| 9210 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9211 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9212 | } |
| 9213 | { // '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9214 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9215 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9216 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9217 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9218 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9219 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9220 | ) |
| 9221 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9222 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9223 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9224 | return NULL; |
| 9225 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9226 | int _end_lineno = _token->end_lineno; |
| 9227 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9228 | int _end_col_offset = _token->end_col_offset; |
| 9229 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9230 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); |
| 9231 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9232 | p->error_indicator = 1; |
| 9233 | return NULL; |
| 9234 | } |
| 9235 | goto done; |
| 9236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9237 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9238 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9239 | { // invalid_kwarg |
| 9240 | void *invalid_kwarg_var; |
| 9241 | if ( |
| 9242 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 9243 | ) |
| 9244 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9245 | _res = invalid_kwarg_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9246 | goto done; |
| 9247 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9248 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9249 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9250 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9251 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9252 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9253 | } |
| 9254 | |
| 9255 | // star_targets: star_target !',' | star_target ((',' star_target))* ','? |
| 9256 | static expr_ty |
| 9257 | star_targets_rule(Parser *p) |
| 9258 | { |
| 9259 | if (p->error_indicator) { |
| 9260 | return NULL; |
| 9261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9262 | expr_ty _res = NULL; |
| 9263 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9264 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9265 | p->error_indicator = 1; |
| 9266 | return NULL; |
| 9267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9268 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9269 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9270 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9271 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9272 | { // star_target !',' |
| 9273 | expr_ty a; |
| 9274 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9275 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9276 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9277 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9278 | ) |
| 9279 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9280 | _res = a; |
| 9281 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9282 | p->error_indicator = 1; |
| 9283 | return NULL; |
| 9284 | } |
| 9285 | goto done; |
| 9286 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9287 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9288 | } |
| 9289 | { // star_target ((',' star_target))* ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9290 | void *_opt_var; |
| 9291 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9292 | expr_ty a; |
| 9293 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9294 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9295 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9296 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9297 | (b = _loop0_117_rule(p)) // ((',' star_target))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9298 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9299 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9300 | ) |
| 9301 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9302 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9303 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9304 | return NULL; |
| 9305 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9306 | int _end_lineno = _token->end_lineno; |
| 9307 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9308 | int _end_col_offset = _token->end_col_offset; |
| 9309 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9310 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); |
| 9311 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9312 | p->error_indicator = 1; |
| 9313 | return NULL; |
| 9314 | } |
| 9315 | goto done; |
| 9316 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9317 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9318 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9319 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9320 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9321 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9322 | } |
| 9323 | |
| 9324 | // star_targets_seq: ','.star_target+ ','? |
| 9325 | static asdl_seq* |
| 9326 | star_targets_seq_rule(Parser *p) |
| 9327 | { |
| 9328 | if (p->error_indicator) { |
| 9329 | return NULL; |
| 9330 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9331 | asdl_seq* _res = NULL; |
| 9332 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9333 | { // ','.star_target+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9334 | void *_opt_var; |
| 9335 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9336 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9337 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9338 | (a = _gather_118_rule(p)) // ','.star_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9339 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9340 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9341 | ) |
| 9342 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9343 | _res = a; |
| 9344 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9345 | p->error_indicator = 1; |
| 9346 | return NULL; |
| 9347 | } |
| 9348 | goto done; |
| 9349 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9350 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9351 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9352 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9353 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9354 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9355 | } |
| 9356 | |
| 9357 | // star_target: |
| 9358 | // | '*' (!'*' star_target) |
| 9359 | // | t_primary '.' NAME !t_lookahead |
| 9360 | // | t_primary '[' slices ']' !t_lookahead |
| 9361 | // | star_atom |
| 9362 | static expr_ty |
| 9363 | star_target_rule(Parser *p) |
| 9364 | { |
| 9365 | if (p->error_indicator) { |
| 9366 | return NULL; |
| 9367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9368 | expr_ty _res = NULL; |
| 9369 | if (_PyPegen_is_memoized(p, star_target_type, &_res)) |
| 9370 | return _res; |
| 9371 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9372 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9373 | p->error_indicator = 1; |
| 9374 | return NULL; |
| 9375 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9376 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9377 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9378 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9379 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9380 | { // '*' (!'*' star_target) |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9381 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9382 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9383 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9384 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9385 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9386 | (a = _tmp_120_rule(p)) // !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9387 | ) |
| 9388 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9389 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9390 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9391 | return NULL; |
| 9392 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9393 | int _end_lineno = _token->end_lineno; |
| 9394 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9395 | int _end_col_offset = _token->end_col_offset; |
| 9396 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9397 | _res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); |
| 9398 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9399 | p->error_indicator = 1; |
| 9400 | return NULL; |
| 9401 | } |
| 9402 | goto done; |
| 9403 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9404 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9405 | } |
| 9406 | { // t_primary '.' NAME !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9407 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9408 | expr_ty a; |
| 9409 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9410 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9411 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9412 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9413 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9414 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9415 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9416 | && |
| 9417 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9418 | ) |
| 9419 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9420 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9421 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9422 | return NULL; |
| 9423 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9424 | int _end_lineno = _token->end_lineno; |
| 9425 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9426 | int _end_col_offset = _token->end_col_offset; |
| 9427 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9428 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9429 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9430 | p->error_indicator = 1; |
| 9431 | return NULL; |
| 9432 | } |
| 9433 | goto done; |
| 9434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9435 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9436 | } |
| 9437 | { // t_primary '[' slices ']' !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9438 | Token * _literal; |
| 9439 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9440 | expr_ty a; |
| 9441 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9442 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9443 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9444 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9445 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9446 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9447 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9448 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9449 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9450 | && |
| 9451 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9452 | ) |
| 9453 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9454 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9455 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9456 | return NULL; |
| 9457 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9458 | int _end_lineno = _token->end_lineno; |
| 9459 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9460 | int _end_col_offset = _token->end_col_offset; |
| 9461 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9462 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9463 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9464 | p->error_indicator = 1; |
| 9465 | return NULL; |
| 9466 | } |
| 9467 | goto done; |
| 9468 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9469 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9470 | } |
| 9471 | { // star_atom |
| 9472 | expr_ty star_atom_var; |
| 9473 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9474 | (star_atom_var = star_atom_rule(p)) // star_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9475 | ) |
| 9476 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9477 | _res = star_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9478 | goto done; |
| 9479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9480 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9481 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9482 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9483 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9484 | _PyPegen_insert_memo(p, _mark, star_target_type, _res); |
| 9485 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9486 | } |
| 9487 | |
| 9488 | // star_atom: |
| 9489 | // | NAME |
| 9490 | // | '(' star_target ')' |
| 9491 | // | '(' star_targets_seq? ')' |
| 9492 | // | '[' star_targets_seq? ']' |
| 9493 | static expr_ty |
| 9494 | star_atom_rule(Parser *p) |
| 9495 | { |
| 9496 | if (p->error_indicator) { |
| 9497 | return NULL; |
| 9498 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9499 | expr_ty _res = NULL; |
| 9500 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9501 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9502 | p->error_indicator = 1; |
| 9503 | return NULL; |
| 9504 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9505 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9506 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9507 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9508 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9509 | { // NAME |
| 9510 | expr_ty a; |
| 9511 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9512 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9513 | ) |
| 9514 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9515 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9516 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9517 | p->error_indicator = 1; |
| 9518 | return NULL; |
| 9519 | } |
| 9520 | goto done; |
| 9521 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9522 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9523 | } |
| 9524 | { // '(' star_target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9525 | Token * _literal; |
| 9526 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9527 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9528 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9529 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9530 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9531 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9532 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9533 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9534 | ) |
| 9535 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9536 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9537 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9538 | p->error_indicator = 1; |
| 9539 | return NULL; |
| 9540 | } |
| 9541 | goto done; |
| 9542 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9543 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9544 | } |
| 9545 | { // '(' star_targets_seq? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9546 | Token * _literal; |
| 9547 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9548 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9549 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9550 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9551 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9552 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9553 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9554 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9555 | ) |
| 9556 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9557 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9558 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9559 | return NULL; |
| 9560 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9561 | int _end_lineno = _token->end_lineno; |
| 9562 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9563 | int _end_col_offset = _token->end_col_offset; |
| 9564 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9565 | _res = _Py_Tuple ( a , Store , EXTRA ); |
| 9566 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9567 | p->error_indicator = 1; |
| 9568 | return NULL; |
| 9569 | } |
| 9570 | goto done; |
| 9571 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9572 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9573 | } |
| 9574 | { // '[' star_targets_seq? ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9575 | Token * _literal; |
| 9576 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9577 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9578 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9579 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9580 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9581 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9582 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9583 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9584 | ) |
| 9585 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9586 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9587 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9588 | return NULL; |
| 9589 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9590 | int _end_lineno = _token->end_lineno; |
| 9591 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9592 | int _end_col_offset = _token->end_col_offset; |
| 9593 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9594 | _res = _Py_List ( a , Store , EXTRA ); |
| 9595 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9596 | p->error_indicator = 1; |
| 9597 | return NULL; |
| 9598 | } |
| 9599 | goto done; |
| 9600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9601 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9602 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9603 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9604 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9605 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9606 | } |
| 9607 | |
| 9608 | // inside_paren_ann_assign_target: |
| 9609 | // | ann_assign_subscript_attribute_target |
| 9610 | // | NAME |
| 9611 | // | '(' inside_paren_ann_assign_target ')' |
| 9612 | static expr_ty |
| 9613 | inside_paren_ann_assign_target_rule(Parser *p) |
| 9614 | { |
| 9615 | if (p->error_indicator) { |
| 9616 | return NULL; |
| 9617 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9618 | expr_ty _res = NULL; |
| 9619 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9620 | { // ann_assign_subscript_attribute_target |
| 9621 | expr_ty ann_assign_subscript_attribute_target_var; |
| 9622 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9623 | (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] | 9624 | ) |
| 9625 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9626 | _res = ann_assign_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9627 | goto done; |
| 9628 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9629 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9630 | } |
| 9631 | { // NAME |
| 9632 | expr_ty a; |
| 9633 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9634 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9635 | ) |
| 9636 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9637 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9638 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9639 | p->error_indicator = 1; |
| 9640 | return NULL; |
| 9641 | } |
| 9642 | goto done; |
| 9643 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9644 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9645 | } |
| 9646 | { // '(' inside_paren_ann_assign_target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9647 | Token * _literal; |
| 9648 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9649 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9650 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9651 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9652 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9653 | (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] | 9654 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9655 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9656 | ) |
| 9657 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9658 | _res = a; |
| 9659 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9660 | p->error_indicator = 1; |
| 9661 | return NULL; |
| 9662 | } |
| 9663 | goto done; |
| 9664 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9665 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9666 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9667 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9668 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9669 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9670 | } |
| 9671 | |
| 9672 | // ann_assign_subscript_attribute_target: |
| 9673 | // | t_primary '.' NAME !t_lookahead |
| 9674 | // | t_primary '[' slices ']' !t_lookahead |
| 9675 | static expr_ty |
| 9676 | ann_assign_subscript_attribute_target_rule(Parser *p) |
| 9677 | { |
| 9678 | if (p->error_indicator) { |
| 9679 | return NULL; |
| 9680 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9681 | expr_ty _res = NULL; |
| 9682 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9683 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9684 | p->error_indicator = 1; |
| 9685 | return NULL; |
| 9686 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9687 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9688 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9689 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9690 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9691 | { // t_primary '.' NAME !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9692 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9693 | expr_ty a; |
| 9694 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9695 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9696 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9697 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9698 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9699 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9700 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9701 | && |
| 9702 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9703 | ) |
| 9704 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9705 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9706 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9707 | return NULL; |
| 9708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9709 | int _end_lineno = _token->end_lineno; |
| 9710 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9711 | int _end_col_offset = _token->end_col_offset; |
| 9712 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9713 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9714 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9715 | p->error_indicator = 1; |
| 9716 | return NULL; |
| 9717 | } |
| 9718 | goto done; |
| 9719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9720 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9721 | } |
| 9722 | { // t_primary '[' slices ']' !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9723 | Token * _literal; |
| 9724 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9725 | expr_ty a; |
| 9726 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9727 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9728 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9729 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9730 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9731 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9732 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9733 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9734 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9735 | && |
| 9736 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9737 | ) |
| 9738 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9739 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9740 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9741 | return NULL; |
| 9742 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9743 | int _end_lineno = _token->end_lineno; |
| 9744 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9745 | int _end_col_offset = _token->end_col_offset; |
| 9746 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9747 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9748 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9749 | p->error_indicator = 1; |
| 9750 | return NULL; |
| 9751 | } |
| 9752 | goto done; |
| 9753 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9754 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9755 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9756 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9757 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9758 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9759 | } |
| 9760 | |
| 9761 | // del_targets: ','.del_target+ ','? |
| 9762 | static asdl_seq* |
| 9763 | del_targets_rule(Parser *p) |
| 9764 | { |
| 9765 | if (p->error_indicator) { |
| 9766 | return NULL; |
| 9767 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9768 | asdl_seq* _res = NULL; |
| 9769 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9770 | { // ','.del_target+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9771 | void *_opt_var; |
| 9772 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9773 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9774 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9775 | (a = _gather_121_rule(p)) // ','.del_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9776 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9777 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9778 | ) |
| 9779 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9780 | _res = a; |
| 9781 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9782 | p->error_indicator = 1; |
| 9783 | return NULL; |
| 9784 | } |
| 9785 | goto done; |
| 9786 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9787 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9788 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9789 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9790 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9791 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9792 | } |
| 9793 | |
| 9794 | // del_target: |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9795 | // | t_primary '.' NAME &del_target_end |
| 9796 | // | t_primary '[' slices ']' &del_target_end |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9797 | // | del_t_atom |
| 9798 | static expr_ty |
| 9799 | del_target_rule(Parser *p) |
| 9800 | { |
| 9801 | if (p->error_indicator) { |
| 9802 | return NULL; |
| 9803 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9804 | expr_ty _res = NULL; |
| 9805 | if (_PyPegen_is_memoized(p, del_target_type, &_res)) |
| 9806 | return _res; |
| 9807 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9808 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9809 | p->error_indicator = 1; |
| 9810 | return NULL; |
| 9811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9812 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9813 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9814 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9815 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9816 | { // t_primary '.' NAME &del_target_end |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9817 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9818 | expr_ty a; |
| 9819 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9820 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9821 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9822 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9823 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9824 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9825 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9826 | && |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9827 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9828 | ) |
| 9829 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9830 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9831 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9832 | return NULL; |
| 9833 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9834 | int _end_lineno = _token->end_lineno; |
| 9835 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9836 | int _end_col_offset = _token->end_col_offset; |
| 9837 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9838 | _res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); |
| 9839 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9840 | p->error_indicator = 1; |
| 9841 | return NULL; |
| 9842 | } |
| 9843 | goto done; |
| 9844 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9845 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9846 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9847 | { // t_primary '[' slices ']' &del_target_end |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9848 | Token * _literal; |
| 9849 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9850 | expr_ty a; |
| 9851 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9852 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9853 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9854 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9855 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9856 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9857 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9858 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9859 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9860 | && |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9861 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9862 | ) |
| 9863 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9864 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9865 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9866 | return NULL; |
| 9867 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9868 | int _end_lineno = _token->end_lineno; |
| 9869 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9870 | int _end_col_offset = _token->end_col_offset; |
| 9871 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9872 | _res = _Py_Subscript ( a , b , Del , EXTRA ); |
| 9873 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9874 | p->error_indicator = 1; |
| 9875 | return NULL; |
| 9876 | } |
| 9877 | goto done; |
| 9878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9879 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9880 | } |
| 9881 | { // del_t_atom |
| 9882 | expr_ty del_t_atom_var; |
| 9883 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9884 | (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9885 | ) |
| 9886 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9887 | _res = del_t_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9888 | goto done; |
| 9889 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9890 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9892 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9893 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9894 | _PyPegen_insert_memo(p, _mark, del_target_type, _res); |
| 9895 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9896 | } |
| 9897 | |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9898 | // del_t_atom: |
| 9899 | // | NAME &del_target_end |
| 9900 | // | '(' del_target ')' |
| 9901 | // | '(' del_targets? ')' |
| 9902 | // | '[' del_targets? ']' |
| 9903 | // | invalid_del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9904 | static expr_ty |
| 9905 | del_t_atom_rule(Parser *p) |
| 9906 | { |
| 9907 | if (p->error_indicator) { |
| 9908 | return NULL; |
| 9909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9910 | expr_ty _res = NULL; |
| 9911 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9912 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9913 | p->error_indicator = 1; |
| 9914 | return NULL; |
| 9915 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9916 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9917 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9918 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9919 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9920 | { // NAME &del_target_end |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9921 | expr_ty a; |
| 9922 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9923 | (a = _PyPegen_name_token(p)) // NAME |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9924 | && |
| 9925 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9926 | ) |
| 9927 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9928 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9929 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9930 | p->error_indicator = 1; |
| 9931 | return NULL; |
| 9932 | } |
| 9933 | goto done; |
| 9934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9935 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9936 | } |
| 9937 | { // '(' del_target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9938 | Token * _literal; |
| 9939 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9940 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9941 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9942 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9943 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9944 | (a = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9945 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9946 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9947 | ) |
| 9948 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9949 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9950 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9951 | p->error_indicator = 1; |
| 9952 | return NULL; |
| 9953 | } |
| 9954 | goto done; |
| 9955 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9956 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9957 | } |
| 9958 | { // '(' del_targets? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9959 | Token * _literal; |
| 9960 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9961 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9962 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9963 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9964 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9965 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9966 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9967 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9968 | ) |
| 9969 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9970 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9971 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9972 | return NULL; |
| 9973 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9974 | int _end_lineno = _token->end_lineno; |
| 9975 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9976 | int _end_col_offset = _token->end_col_offset; |
| 9977 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9978 | _res = _Py_Tuple ( a , Del , EXTRA ); |
| 9979 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9980 | p->error_indicator = 1; |
| 9981 | return NULL; |
| 9982 | } |
| 9983 | goto done; |
| 9984 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9985 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9986 | } |
| 9987 | { // '[' del_targets? ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9988 | Token * _literal; |
| 9989 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9990 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9991 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9992 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9993 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9994 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9995 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9996 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9997 | ) |
| 9998 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9999 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10000 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10001 | return NULL; |
| 10002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10003 | int _end_lineno = _token->end_lineno; |
| 10004 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10005 | int _end_col_offset = _token->end_col_offset; |
| 10006 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10007 | _res = _Py_List ( a , Del , EXTRA ); |
| 10008 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10009 | p->error_indicator = 1; |
| 10010 | return NULL; |
| 10011 | } |
| 10012 | goto done; |
| 10013 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10014 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10015 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10016 | { // invalid_del_target |
| 10017 | void *invalid_del_target_var; |
| 10018 | if ( |
| 10019 | (invalid_del_target_var = invalid_del_target_rule(p)) // invalid_del_target |
| 10020 | ) |
| 10021 | { |
| 10022 | _res = invalid_del_target_var; |
| 10023 | goto done; |
| 10024 | } |
| 10025 | p->mark = _mark; |
| 10026 | } |
| 10027 | _res = NULL; |
| 10028 | done: |
| 10029 | return _res; |
| 10030 | } |
| 10031 | |
| 10032 | // del_target_end: ')' | ']' | ',' | ';' | NEWLINE |
| 10033 | static void * |
| 10034 | del_target_end_rule(Parser *p) |
| 10035 | { |
| 10036 | if (p->error_indicator) { |
| 10037 | return NULL; |
| 10038 | } |
| 10039 | void * _res = NULL; |
| 10040 | int _mark = p->mark; |
| 10041 | { // ')' |
| 10042 | Token * _literal; |
| 10043 | if ( |
| 10044 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
| 10045 | ) |
| 10046 | { |
| 10047 | _res = _literal; |
| 10048 | goto done; |
| 10049 | } |
| 10050 | p->mark = _mark; |
| 10051 | } |
| 10052 | { // ']' |
| 10053 | Token * _literal; |
| 10054 | if ( |
| 10055 | (_literal = _PyPegen_expect_token(p, 10)) // token=']' |
| 10056 | ) |
| 10057 | { |
| 10058 | _res = _literal; |
| 10059 | goto done; |
| 10060 | } |
| 10061 | p->mark = _mark; |
| 10062 | } |
| 10063 | { // ',' |
| 10064 | Token * _literal; |
| 10065 | if ( |
| 10066 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 10067 | ) |
| 10068 | { |
| 10069 | _res = _literal; |
| 10070 | goto done; |
| 10071 | } |
| 10072 | p->mark = _mark; |
| 10073 | } |
| 10074 | { // ';' |
| 10075 | Token * _literal; |
| 10076 | if ( |
| 10077 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
| 10078 | ) |
| 10079 | { |
| 10080 | _res = _literal; |
| 10081 | goto done; |
| 10082 | } |
| 10083 | p->mark = _mark; |
| 10084 | } |
| 10085 | { // NEWLINE |
| 10086 | Token * newline_var; |
| 10087 | if ( |
| 10088 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 10089 | ) |
| 10090 | { |
| 10091 | _res = newline_var; |
| 10092 | goto done; |
| 10093 | } |
| 10094 | p->mark = _mark; |
| 10095 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10096 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10097 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10098 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10099 | } |
| 10100 | |
| 10101 | // targets: ','.target+ ','? |
| 10102 | static asdl_seq* |
| 10103 | targets_rule(Parser *p) |
| 10104 | { |
| 10105 | if (p->error_indicator) { |
| 10106 | return NULL; |
| 10107 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10108 | asdl_seq* _res = NULL; |
| 10109 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10110 | { // ','.target+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10111 | void *_opt_var; |
| 10112 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10113 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10114 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10115 | (a = _gather_123_rule(p)) // ','.target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10116 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10117 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10118 | ) |
| 10119 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10120 | _res = a; |
| 10121 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10122 | p->error_indicator = 1; |
| 10123 | return NULL; |
| 10124 | } |
| 10125 | goto done; |
| 10126 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10127 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10128 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10129 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10130 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10131 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10132 | } |
| 10133 | |
| 10134 | // target: |
| 10135 | // | t_primary '.' NAME !t_lookahead |
| 10136 | // | t_primary '[' slices ']' !t_lookahead |
| 10137 | // | t_atom |
| 10138 | static expr_ty |
| 10139 | target_rule(Parser *p) |
| 10140 | { |
| 10141 | if (p->error_indicator) { |
| 10142 | return NULL; |
| 10143 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10144 | expr_ty _res = NULL; |
| 10145 | if (_PyPegen_is_memoized(p, target_type, &_res)) |
| 10146 | return _res; |
| 10147 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10148 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10149 | p->error_indicator = 1; |
| 10150 | return NULL; |
| 10151 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10152 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10153 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10154 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10155 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10156 | { // t_primary '.' NAME !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10157 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10158 | expr_ty a; |
| 10159 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10160 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10161 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10162 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10163 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10164 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10165 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10166 | && |
| 10167 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10168 | ) |
| 10169 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10170 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10171 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10172 | return NULL; |
| 10173 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10174 | int _end_lineno = _token->end_lineno; |
| 10175 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10176 | int _end_col_offset = _token->end_col_offset; |
| 10177 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10178 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 10179 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10180 | p->error_indicator = 1; |
| 10181 | return NULL; |
| 10182 | } |
| 10183 | goto done; |
| 10184 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10185 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10186 | } |
| 10187 | { // t_primary '[' slices ']' !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10188 | Token * _literal; |
| 10189 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10190 | expr_ty a; |
| 10191 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10192 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10193 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10194 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10195 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10196 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10197 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10198 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10199 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10200 | && |
| 10201 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10202 | ) |
| 10203 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10204 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10205 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10206 | return NULL; |
| 10207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10208 | int _end_lineno = _token->end_lineno; |
| 10209 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10210 | int _end_col_offset = _token->end_col_offset; |
| 10211 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10212 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 10213 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10214 | p->error_indicator = 1; |
| 10215 | return NULL; |
| 10216 | } |
| 10217 | goto done; |
| 10218 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10219 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10220 | } |
| 10221 | { // t_atom |
| 10222 | expr_ty t_atom_var; |
| 10223 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10224 | (t_atom_var = t_atom_rule(p)) // t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10225 | ) |
| 10226 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10227 | _res = t_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10228 | goto done; |
| 10229 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10230 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10231 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10232 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10233 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10234 | _PyPegen_insert_memo(p, _mark, target_type, _res); |
| 10235 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10236 | } |
| 10237 | |
| 10238 | // Left-recursive |
| 10239 | // t_primary: |
| 10240 | // | t_primary '.' NAME &t_lookahead |
| 10241 | // | t_primary '[' slices ']' &t_lookahead |
| 10242 | // | t_primary genexp &t_lookahead |
| 10243 | // | t_primary '(' arguments? ')' &t_lookahead |
| 10244 | // | atom &t_lookahead |
| 10245 | static expr_ty t_primary_raw(Parser *); |
| 10246 | static expr_ty |
| 10247 | t_primary_rule(Parser *p) |
| 10248 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10249 | expr_ty _res = NULL; |
| 10250 | if (_PyPegen_is_memoized(p, t_primary_type, &_res)) |
| 10251 | return _res; |
| 10252 | int _mark = p->mark; |
| 10253 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10254 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10255 | int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10256 | if (tmpvar_8) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10257 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10258 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10259 | p->mark = _mark; |
| 10260 | void *_raw = t_primary_raw(p); |
| 10261 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10262 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10263 | _resmark = p->mark; |
| 10264 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10266 | p->mark = _resmark; |
| 10267 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10268 | } |
| 10269 | static expr_ty |
| 10270 | t_primary_raw(Parser *p) |
| 10271 | { |
| 10272 | if (p->error_indicator) { |
| 10273 | return NULL; |
| 10274 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10275 | expr_ty _res = NULL; |
| 10276 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10277 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10278 | p->error_indicator = 1; |
| 10279 | return NULL; |
| 10280 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10281 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10282 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10283 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10284 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10285 | { // t_primary '.' NAME &t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10286 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10287 | expr_ty a; |
| 10288 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10289 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10290 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10291 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10292 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10293 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10294 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10295 | && |
| 10296 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10297 | ) |
| 10298 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10299 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10300 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10301 | return NULL; |
| 10302 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10303 | int _end_lineno = _token->end_lineno; |
| 10304 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10305 | int _end_col_offset = _token->end_col_offset; |
| 10306 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10307 | _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 10308 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10309 | p->error_indicator = 1; |
| 10310 | return NULL; |
| 10311 | } |
| 10312 | goto done; |
| 10313 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10314 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10315 | } |
| 10316 | { // t_primary '[' slices ']' &t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10317 | Token * _literal; |
| 10318 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10319 | expr_ty a; |
| 10320 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10321 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10322 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10323 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10324 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10325 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10326 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10327 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10328 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10329 | && |
| 10330 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10331 | ) |
| 10332 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10333 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10334 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10335 | return NULL; |
| 10336 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10337 | int _end_lineno = _token->end_lineno; |
| 10338 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10339 | int _end_col_offset = _token->end_col_offset; |
| 10340 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10341 | _res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 10342 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10343 | p->error_indicator = 1; |
| 10344 | return NULL; |
| 10345 | } |
| 10346 | goto done; |
| 10347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10348 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10349 | } |
| 10350 | { // t_primary genexp &t_lookahead |
| 10351 | expr_ty a; |
| 10352 | expr_ty b; |
| 10353 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10354 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10355 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10356 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10357 | && |
| 10358 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10359 | ) |
| 10360 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10361 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10362 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10363 | return NULL; |
| 10364 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10365 | int _end_lineno = _token->end_lineno; |
| 10366 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10367 | int _end_col_offset = _token->end_col_offset; |
| 10368 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10369 | _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 10370 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10371 | p->error_indicator = 1; |
| 10372 | return NULL; |
| 10373 | } |
| 10374 | goto done; |
| 10375 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10376 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10377 | } |
| 10378 | { // t_primary '(' arguments? ')' &t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10379 | Token * _literal; |
| 10380 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10381 | expr_ty a; |
| 10382 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10383 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10384 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10385 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10386 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10387 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10388 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10389 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10390 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10391 | && |
| 10392 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10393 | ) |
| 10394 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10395 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10396 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10397 | return NULL; |
| 10398 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10399 | int _end_lineno = _token->end_lineno; |
| 10400 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10401 | int _end_col_offset = _token->end_col_offset; |
| 10402 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10403 | _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 10404 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10405 | p->error_indicator = 1; |
| 10406 | return NULL; |
| 10407 | } |
| 10408 | goto done; |
| 10409 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10410 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10411 | } |
| 10412 | { // atom &t_lookahead |
| 10413 | expr_ty a; |
| 10414 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10415 | (a = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10416 | && |
| 10417 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10418 | ) |
| 10419 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10420 | _res = a; |
| 10421 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10422 | p->error_indicator = 1; |
| 10423 | return NULL; |
| 10424 | } |
| 10425 | goto done; |
| 10426 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10427 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10428 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10429 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10430 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10431 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10432 | } |
| 10433 | |
| 10434 | // t_lookahead: '(' | '[' | '.' |
| 10435 | static void * |
| 10436 | t_lookahead_rule(Parser *p) |
| 10437 | { |
| 10438 | if (p->error_indicator) { |
| 10439 | return NULL; |
| 10440 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10441 | void * _res = NULL; |
| 10442 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10443 | { // '(' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10444 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10445 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10446 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10447 | ) |
| 10448 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10449 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10450 | goto done; |
| 10451 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10452 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10453 | } |
| 10454 | { // '[' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10455 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10456 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10457 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10458 | ) |
| 10459 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10460 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10461 | goto done; |
| 10462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10463 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10464 | } |
| 10465 | { // '.' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10466 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10467 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10468 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10469 | ) |
| 10470 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10471 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10472 | goto done; |
| 10473 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10474 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10475 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10476 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10477 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10478 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10479 | } |
| 10480 | |
| 10481 | // t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' |
| 10482 | static expr_ty |
| 10483 | t_atom_rule(Parser *p) |
| 10484 | { |
| 10485 | if (p->error_indicator) { |
| 10486 | return NULL; |
| 10487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10488 | expr_ty _res = NULL; |
| 10489 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10490 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10491 | p->error_indicator = 1; |
| 10492 | return NULL; |
| 10493 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10494 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10495 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10496 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10497 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10498 | { // NAME |
| 10499 | expr_ty a; |
| 10500 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10501 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10502 | ) |
| 10503 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10504 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10505 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10506 | p->error_indicator = 1; |
| 10507 | return NULL; |
| 10508 | } |
| 10509 | goto done; |
| 10510 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10511 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10512 | } |
| 10513 | { // '(' target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10514 | Token * _literal; |
| 10515 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10516 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10517 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10518 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10519 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10520 | (a = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10521 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10522 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10523 | ) |
| 10524 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10525 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10526 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10527 | p->error_indicator = 1; |
| 10528 | return NULL; |
| 10529 | } |
| 10530 | goto done; |
| 10531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10532 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10533 | } |
| 10534 | { // '(' targets? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10535 | Token * _literal; |
| 10536 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10537 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10538 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10539 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10540 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10541 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10542 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10543 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10544 | ) |
| 10545 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10546 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10547 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10548 | return NULL; |
| 10549 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10550 | int _end_lineno = _token->end_lineno; |
| 10551 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10552 | int _end_col_offset = _token->end_col_offset; |
| 10553 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10554 | _res = _Py_Tuple ( b , Store , EXTRA ); |
| 10555 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10556 | p->error_indicator = 1; |
| 10557 | return NULL; |
| 10558 | } |
| 10559 | goto done; |
| 10560 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10561 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10562 | } |
| 10563 | { // '[' targets? ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10564 | Token * _literal; |
| 10565 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10566 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10567 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10568 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10569 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10570 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10571 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10572 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10573 | ) |
| 10574 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10575 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10576 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10577 | return NULL; |
| 10578 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10579 | int _end_lineno = _token->end_lineno; |
| 10580 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10581 | int _end_col_offset = _token->end_col_offset; |
| 10582 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10583 | _res = _Py_List ( b , Store , EXTRA ); |
| 10584 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10585 | p->error_indicator = 1; |
| 10586 | return NULL; |
| 10587 | } |
| 10588 | goto done; |
| 10589 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10590 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10591 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10592 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10593 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10594 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10595 | } |
| 10596 | |
| 10597 | // incorrect_arguments: |
| 10598 | // | args ',' '*' |
| 10599 | // | expression for_if_clauses ',' [args | expression for_if_clauses] |
| 10600 | // | args ',' args |
| 10601 | static void * |
| 10602 | incorrect_arguments_rule(Parser *p) |
| 10603 | { |
| 10604 | if (p->error_indicator) { |
| 10605 | return NULL; |
| 10606 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10607 | void * _res = NULL; |
| 10608 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10609 | { // args ',' '*' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10610 | Token * _literal; |
| 10611 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10612 | expr_ty args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10613 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10614 | (args_var = args_rule(p)) // args |
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 = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10617 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10618 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10619 | ) |
| 10620 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10621 | _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); |
| 10622 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10623 | p->error_indicator = 1; |
| 10624 | return NULL; |
| 10625 | } |
| 10626 | goto done; |
| 10627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10628 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10629 | } |
| 10630 | { // expression for_if_clauses ',' [args | expression for_if_clauses] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10631 | Token * _literal; |
| 10632 | void *_opt_var; |
| 10633 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10634 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10635 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10636 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10637 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10638 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10639 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
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 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10642 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10643 | (_opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10644 | ) |
| 10645 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10646 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10647 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10648 | p->error_indicator = 1; |
| 10649 | return NULL; |
| 10650 | } |
| 10651 | goto done; |
| 10652 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10653 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10654 | } |
| 10655 | { // args ',' args |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10656 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10657 | expr_ty a; |
| 10658 | expr_ty args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10659 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10660 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10661 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10662 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10663 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10664 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10665 | ) |
| 10666 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10667 | _res = _PyPegen_arguments_parsing_error ( p , a ); |
| 10668 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10669 | p->error_indicator = 1; |
| 10670 | return NULL; |
| 10671 | } |
| 10672 | goto done; |
| 10673 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10674 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10675 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10676 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10677 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10678 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10679 | } |
| 10680 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10681 | // invalid_kwarg: expression '=' |
| 10682 | static void * |
| 10683 | invalid_kwarg_rule(Parser *p) |
| 10684 | { |
| 10685 | if (p->error_indicator) { |
| 10686 | return NULL; |
| 10687 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10688 | void * _res = NULL; |
| 10689 | int _mark = p->mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10690 | { // expression '=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10691 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10692 | expr_ty a; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10693 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10694 | (a = expression_rule(p)) // expression |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10695 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10696 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10697 | ) |
| 10698 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10699 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression cannot contain assignment, perhaps you meant \"==\"?" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10700 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10701 | p->error_indicator = 1; |
| 10702 | return NULL; |
| 10703 | } |
| 10704 | goto done; |
| 10705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10706 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10707 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10708 | _res = NULL; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10709 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10710 | return _res; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10711 | } |
| 10712 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10713 | // invalid_named_expression: expression ':=' expression |
| 10714 | static void * |
| 10715 | invalid_named_expression_rule(Parser *p) |
| 10716 | { |
| 10717 | if (p->error_indicator) { |
| 10718 | return NULL; |
| 10719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10720 | void * _res = NULL; |
| 10721 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10722 | { // expression ':=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10723 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10724 | expr_ty a; |
| 10725 | expr_ty expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10726 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10727 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10728 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10729 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10730 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10731 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10732 | ) |
| 10733 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10734 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10735 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10736 | p->error_indicator = 1; |
| 10737 | return NULL; |
| 10738 | } |
| 10739 | goto done; |
| 10740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10741 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10742 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10743 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10744 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10745 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10746 | } |
| 10747 | |
| 10748 | // invalid_assignment: |
| 10749 | // | list ':' |
| 10750 | // | tuple ':' |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10751 | // | star_named_expression ',' star_named_expressions* ':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10752 | // | expression ':' expression ['=' annotated_rhs] |
| 10753 | // | expression ('=' | augassign) (yield_expr | star_expressions) |
| 10754 | static void * |
| 10755 | invalid_assignment_rule(Parser *p) |
| 10756 | { |
| 10757 | if (p->error_indicator) { |
| 10758 | return NULL; |
| 10759 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10760 | void * _res = NULL; |
| 10761 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10762 | { // list ':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10763 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10764 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10765 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10766 | (a = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10767 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10768 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10769 | ) |
| 10770 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10771 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not list) can be annotated" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10772 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10773 | p->error_indicator = 1; |
| 10774 | return NULL; |
| 10775 | } |
| 10776 | goto done; |
| 10777 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10778 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10779 | } |
| 10780 | { // tuple ':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10781 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10782 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10783 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10784 | (a = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10785 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10786 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10787 | ) |
| 10788 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10789 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); |
| 10790 | if (_res == NULL && PyErr_Occurred()) { |
| 10791 | p->error_indicator = 1; |
| 10792 | return NULL; |
| 10793 | } |
| 10794 | goto done; |
| 10795 | } |
| 10796 | p->mark = _mark; |
| 10797 | } |
| 10798 | { // star_named_expression ',' star_named_expressions* ':' |
| 10799 | Token * _literal; |
| 10800 | Token * _literal_1; |
| 10801 | asdl_seq * _loop0_126_var; |
| 10802 | expr_ty a; |
| 10803 | if ( |
| 10804 | (a = star_named_expression_rule(p)) // star_named_expression |
| 10805 | && |
| 10806 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 10807 | && |
| 10808 | (_loop0_126_var = _loop0_126_rule(p)) // star_named_expressions* |
| 10809 | && |
| 10810 | (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' |
| 10811 | ) |
| 10812 | { |
| 10813 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10814 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10815 | p->error_indicator = 1; |
| 10816 | return NULL; |
| 10817 | } |
| 10818 | goto done; |
| 10819 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10820 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10821 | } |
| 10822 | { // expression ':' expression ['=' annotated_rhs] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10823 | Token * _literal; |
| 10824 | void *_opt_var; |
| 10825 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10826 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10827 | expr_ty expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10828 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10829 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10830 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10831 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10832 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10833 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10834 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10835 | (_opt_var = _tmp_127_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10836 | ) |
| 10837 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10838 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10839 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10840 | p->error_indicator = 1; |
| 10841 | return NULL; |
| 10842 | } |
| 10843 | goto done; |
| 10844 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10845 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10846 | } |
| 10847 | { // expression ('=' | augassign) (yield_expr | star_expressions) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10848 | void *_tmp_128_var; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10849 | void *_tmp_129_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10850 | expr_ty a; |
| 10851 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10852 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10853 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10854 | (_tmp_128_var = _tmp_128_rule(p)) // '=' | augassign |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10855 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10856 | (_tmp_129_var = _tmp_129_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10857 | ) |
| 10858 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10859 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot assign to %s" , _PyPegen_get_expr_name ( a ) ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10860 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10861 | p->error_indicator = 1; |
| 10862 | return NULL; |
| 10863 | } |
| 10864 | goto done; |
| 10865 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10866 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10867 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10868 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10869 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10870 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10871 | } |
| 10872 | |
| 10873 | // invalid_block: NEWLINE !INDENT |
| 10874 | static void * |
| 10875 | invalid_block_rule(Parser *p) |
| 10876 | { |
| 10877 | if (p->error_indicator) { |
| 10878 | return NULL; |
| 10879 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10880 | void * _res = NULL; |
| 10881 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10882 | { // NEWLINE !INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10883 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10884 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10885 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10886 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10887 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10888 | ) |
| 10889 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10890 | _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); |
| 10891 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10892 | p->error_indicator = 1; |
| 10893 | return NULL; |
| 10894 | } |
| 10895 | goto done; |
| 10896 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10897 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10898 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10899 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10900 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10901 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10902 | } |
| 10903 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10904 | // invalid_comprehension: ('[' | '(' | '{') starred_expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10905 | static void * |
| 10906 | invalid_comprehension_rule(Parser *p) |
| 10907 | { |
| 10908 | if (p->error_indicator) { |
| 10909 | return NULL; |
| 10910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10911 | void * _res = NULL; |
| 10912 | int _mark = p->mark; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10913 | { // ('[' | '(' | '{') starred_expression for_if_clauses |
| 10914 | void *_tmp_130_var; |
| 10915 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10916 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10917 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10918 | (_tmp_130_var = _tmp_130_rule(p)) // '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10919 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10920 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10921 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10922 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10923 | ) |
| 10924 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10925 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "iterable unpacking cannot be used in comprehension" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10926 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10927 | p->error_indicator = 1; |
| 10928 | return NULL; |
| 10929 | } |
| 10930 | goto done; |
| 10931 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10932 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10933 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10934 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10935 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10936 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10937 | } |
| 10938 | |
| 10939 | // invalid_parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10940 | // | param_no_default* (slash_with_default | param_with_default+) param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10941 | static void * |
| 10942 | invalid_parameters_rule(Parser *p) |
| 10943 | { |
| 10944 | if (p->error_indicator) { |
| 10945 | return NULL; |
| 10946 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10947 | void * _res = NULL; |
| 10948 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10949 | { // param_no_default* (slash_with_default | param_with_default+) param_no_default |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10950 | asdl_seq * _loop0_131_var; |
| 10951 | void *_tmp_132_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10952 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10953 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10954 | (_loop0_131_var = _loop0_131_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10955 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10956 | (_tmp_132_var = _tmp_132_rule(p)) // slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10957 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10958 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10959 | ) |
| 10960 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10961 | _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 10962 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10963 | p->error_indicator = 1; |
| 10964 | return NULL; |
| 10965 | } |
| 10966 | goto done; |
| 10967 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10968 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10969 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10970 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10971 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10972 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10973 | } |
| 10974 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10975 | // invalid_star_etc: '*' (')' | ',' (')' | '**')) |
| 10976 | static void * |
| 10977 | invalid_star_etc_rule(Parser *p) |
| 10978 | { |
| 10979 | if (p->error_indicator) { |
| 10980 | return NULL; |
| 10981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10982 | void * _res = NULL; |
| 10983 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10984 | { // '*' (')' | ',' (')' | '**')) |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10985 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10986 | void *_tmp_133_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10987 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10988 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10989 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 10990 | (_tmp_133_var = _tmp_133_rule(p)) // ')' | ',' (')' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10991 | ) |
| 10992 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10993 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 10994 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10995 | p->error_indicator = 1; |
| 10996 | return NULL; |
| 10997 | } |
| 10998 | goto done; |
| 10999 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11000 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11001 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11002 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11003 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11004 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11005 | } |
| 11006 | |
| 11007 | // invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) |
| 11008 | static void * |
| 11009 | invalid_lambda_star_etc_rule(Parser *p) |
| 11010 | { |
| 11011 | if (p->error_indicator) { |
| 11012 | return NULL; |
| 11013 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11014 | void * _res = NULL; |
| 11015 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11016 | { // '*' (':' | ',' (':' | '**')) |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11017 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11018 | void *_tmp_134_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11019 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11020 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11021 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11022 | (_tmp_134_var = _tmp_134_rule(p)) // ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11023 | ) |
| 11024 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11025 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 11026 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11027 | p->error_indicator = 1; |
| 11028 | return NULL; |
| 11029 | } |
| 11030 | goto done; |
| 11031 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11032 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11033 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11034 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11035 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11036 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11037 | } |
| 11038 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11039 | // invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 11040 | static void * |
| 11041 | invalid_double_type_comments_rule(Parser *p) |
| 11042 | { |
| 11043 | if (p->error_indicator) { |
| 11044 | return NULL; |
| 11045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11046 | void * _res = NULL; |
| 11047 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11048 | { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11049 | Token * indent_var; |
| 11050 | Token * newline_var; |
| 11051 | Token * newline_var_1; |
| 11052 | Token * type_comment_var; |
| 11053 | Token * type_comment_var_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11054 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11055 | (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] | 11056 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11057 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11058 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11059 | (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] | 11060 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11061 | (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11062 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11063 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11064 | ) |
| 11065 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11066 | _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); |
| 11067 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11068 | p->error_indicator = 1; |
| 11069 | return NULL; |
| 11070 | } |
| 11071 | goto done; |
| 11072 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11073 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11074 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11075 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11076 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11077 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11078 | } |
| 11079 | |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 11080 | // invalid_del_target: star_expression &del_target_end |
| 11081 | static void * |
| 11082 | invalid_del_target_rule(Parser *p) |
| 11083 | { |
| 11084 | if (p->error_indicator) { |
| 11085 | return NULL; |
| 11086 | } |
| 11087 | void * _res = NULL; |
| 11088 | int _mark = p->mark; |
| 11089 | { // star_expression &del_target_end |
| 11090 | expr_ty a; |
| 11091 | if ( |
| 11092 | (a = star_expression_rule(p)) // star_expression |
| 11093 | && |
| 11094 | _PyPegen_lookahead(1, del_target_end_rule, p) |
| 11095 | ) |
| 11096 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11097 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot delete %s" , _PyPegen_get_expr_name ( a ) ); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 11098 | if (_res == NULL && PyErr_Occurred()) { |
| 11099 | p->error_indicator = 1; |
| 11100 | return NULL; |
| 11101 | } |
| 11102 | goto done; |
| 11103 | } |
| 11104 | p->mark = _mark; |
| 11105 | } |
| 11106 | _res = NULL; |
| 11107 | done: |
| 11108 | return _res; |
| 11109 | } |
| 11110 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11111 | // _loop0_1: NEWLINE |
| 11112 | static asdl_seq * |
| 11113 | _loop0_1_rule(Parser *p) |
| 11114 | { |
| 11115 | if (p->error_indicator) { |
| 11116 | return NULL; |
| 11117 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11118 | void *_res = NULL; |
| 11119 | int _mark = p->mark; |
| 11120 | int _start_mark = p->mark; |
| 11121 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11122 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11123 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11124 | return NULL; |
| 11125 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11126 | ssize_t _children_capacity = 1; |
| 11127 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11128 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11129 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11130 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11131 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11132 | ) |
| 11133 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11134 | _res = newline_var; |
| 11135 | if (_n == _children_capacity) { |
| 11136 | _children_capacity *= 2; |
| 11137 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11138 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11139 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11140 | return NULL; |
| 11141 | } |
| 11142 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11143 | _children[_n++] = _res; |
| 11144 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11145 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11146 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11147 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11148 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11149 | if (!_seq) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11150 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11151 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11152 | return NULL; |
| 11153 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11154 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11155 | PyMem_Free(_children); |
| 11156 | _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq); |
| 11157 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11158 | } |
| 11159 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11160 | // _loop0_2: NEWLINE |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11161 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11162 | _loop0_2_rule(Parser *p) |
| 11163 | { |
| 11164 | if (p->error_indicator) { |
| 11165 | return NULL; |
| 11166 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11167 | void *_res = NULL; |
| 11168 | int _mark = p->mark; |
| 11169 | int _start_mark = p->mark; |
| 11170 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11171 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11172 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11173 | return NULL; |
| 11174 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11175 | ssize_t _children_capacity = 1; |
| 11176 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11177 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11178 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11179 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11180 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11181 | ) |
| 11182 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11183 | _res = newline_var; |
| 11184 | if (_n == _children_capacity) { |
| 11185 | _children_capacity *= 2; |
| 11186 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11187 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11188 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11189 | return NULL; |
| 11190 | } |
| 11191 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11192 | _children[_n++] = _res; |
| 11193 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11194 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11195 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11196 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11197 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11198 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11199 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11200 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11201 | return NULL; |
| 11202 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11203 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11204 | PyMem_Free(_children); |
| 11205 | _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq); |
| 11206 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11207 | } |
| 11208 | |
| 11209 | // _loop0_4: ',' expression |
| 11210 | static asdl_seq * |
| 11211 | _loop0_4_rule(Parser *p) |
| 11212 | { |
| 11213 | if (p->error_indicator) { |
| 11214 | return NULL; |
| 11215 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11216 | void *_res = NULL; |
| 11217 | int _mark = p->mark; |
| 11218 | int _start_mark = p->mark; |
| 11219 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11220 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11221 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11222 | return NULL; |
| 11223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11224 | ssize_t _children_capacity = 1; |
| 11225 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11226 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11227 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11228 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11229 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11230 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11231 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11232 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11233 | ) |
| 11234 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11235 | _res = elem; |
| 11236 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11237 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11238 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11239 | return NULL; |
| 11240 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11241 | if (_n == _children_capacity) { |
| 11242 | _children_capacity *= 2; |
| 11243 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11244 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11245 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11246 | return NULL; |
| 11247 | } |
| 11248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11249 | _children[_n++] = _res; |
| 11250 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11252 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11253 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11254 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11255 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11256 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11257 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11258 | return NULL; |
| 11259 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11260 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11261 | PyMem_Free(_children); |
| 11262 | _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq); |
| 11263 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11264 | } |
| 11265 | |
| 11266 | // _gather_3: expression _loop0_4 |
| 11267 | static asdl_seq * |
| 11268 | _gather_3_rule(Parser *p) |
| 11269 | { |
| 11270 | if (p->error_indicator) { |
| 11271 | return NULL; |
| 11272 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11273 | asdl_seq * _res = NULL; |
| 11274 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11275 | { // expression _loop0_4 |
| 11276 | expr_ty elem; |
| 11277 | asdl_seq * seq; |
| 11278 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11279 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11280 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11281 | (seq = _loop0_4_rule(p)) // _loop0_4 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11282 | ) |
| 11283 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11284 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11285 | goto done; |
| 11286 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11287 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11288 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11289 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11290 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11291 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11292 | } |
| 11293 | |
| 11294 | // _loop0_6: ',' expression |
| 11295 | static asdl_seq * |
| 11296 | _loop0_6_rule(Parser *p) |
| 11297 | { |
| 11298 | if (p->error_indicator) { |
| 11299 | return NULL; |
| 11300 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11301 | void *_res = NULL; |
| 11302 | int _mark = p->mark; |
| 11303 | int _start_mark = p->mark; |
| 11304 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11305 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11306 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11307 | return NULL; |
| 11308 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11309 | ssize_t _children_capacity = 1; |
| 11310 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11311 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11312 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11313 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11314 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11315 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11316 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11317 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11318 | ) |
| 11319 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11320 | _res = elem; |
| 11321 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11322 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11323 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11324 | return NULL; |
| 11325 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11326 | if (_n == _children_capacity) { |
| 11327 | _children_capacity *= 2; |
| 11328 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11329 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11330 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11331 | return NULL; |
| 11332 | } |
| 11333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11334 | _children[_n++] = _res; |
| 11335 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11336 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11337 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11338 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11339 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11340 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11341 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11342 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11343 | return NULL; |
| 11344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11345 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11346 | PyMem_Free(_children); |
| 11347 | _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq); |
| 11348 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11349 | } |
| 11350 | |
| 11351 | // _gather_5: expression _loop0_6 |
| 11352 | static asdl_seq * |
| 11353 | _gather_5_rule(Parser *p) |
| 11354 | { |
| 11355 | if (p->error_indicator) { |
| 11356 | return NULL; |
| 11357 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11358 | asdl_seq * _res = NULL; |
| 11359 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11360 | { // expression _loop0_6 |
| 11361 | expr_ty elem; |
| 11362 | asdl_seq * seq; |
| 11363 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11364 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11365 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11366 | (seq = _loop0_6_rule(p)) // _loop0_6 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11367 | ) |
| 11368 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11369 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11370 | goto done; |
| 11371 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11372 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11373 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11374 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11375 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11376 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11377 | } |
| 11378 | |
| 11379 | // _loop0_8: ',' expression |
| 11380 | static asdl_seq * |
| 11381 | _loop0_8_rule(Parser *p) |
| 11382 | { |
| 11383 | if (p->error_indicator) { |
| 11384 | return NULL; |
| 11385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11386 | void *_res = NULL; |
| 11387 | int _mark = p->mark; |
| 11388 | int _start_mark = p->mark; |
| 11389 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11390 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11391 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11392 | return NULL; |
| 11393 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11394 | ssize_t _children_capacity = 1; |
| 11395 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11396 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11397 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11398 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11399 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11400 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11401 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11402 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11403 | ) |
| 11404 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11405 | _res = elem; |
| 11406 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11407 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11408 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11409 | return NULL; |
| 11410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11411 | if (_n == _children_capacity) { |
| 11412 | _children_capacity *= 2; |
| 11413 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11414 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11415 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11416 | return NULL; |
| 11417 | } |
| 11418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11419 | _children[_n++] = _res; |
| 11420 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11422 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11423 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11424 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11425 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11426 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11427 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11428 | return NULL; |
| 11429 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11430 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11431 | PyMem_Free(_children); |
| 11432 | _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq); |
| 11433 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11434 | } |
| 11435 | |
| 11436 | // _gather_7: expression _loop0_8 |
| 11437 | static asdl_seq * |
| 11438 | _gather_7_rule(Parser *p) |
| 11439 | { |
| 11440 | if (p->error_indicator) { |
| 11441 | return NULL; |
| 11442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11443 | asdl_seq * _res = NULL; |
| 11444 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11445 | { // expression _loop0_8 |
| 11446 | expr_ty elem; |
| 11447 | asdl_seq * seq; |
| 11448 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11449 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11450 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11451 | (seq = _loop0_8_rule(p)) // _loop0_8 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11452 | ) |
| 11453 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11454 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11455 | goto done; |
| 11456 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11457 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11458 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11459 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11460 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11461 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11462 | } |
| 11463 | |
| 11464 | // _loop0_10: ',' expression |
| 11465 | static asdl_seq * |
| 11466 | _loop0_10_rule(Parser *p) |
| 11467 | { |
| 11468 | if (p->error_indicator) { |
| 11469 | return NULL; |
| 11470 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11471 | void *_res = NULL; |
| 11472 | int _mark = p->mark; |
| 11473 | int _start_mark = p->mark; |
| 11474 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11475 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11476 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11477 | return NULL; |
| 11478 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11479 | ssize_t _children_capacity = 1; |
| 11480 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11481 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11482 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11483 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11484 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11485 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11486 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11487 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11488 | ) |
| 11489 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11490 | _res = elem; |
| 11491 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11492 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11493 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11494 | return NULL; |
| 11495 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11496 | if (_n == _children_capacity) { |
| 11497 | _children_capacity *= 2; |
| 11498 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11499 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11500 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11501 | return NULL; |
| 11502 | } |
| 11503 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11504 | _children[_n++] = _res; |
| 11505 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11507 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11508 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11509 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11510 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11511 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11512 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11513 | return NULL; |
| 11514 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11515 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11516 | PyMem_Free(_children); |
| 11517 | _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq); |
| 11518 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11519 | } |
| 11520 | |
| 11521 | // _gather_9: expression _loop0_10 |
| 11522 | static asdl_seq * |
| 11523 | _gather_9_rule(Parser *p) |
| 11524 | { |
| 11525 | if (p->error_indicator) { |
| 11526 | return NULL; |
| 11527 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11528 | asdl_seq * _res = NULL; |
| 11529 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11530 | { // expression _loop0_10 |
| 11531 | expr_ty elem; |
| 11532 | asdl_seq * seq; |
| 11533 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11534 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11535 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11536 | (seq = _loop0_10_rule(p)) // _loop0_10 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11537 | ) |
| 11538 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11539 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11540 | goto done; |
| 11541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11542 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11543 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11544 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11545 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11546 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11547 | } |
| 11548 | |
| 11549 | // _loop1_11: statement |
| 11550 | static asdl_seq * |
| 11551 | _loop1_11_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11552 | { |
| 11553 | if (p->error_indicator) { |
| 11554 | return NULL; |
| 11555 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11556 | void *_res = NULL; |
| 11557 | int _mark = p->mark; |
| 11558 | int _start_mark = p->mark; |
| 11559 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11560 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11561 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11562 | return NULL; |
| 11563 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11564 | ssize_t _children_capacity = 1; |
| 11565 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11566 | { // statement |
| 11567 | asdl_seq* statement_var; |
| 11568 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11569 | (statement_var = statement_rule(p)) // statement |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11570 | ) |
| 11571 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11572 | _res = statement_var; |
| 11573 | if (_n == _children_capacity) { |
| 11574 | _children_capacity *= 2; |
| 11575 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11576 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11577 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11578 | return NULL; |
| 11579 | } |
| 11580 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11581 | _children[_n++] = _res; |
| 11582 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11583 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11584 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11586 | if (_n == 0 || p->error_indicator) { |
| 11587 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11588 | return NULL; |
| 11589 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11590 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11591 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11592 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11593 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11594 | return NULL; |
| 11595 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11596 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11597 | PyMem_Free(_children); |
| 11598 | _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq); |
| 11599 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11600 | } |
| 11601 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11602 | // _loop0_13: ';' small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11603 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11604 | _loop0_13_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11605 | { |
| 11606 | if (p->error_indicator) { |
| 11607 | return NULL; |
| 11608 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11609 | void *_res = NULL; |
| 11610 | int _mark = p->mark; |
| 11611 | int _start_mark = p->mark; |
| 11612 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11613 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11614 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11615 | return NULL; |
| 11616 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11617 | ssize_t _children_capacity = 1; |
| 11618 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11619 | { // ';' small_stmt |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11620 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11621 | stmt_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11622 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11623 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11624 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11625 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11626 | ) |
| 11627 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11628 | _res = elem; |
| 11629 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11630 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11631 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11632 | return NULL; |
| 11633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11634 | if (_n == _children_capacity) { |
| 11635 | _children_capacity *= 2; |
| 11636 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11637 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11638 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11639 | return NULL; |
| 11640 | } |
| 11641 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11642 | _children[_n++] = _res; |
| 11643 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11644 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11645 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11646 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11647 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11648 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11649 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11650 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11651 | return NULL; |
| 11652 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11653 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11654 | PyMem_Free(_children); |
| 11655 | _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq); |
| 11656 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11657 | } |
| 11658 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11659 | // _gather_12: small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11660 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11661 | _gather_12_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11662 | { |
| 11663 | if (p->error_indicator) { |
| 11664 | return NULL; |
| 11665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11666 | asdl_seq * _res = NULL; |
| 11667 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11668 | { // small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11669 | stmt_ty elem; |
| 11670 | asdl_seq * seq; |
| 11671 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11672 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11673 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11674 | (seq = _loop0_13_rule(p)) // _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11675 | ) |
| 11676 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11677 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11678 | goto done; |
| 11679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11680 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11681 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11682 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11683 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11684 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11685 | } |
| 11686 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11687 | // _tmp_14: 'import' | 'from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11688 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11689 | _tmp_14_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11690 | { |
| 11691 | if (p->error_indicator) { |
| 11692 | return NULL; |
| 11693 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11694 | void * _res = NULL; |
| 11695 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11696 | { // 'import' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11697 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11698 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11699 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11700 | ) |
| 11701 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11702 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11703 | goto done; |
| 11704 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11705 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11706 | } |
| 11707 | { // 'from' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11708 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11709 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11710 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11711 | ) |
| 11712 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11713 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11714 | goto done; |
| 11715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11716 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11717 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11718 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11719 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11720 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11721 | } |
| 11722 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11723 | // _tmp_15: 'def' | '@' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11724 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11725 | _tmp_15_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11726 | { |
| 11727 | if (p->error_indicator) { |
| 11728 | return NULL; |
| 11729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11730 | void * _res = NULL; |
| 11731 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11732 | { // 'def' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11733 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11734 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11735 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11736 | ) |
| 11737 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11738 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11739 | goto done; |
| 11740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11741 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11742 | } |
| 11743 | { // '@' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11744 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11745 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11746 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11747 | ) |
| 11748 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11749 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11750 | goto done; |
| 11751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11752 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11753 | } |
| 11754 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11755 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11756 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11757 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11758 | ) |
| 11759 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11760 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11761 | goto done; |
| 11762 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11763 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11765 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11766 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11767 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11768 | } |
| 11769 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11770 | // _tmp_16: 'class' | '@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11771 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11772 | _tmp_16_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11773 | { |
| 11774 | if (p->error_indicator) { |
| 11775 | return NULL; |
| 11776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11777 | void * _res = NULL; |
| 11778 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11779 | { // 'class' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11780 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11781 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11782 | (_keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11783 | ) |
| 11784 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11785 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11786 | goto done; |
| 11787 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11788 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11789 | } |
| 11790 | { // '@' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11791 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11792 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11793 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11794 | ) |
| 11795 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11796 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11797 | goto done; |
| 11798 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11799 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11800 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11801 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11802 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11803 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11804 | } |
| 11805 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11806 | // _tmp_17: 'with' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11807 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11808 | _tmp_17_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11809 | { |
| 11810 | if (p->error_indicator) { |
| 11811 | return NULL; |
| 11812 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11813 | void * _res = NULL; |
| 11814 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11815 | { // 'with' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11816 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11817 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11818 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11819 | ) |
| 11820 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11821 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11822 | goto done; |
| 11823 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11824 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11825 | } |
| 11826 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11827 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11828 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11829 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11830 | ) |
| 11831 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11832 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11833 | goto done; |
| 11834 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11835 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11837 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11838 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11839 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11840 | } |
| 11841 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11842 | // _tmp_18: 'for' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11843 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11844 | _tmp_18_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11845 | { |
| 11846 | if (p->error_indicator) { |
| 11847 | return NULL; |
| 11848 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11849 | void * _res = NULL; |
| 11850 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11851 | { // 'for' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11852 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11853 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11854 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11855 | ) |
| 11856 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11857 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11858 | goto done; |
| 11859 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11860 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11861 | } |
| 11862 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11863 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11864 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11865 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11866 | ) |
| 11867 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11868 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11869 | goto done; |
| 11870 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11871 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11872 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11873 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11874 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11875 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11876 | } |
| 11877 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11878 | // _tmp_19: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11879 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11880 | _tmp_19_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11881 | { |
| 11882 | if (p->error_indicator) { |
| 11883 | return NULL; |
| 11884 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11885 | void * _res = NULL; |
| 11886 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11887 | { // '=' annotated_rhs |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11888 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11889 | expr_ty d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11890 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11891 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11892 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11893 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11894 | ) |
| 11895 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11896 | _res = d; |
| 11897 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11898 | p->error_indicator = 1; |
| 11899 | return NULL; |
| 11900 | } |
| 11901 | goto done; |
| 11902 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11903 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11904 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11905 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11906 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11907 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11908 | } |
| 11909 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11910 | // _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11911 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11912 | _tmp_20_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11913 | { |
| 11914 | if (p->error_indicator) { |
| 11915 | return NULL; |
| 11916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11917 | void * _res = NULL; |
| 11918 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11919 | { // '(' inside_paren_ann_assign_target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11920 | Token * _literal; |
| 11921 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11922 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11923 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11924 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11925 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11926 | (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] | 11927 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11928 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11929 | ) |
| 11930 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11931 | _res = b; |
| 11932 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11933 | p->error_indicator = 1; |
| 11934 | return NULL; |
| 11935 | } |
| 11936 | goto done; |
| 11937 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11938 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11939 | } |
| 11940 | { // ann_assign_subscript_attribute_target |
| 11941 | expr_ty ann_assign_subscript_attribute_target_var; |
| 11942 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11943 | (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] | 11944 | ) |
| 11945 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11946 | _res = ann_assign_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11947 | goto done; |
| 11948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11949 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11950 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11951 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11952 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11953 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11954 | } |
| 11955 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11956 | // _tmp_21: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11957 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11958 | _tmp_21_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11959 | { |
| 11960 | if (p->error_indicator) { |
| 11961 | return NULL; |
| 11962 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11963 | void * _res = NULL; |
| 11964 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11965 | { // '=' annotated_rhs |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11966 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11967 | expr_ty d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11968 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11969 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11970 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11971 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11972 | ) |
| 11973 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11974 | _res = d; |
| 11975 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11976 | p->error_indicator = 1; |
| 11977 | return NULL; |
| 11978 | } |
| 11979 | goto done; |
| 11980 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11981 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11983 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11984 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11985 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11986 | } |
| 11987 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11988 | // _loop1_22: (star_targets '=') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11989 | static asdl_seq * |
| 11990 | _loop1_22_rule(Parser *p) |
| 11991 | { |
| 11992 | if (p->error_indicator) { |
| 11993 | return NULL; |
| 11994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11995 | void *_res = NULL; |
| 11996 | int _mark = p->mark; |
| 11997 | int _start_mark = p->mark; |
| 11998 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11999 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12000 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12001 | return NULL; |
| 12002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12003 | ssize_t _children_capacity = 1; |
| 12004 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12005 | { // (star_targets '=') |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12006 | void *_tmp_135_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12007 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12008 | (_tmp_135_var = _tmp_135_rule(p)) // star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12009 | ) |
| 12010 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12011 | _res = _tmp_135_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12012 | if (_n == _children_capacity) { |
| 12013 | _children_capacity *= 2; |
| 12014 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12015 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12016 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12017 | return NULL; |
| 12018 | } |
| 12019 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12020 | _children[_n++] = _res; |
| 12021 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12022 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12023 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12024 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12025 | if (_n == 0 || p->error_indicator) { |
| 12026 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12027 | return NULL; |
| 12028 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12029 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12030 | if (!_seq) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12031 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12032 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12033 | return NULL; |
| 12034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12035 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12036 | PyMem_Free(_children); |
| 12037 | _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq); |
| 12038 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12039 | } |
| 12040 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12041 | // _tmp_23: yield_expr | star_expressions |
| 12042 | static void * |
| 12043 | _tmp_23_rule(Parser *p) |
| 12044 | { |
| 12045 | if (p->error_indicator) { |
| 12046 | return NULL; |
| 12047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12048 | void * _res = NULL; |
| 12049 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12050 | { // yield_expr |
| 12051 | expr_ty yield_expr_var; |
| 12052 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12053 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12054 | ) |
| 12055 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12056 | _res = yield_expr_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12057 | goto done; |
| 12058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12059 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12060 | } |
| 12061 | { // star_expressions |
| 12062 | expr_ty star_expressions_var; |
| 12063 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12064 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12065 | ) |
| 12066 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12067 | _res = star_expressions_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12068 | goto done; |
| 12069 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12070 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12072 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12073 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12074 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12075 | } |
| 12076 | |
| 12077 | // _tmp_24: yield_expr | star_expressions |
| 12078 | static void * |
| 12079 | _tmp_24_rule(Parser *p) |
| 12080 | { |
| 12081 | if (p->error_indicator) { |
| 12082 | return NULL; |
| 12083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12084 | void * _res = NULL; |
| 12085 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12086 | { // yield_expr |
| 12087 | expr_ty yield_expr_var; |
| 12088 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12089 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12090 | ) |
| 12091 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12092 | _res = yield_expr_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12093 | goto done; |
| 12094 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12095 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12096 | } |
| 12097 | { // star_expressions |
| 12098 | expr_ty star_expressions_var; |
| 12099 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12100 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12101 | ) |
| 12102 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12103 | _res = star_expressions_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12104 | goto done; |
| 12105 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12106 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12107 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12108 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12109 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12110 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12111 | } |
| 12112 | |
| 12113 | // _loop0_26: ',' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12114 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12115 | _loop0_26_rule(Parser *p) |
| 12116 | { |
| 12117 | if (p->error_indicator) { |
| 12118 | return NULL; |
| 12119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12120 | void *_res = NULL; |
| 12121 | int _mark = p->mark; |
| 12122 | int _start_mark = p->mark; |
| 12123 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12124 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12125 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12126 | return NULL; |
| 12127 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12128 | ssize_t _children_capacity = 1; |
| 12129 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12130 | { // ',' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12131 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12132 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12133 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12134 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12135 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12136 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12137 | ) |
| 12138 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12139 | _res = elem; |
| 12140 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12141 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12142 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12143 | return NULL; |
| 12144 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12145 | if (_n == _children_capacity) { |
| 12146 | _children_capacity *= 2; |
| 12147 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12148 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12149 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12150 | return NULL; |
| 12151 | } |
| 12152 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12153 | _children[_n++] = _res; |
| 12154 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12155 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12156 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12157 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12158 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12159 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12160 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12161 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12162 | return NULL; |
| 12163 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12164 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12165 | PyMem_Free(_children); |
| 12166 | _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); |
| 12167 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12168 | } |
| 12169 | |
| 12170 | // _gather_25: NAME _loop0_26 |
| 12171 | static asdl_seq * |
| 12172 | _gather_25_rule(Parser *p) |
| 12173 | { |
| 12174 | if (p->error_indicator) { |
| 12175 | return NULL; |
| 12176 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12177 | asdl_seq * _res = NULL; |
| 12178 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12179 | { // NAME _loop0_26 |
| 12180 | expr_ty elem; |
| 12181 | asdl_seq * seq; |
| 12182 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12183 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12184 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12185 | (seq = _loop0_26_rule(p)) // _loop0_26 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12186 | ) |
| 12187 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12188 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12189 | goto done; |
| 12190 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12191 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12192 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12193 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12194 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12195 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12196 | } |
| 12197 | |
| 12198 | // _loop0_28: ',' NAME |
| 12199 | static asdl_seq * |
| 12200 | _loop0_28_rule(Parser *p) |
| 12201 | { |
| 12202 | if (p->error_indicator) { |
| 12203 | return NULL; |
| 12204 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12205 | void *_res = NULL; |
| 12206 | int _mark = p->mark; |
| 12207 | int _start_mark = p->mark; |
| 12208 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12209 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12210 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12211 | return NULL; |
| 12212 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12213 | ssize_t _children_capacity = 1; |
| 12214 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12215 | { // ',' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12216 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12217 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12218 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12219 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12220 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12221 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12222 | ) |
| 12223 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12224 | _res = elem; |
| 12225 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12226 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12227 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12228 | return NULL; |
| 12229 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12230 | if (_n == _children_capacity) { |
| 12231 | _children_capacity *= 2; |
| 12232 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12233 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12234 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12235 | return NULL; |
| 12236 | } |
| 12237 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12238 | _children[_n++] = _res; |
| 12239 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12240 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12241 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12242 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12243 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12244 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12245 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12246 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12247 | return NULL; |
| 12248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12249 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12250 | PyMem_Free(_children); |
| 12251 | _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); |
| 12252 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12253 | } |
| 12254 | |
| 12255 | // _gather_27: NAME _loop0_28 |
| 12256 | static asdl_seq * |
| 12257 | _gather_27_rule(Parser *p) |
| 12258 | { |
| 12259 | if (p->error_indicator) { |
| 12260 | return NULL; |
| 12261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12262 | asdl_seq * _res = NULL; |
| 12263 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12264 | { // NAME _loop0_28 |
| 12265 | expr_ty elem; |
| 12266 | asdl_seq * seq; |
| 12267 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12268 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12269 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12270 | (seq = _loop0_28_rule(p)) // _loop0_28 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12271 | ) |
| 12272 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12273 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12274 | goto done; |
| 12275 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12276 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12277 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12278 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12279 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12280 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12281 | } |
| 12282 | |
| 12283 | // _tmp_29: ',' expression |
| 12284 | static void * |
| 12285 | _tmp_29_rule(Parser *p) |
| 12286 | { |
| 12287 | if (p->error_indicator) { |
| 12288 | return NULL; |
| 12289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12290 | void * _res = NULL; |
| 12291 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12292 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12293 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12294 | expr_ty z; |
| 12295 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12296 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12297 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12298 | (z = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12299 | ) |
| 12300 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12301 | _res = z; |
| 12302 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12303 | p->error_indicator = 1; |
| 12304 | return NULL; |
| 12305 | } |
| 12306 | goto done; |
| 12307 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12308 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12309 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12310 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12311 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12312 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12313 | } |
| 12314 | |
| 12315 | // _loop0_30: ('.' | '...') |
| 12316 | static asdl_seq * |
| 12317 | _loop0_30_rule(Parser *p) |
| 12318 | { |
| 12319 | if (p->error_indicator) { |
| 12320 | return NULL; |
| 12321 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12322 | void *_res = NULL; |
| 12323 | int _mark = p->mark; |
| 12324 | int _start_mark = p->mark; |
| 12325 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12326 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12327 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12328 | return NULL; |
| 12329 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12330 | ssize_t _children_capacity = 1; |
| 12331 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12332 | { // ('.' | '...') |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12333 | void *_tmp_136_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12334 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12335 | (_tmp_136_var = _tmp_136_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12336 | ) |
| 12337 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12338 | _res = _tmp_136_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12339 | if (_n == _children_capacity) { |
| 12340 | _children_capacity *= 2; |
| 12341 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12342 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12343 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12344 | return NULL; |
| 12345 | } |
| 12346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12347 | _children[_n++] = _res; |
| 12348 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12349 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12350 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12351 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12352 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12353 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12354 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12355 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12356 | return NULL; |
| 12357 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12358 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12359 | PyMem_Free(_children); |
| 12360 | _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq); |
| 12361 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12362 | } |
| 12363 | |
| 12364 | // _loop1_31: ('.' | '...') |
| 12365 | static asdl_seq * |
| 12366 | _loop1_31_rule(Parser *p) |
| 12367 | { |
| 12368 | if (p->error_indicator) { |
| 12369 | return NULL; |
| 12370 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12371 | void *_res = NULL; |
| 12372 | int _mark = p->mark; |
| 12373 | int _start_mark = p->mark; |
| 12374 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12375 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12376 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12377 | return NULL; |
| 12378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12379 | ssize_t _children_capacity = 1; |
| 12380 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12381 | { // ('.' | '...') |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12382 | void *_tmp_137_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12383 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12384 | (_tmp_137_var = _tmp_137_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12385 | ) |
| 12386 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12387 | _res = _tmp_137_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12388 | if (_n == _children_capacity) { |
| 12389 | _children_capacity *= 2; |
| 12390 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12391 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12392 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12393 | return NULL; |
| 12394 | } |
| 12395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12396 | _children[_n++] = _res; |
| 12397 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12398 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12399 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12400 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12401 | if (_n == 0 || p->error_indicator) { |
| 12402 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12403 | return NULL; |
| 12404 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12405 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12406 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12407 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12408 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12409 | return NULL; |
| 12410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12411 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12412 | PyMem_Free(_children); |
| 12413 | _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq); |
| 12414 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12415 | } |
| 12416 | |
| 12417 | // _loop0_33: ',' import_from_as_name |
| 12418 | static asdl_seq * |
| 12419 | _loop0_33_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12420 | { |
| 12421 | if (p->error_indicator) { |
| 12422 | return NULL; |
| 12423 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12424 | void *_res = NULL; |
| 12425 | int _mark = p->mark; |
| 12426 | int _start_mark = p->mark; |
| 12427 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12428 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12429 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12430 | return NULL; |
| 12431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12432 | ssize_t _children_capacity = 1; |
| 12433 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12434 | { // ',' import_from_as_name |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12435 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12436 | alias_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12437 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12438 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12439 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12440 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12441 | ) |
| 12442 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12443 | _res = elem; |
| 12444 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12445 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12446 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12447 | return NULL; |
| 12448 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12449 | if (_n == _children_capacity) { |
| 12450 | _children_capacity *= 2; |
| 12451 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12452 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12453 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12454 | return NULL; |
| 12455 | } |
| 12456 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12457 | _children[_n++] = _res; |
| 12458 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12459 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12460 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12461 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12462 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12463 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12464 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12465 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12466 | return NULL; |
| 12467 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12468 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12469 | PyMem_Free(_children); |
| 12470 | _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq); |
| 12471 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12472 | } |
| 12473 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12474 | // _gather_32: import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12475 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12476 | _gather_32_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12477 | { |
| 12478 | if (p->error_indicator) { |
| 12479 | return NULL; |
| 12480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12481 | asdl_seq * _res = NULL; |
| 12482 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12483 | { // import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12484 | alias_ty elem; |
| 12485 | asdl_seq * seq; |
| 12486 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12487 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12488 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12489 | (seq = _loop0_33_rule(p)) // _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12490 | ) |
| 12491 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12492 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12493 | goto done; |
| 12494 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12495 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12496 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12497 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12498 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12499 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12500 | } |
| 12501 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12502 | // _tmp_34: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12503 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12504 | _tmp_34_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12505 | { |
| 12506 | if (p->error_indicator) { |
| 12507 | return NULL; |
| 12508 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12509 | void * _res = NULL; |
| 12510 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12511 | { // 'as' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12512 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12513 | expr_ty z; |
| 12514 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12515 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12516 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12517 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12518 | ) |
| 12519 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12520 | _res = z; |
| 12521 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12522 | p->error_indicator = 1; |
| 12523 | return NULL; |
| 12524 | } |
| 12525 | goto done; |
| 12526 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12527 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12529 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12530 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12531 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12532 | } |
| 12533 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12534 | // _loop0_36: ',' dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12535 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12536 | _loop0_36_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12537 | { |
| 12538 | if (p->error_indicator) { |
| 12539 | return NULL; |
| 12540 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12541 | void *_res = NULL; |
| 12542 | int _mark = p->mark; |
| 12543 | int _start_mark = p->mark; |
| 12544 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12545 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12546 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12547 | return NULL; |
| 12548 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12549 | ssize_t _children_capacity = 1; |
| 12550 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12551 | { // ',' dotted_as_name |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12552 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12553 | alias_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12554 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12555 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12556 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12557 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12558 | ) |
| 12559 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12560 | _res = elem; |
| 12561 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12562 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12563 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12564 | return NULL; |
| 12565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12566 | if (_n == _children_capacity) { |
| 12567 | _children_capacity *= 2; |
| 12568 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12569 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12570 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12571 | return NULL; |
| 12572 | } |
| 12573 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12574 | _children[_n++] = _res; |
| 12575 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12576 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12577 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12578 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12579 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12580 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12581 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12582 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12583 | return NULL; |
| 12584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12585 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12586 | PyMem_Free(_children); |
| 12587 | _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq); |
| 12588 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12589 | } |
| 12590 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12591 | // _gather_35: dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12592 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12593 | _gather_35_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12594 | { |
| 12595 | if (p->error_indicator) { |
| 12596 | return NULL; |
| 12597 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12598 | asdl_seq * _res = NULL; |
| 12599 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12600 | { // dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12601 | alias_ty elem; |
| 12602 | asdl_seq * seq; |
| 12603 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12604 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12605 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12606 | (seq = _loop0_36_rule(p)) // _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12607 | ) |
| 12608 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12609 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12610 | goto done; |
| 12611 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12612 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12613 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12614 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12615 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12616 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12617 | } |
| 12618 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12619 | // _tmp_37: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12620 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12621 | _tmp_37_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12622 | { |
| 12623 | if (p->error_indicator) { |
| 12624 | return NULL; |
| 12625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12626 | void * _res = NULL; |
| 12627 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12628 | { // 'as' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12629 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12630 | expr_ty z; |
| 12631 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12632 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12633 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12634 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12635 | ) |
| 12636 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12637 | _res = z; |
| 12638 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12639 | p->error_indicator = 1; |
| 12640 | return NULL; |
| 12641 | } |
| 12642 | goto done; |
| 12643 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12644 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12645 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12646 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12647 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12648 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12649 | } |
| 12650 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12651 | // _loop0_39: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12652 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12653 | _loop0_39_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12654 | { |
| 12655 | if (p->error_indicator) { |
| 12656 | return NULL; |
| 12657 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12658 | void *_res = NULL; |
| 12659 | int _mark = p->mark; |
| 12660 | int _start_mark = p->mark; |
| 12661 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12662 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12663 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12664 | return NULL; |
| 12665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12666 | ssize_t _children_capacity = 1; |
| 12667 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12668 | { // ',' with_item |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12669 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12670 | withitem_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12671 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12672 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12673 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12674 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12675 | ) |
| 12676 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12677 | _res = elem; |
| 12678 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12679 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12680 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12681 | return NULL; |
| 12682 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12683 | if (_n == _children_capacity) { |
| 12684 | _children_capacity *= 2; |
| 12685 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12686 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12687 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12688 | return NULL; |
| 12689 | } |
| 12690 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12691 | _children[_n++] = _res; |
| 12692 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12693 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12694 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12695 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12696 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12697 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12698 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12699 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12700 | return NULL; |
| 12701 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12702 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12703 | PyMem_Free(_children); |
| 12704 | _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq); |
| 12705 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12706 | } |
| 12707 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12708 | // _gather_38: with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12709 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12710 | _gather_38_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12711 | { |
| 12712 | if (p->error_indicator) { |
| 12713 | return NULL; |
| 12714 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12715 | asdl_seq * _res = NULL; |
| 12716 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12717 | { // with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12718 | withitem_ty elem; |
| 12719 | asdl_seq * seq; |
| 12720 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12721 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12722 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12723 | (seq = _loop0_39_rule(p)) // _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12724 | ) |
| 12725 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12726 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12727 | goto done; |
| 12728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12729 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12730 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12731 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12732 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12733 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12734 | } |
| 12735 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12736 | // _loop0_41: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12737 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12738 | _loop0_41_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12739 | { |
| 12740 | if (p->error_indicator) { |
| 12741 | return NULL; |
| 12742 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12743 | void *_res = NULL; |
| 12744 | int _mark = p->mark; |
| 12745 | int _start_mark = p->mark; |
| 12746 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12747 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12748 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12749 | return NULL; |
| 12750 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12751 | ssize_t _children_capacity = 1; |
| 12752 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12753 | { // ',' with_item |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12754 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12755 | withitem_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12756 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12757 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12758 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12759 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12760 | ) |
| 12761 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12762 | _res = elem; |
| 12763 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12764 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12765 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12766 | return NULL; |
| 12767 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12768 | if (_n == _children_capacity) { |
| 12769 | _children_capacity *= 2; |
| 12770 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12771 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12772 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12773 | return NULL; |
| 12774 | } |
| 12775 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12776 | _children[_n++] = _res; |
| 12777 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12779 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12780 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12781 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12782 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12783 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12784 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12785 | return NULL; |
| 12786 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12787 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12788 | PyMem_Free(_children); |
| 12789 | _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq); |
| 12790 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12791 | } |
| 12792 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12793 | // _gather_40: with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12794 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12795 | _gather_40_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12796 | { |
| 12797 | if (p->error_indicator) { |
| 12798 | return NULL; |
| 12799 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12800 | asdl_seq * _res = NULL; |
| 12801 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12802 | { // with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12803 | withitem_ty elem; |
| 12804 | asdl_seq * seq; |
| 12805 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12806 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12807 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12808 | (seq = _loop0_41_rule(p)) // _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12809 | ) |
| 12810 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12811 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12812 | goto done; |
| 12813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12814 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12816 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12817 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12818 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12819 | } |
| 12820 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12821 | // _loop0_43: ',' with_item |
| 12822 | static asdl_seq * |
| 12823 | _loop0_43_rule(Parser *p) |
| 12824 | { |
| 12825 | if (p->error_indicator) { |
| 12826 | return NULL; |
| 12827 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12828 | void *_res = NULL; |
| 12829 | int _mark = p->mark; |
| 12830 | int _start_mark = p->mark; |
| 12831 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12832 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12833 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12834 | return NULL; |
| 12835 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12836 | ssize_t _children_capacity = 1; |
| 12837 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12838 | { // ',' with_item |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12839 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12840 | withitem_ty elem; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12841 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12842 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12843 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12844 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12845 | ) |
| 12846 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12847 | _res = elem; |
| 12848 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12849 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12850 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12851 | return NULL; |
| 12852 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12853 | if (_n == _children_capacity) { |
| 12854 | _children_capacity *= 2; |
| 12855 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12856 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12857 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12858 | return NULL; |
| 12859 | } |
| 12860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12861 | _children[_n++] = _res; |
| 12862 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12863 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12864 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12865 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12866 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12867 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12868 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12869 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12870 | return NULL; |
| 12871 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12872 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12873 | PyMem_Free(_children); |
| 12874 | _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq); |
| 12875 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12876 | } |
| 12877 | |
| 12878 | // _gather_42: with_item _loop0_43 |
| 12879 | static asdl_seq * |
| 12880 | _gather_42_rule(Parser *p) |
| 12881 | { |
| 12882 | if (p->error_indicator) { |
| 12883 | return NULL; |
| 12884 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12885 | asdl_seq * _res = NULL; |
| 12886 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12887 | { // with_item _loop0_43 |
| 12888 | withitem_ty elem; |
| 12889 | asdl_seq * seq; |
| 12890 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12891 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12892 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12893 | (seq = _loop0_43_rule(p)) // _loop0_43 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12894 | ) |
| 12895 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12896 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12897 | goto done; |
| 12898 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12899 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12901 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12902 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12903 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12904 | } |
| 12905 | |
| 12906 | // _loop0_45: ',' with_item |
| 12907 | static asdl_seq * |
| 12908 | _loop0_45_rule(Parser *p) |
| 12909 | { |
| 12910 | if (p->error_indicator) { |
| 12911 | return NULL; |
| 12912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12913 | void *_res = NULL; |
| 12914 | int _mark = p->mark; |
| 12915 | int _start_mark = p->mark; |
| 12916 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12917 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12918 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12919 | return NULL; |
| 12920 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12921 | ssize_t _children_capacity = 1; |
| 12922 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12923 | { // ',' with_item |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12924 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12925 | withitem_ty elem; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12926 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12927 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12928 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12929 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12930 | ) |
| 12931 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12932 | _res = elem; |
| 12933 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12934 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12935 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12936 | return NULL; |
| 12937 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12938 | if (_n == _children_capacity) { |
| 12939 | _children_capacity *= 2; |
| 12940 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12941 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12942 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12943 | return NULL; |
| 12944 | } |
| 12945 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12946 | _children[_n++] = _res; |
| 12947 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12949 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12950 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12951 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12952 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12953 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12954 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12955 | return NULL; |
| 12956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12957 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12958 | PyMem_Free(_children); |
| 12959 | _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq); |
| 12960 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12961 | } |
| 12962 | |
| 12963 | // _gather_44: with_item _loop0_45 |
| 12964 | static asdl_seq * |
| 12965 | _gather_44_rule(Parser *p) |
| 12966 | { |
| 12967 | if (p->error_indicator) { |
| 12968 | return NULL; |
| 12969 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12970 | asdl_seq * _res = NULL; |
| 12971 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12972 | { // with_item _loop0_45 |
| 12973 | withitem_ty elem; |
| 12974 | asdl_seq * seq; |
| 12975 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12976 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12977 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12978 | (seq = _loop0_45_rule(p)) // _loop0_45 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12979 | ) |
| 12980 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12981 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12982 | goto done; |
| 12983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12984 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12986 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12987 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12988 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12989 | } |
| 12990 | |
| 12991 | // _tmp_46: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12992 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12993 | _tmp_46_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12994 | { |
| 12995 | if (p->error_indicator) { |
| 12996 | return NULL; |
| 12997 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12998 | void * _res = NULL; |
| 12999 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13000 | { // 'as' target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13001 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13002 | expr_ty t; |
| 13003 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13004 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13005 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13006 | (t = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13007 | ) |
| 13008 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13009 | _res = t; |
| 13010 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13011 | p->error_indicator = 1; |
| 13012 | return NULL; |
| 13013 | } |
| 13014 | goto done; |
| 13015 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13016 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13017 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13018 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13019 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13020 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13021 | } |
| 13022 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13023 | // _loop1_47: except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13024 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13025 | _loop1_47_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13026 | { |
| 13027 | if (p->error_indicator) { |
| 13028 | return NULL; |
| 13029 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13030 | void *_res = NULL; |
| 13031 | int _mark = p->mark; |
| 13032 | int _start_mark = p->mark; |
| 13033 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13034 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13035 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13036 | return NULL; |
| 13037 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13038 | ssize_t _children_capacity = 1; |
| 13039 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13040 | { // except_block |
| 13041 | excepthandler_ty except_block_var; |
| 13042 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13043 | (except_block_var = except_block_rule(p)) // except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13044 | ) |
| 13045 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13046 | _res = except_block_var; |
| 13047 | if (_n == _children_capacity) { |
| 13048 | _children_capacity *= 2; |
| 13049 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13050 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13051 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13052 | return NULL; |
| 13053 | } |
| 13054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13055 | _children[_n++] = _res; |
| 13056 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13057 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13058 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13060 | if (_n == 0 || p->error_indicator) { |
| 13061 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13062 | return NULL; |
| 13063 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13064 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13065 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13066 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13067 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13068 | return NULL; |
| 13069 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13070 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13071 | PyMem_Free(_children); |
| 13072 | _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq); |
| 13073 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13074 | } |
| 13075 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13076 | // _tmp_48: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13077 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13078 | _tmp_48_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13079 | { |
| 13080 | if (p->error_indicator) { |
| 13081 | return NULL; |
| 13082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13083 | void * _res = NULL; |
| 13084 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13085 | { // 'as' target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13086 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13087 | expr_ty z; |
| 13088 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13089 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13090 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13091 | (z = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13092 | ) |
| 13093 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13094 | _res = z; |
| 13095 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13096 | p->error_indicator = 1; |
| 13097 | return NULL; |
| 13098 | } |
| 13099 | goto done; |
| 13100 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13101 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13102 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13103 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13104 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13105 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13106 | } |
| 13107 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13108 | // _tmp_49: 'from' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13109 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13110 | _tmp_49_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13111 | { |
| 13112 | if (p->error_indicator) { |
| 13113 | return NULL; |
| 13114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13115 | void * _res = NULL; |
| 13116 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13117 | { // 'from' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13118 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13119 | expr_ty z; |
| 13120 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13121 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13122 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13123 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13124 | ) |
| 13125 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13126 | _res = z; |
| 13127 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13128 | p->error_indicator = 1; |
| 13129 | return NULL; |
| 13130 | } |
| 13131 | goto done; |
| 13132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13133 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13134 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13135 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13136 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13137 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13138 | } |
| 13139 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13140 | // _tmp_50: '->' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13141 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13142 | _tmp_50_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13143 | { |
| 13144 | if (p->error_indicator) { |
| 13145 | return NULL; |
| 13146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13147 | void * _res = NULL; |
| 13148 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13149 | { // '->' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13150 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13151 | expr_ty z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13152 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13153 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13154 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13155 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13156 | ) |
| 13157 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13158 | _res = z; |
| 13159 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13160 | p->error_indicator = 1; |
| 13161 | return NULL; |
| 13162 | } |
| 13163 | goto done; |
| 13164 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13165 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13166 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13167 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13168 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13169 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13170 | } |
| 13171 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13172 | // _tmp_51: '->' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13173 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13174 | _tmp_51_rule(Parser *p) |
| 13175 | { |
| 13176 | if (p->error_indicator) { |
| 13177 | return NULL; |
| 13178 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13179 | void * _res = NULL; |
| 13180 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13181 | { // '->' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13182 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13183 | expr_ty z; |
| 13184 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13185 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13186 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13187 | (z = expression_rule(p)) // expression |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13188 | ) |
| 13189 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13190 | _res = z; |
| 13191 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13192 | p->error_indicator = 1; |
| 13193 | return NULL; |
| 13194 | } |
| 13195 | goto done; |
| 13196 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13197 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13198 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13199 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13200 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13201 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13202 | } |
| 13203 | |
| 13204 | // _tmp_52: NEWLINE INDENT |
| 13205 | static void * |
| 13206 | _tmp_52_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13207 | { |
| 13208 | if (p->error_indicator) { |
| 13209 | return NULL; |
| 13210 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13211 | void * _res = NULL; |
| 13212 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13213 | { // NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13214 | Token * indent_var; |
| 13215 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13216 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13217 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13218 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13219 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13220 | ) |
| 13221 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13222 | _res = _PyPegen_dummy_name(p, newline_var, indent_var); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13223 | goto done; |
| 13224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13225 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13227 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13228 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13229 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13230 | } |
| 13231 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13232 | // _loop0_53: param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13233 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13234 | _loop0_53_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13235 | { |
| 13236 | if (p->error_indicator) { |
| 13237 | return NULL; |
| 13238 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13239 | void *_res = NULL; |
| 13240 | int _mark = p->mark; |
| 13241 | int _start_mark = p->mark; |
| 13242 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13243 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13244 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13245 | return NULL; |
| 13246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13247 | ssize_t _children_capacity = 1; |
| 13248 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13249 | { // param_no_default |
| 13250 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13251 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13252 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13253 | ) |
| 13254 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13255 | _res = param_no_default_var; |
| 13256 | if (_n == _children_capacity) { |
| 13257 | _children_capacity *= 2; |
| 13258 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13259 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13260 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13261 | return NULL; |
| 13262 | } |
| 13263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13264 | _children[_n++] = _res; |
| 13265 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13266 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13267 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13268 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13269 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13270 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13271 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13272 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13273 | return NULL; |
| 13274 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13275 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13276 | PyMem_Free(_children); |
| 13277 | _PyPegen_insert_memo(p, _start_mark, _loop0_53_type, _seq); |
| 13278 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13279 | } |
| 13280 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13281 | // _loop0_54: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13282 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13283 | _loop0_54_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13284 | { |
| 13285 | if (p->error_indicator) { |
| 13286 | return NULL; |
| 13287 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13288 | void *_res = NULL; |
| 13289 | int _mark = p->mark; |
| 13290 | int _start_mark = p->mark; |
| 13291 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13292 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13293 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13294 | return NULL; |
| 13295 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13296 | ssize_t _children_capacity = 1; |
| 13297 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13298 | { // param_with_default |
| 13299 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13300 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13301 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13302 | ) |
| 13303 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13304 | _res = param_with_default_var; |
| 13305 | if (_n == _children_capacity) { |
| 13306 | _children_capacity *= 2; |
| 13307 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13308 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13309 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13310 | return NULL; |
| 13311 | } |
| 13312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13313 | _children[_n++] = _res; |
| 13314 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13315 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13316 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13317 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13318 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13319 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13320 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13321 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13322 | return NULL; |
| 13323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13324 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13325 | PyMem_Free(_children); |
| 13326 | _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq); |
| 13327 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13328 | } |
| 13329 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13330 | // _loop0_55: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13331 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13332 | _loop0_55_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13333 | { |
| 13334 | if (p->error_indicator) { |
| 13335 | return NULL; |
| 13336 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13337 | void *_res = NULL; |
| 13338 | int _mark = p->mark; |
| 13339 | int _start_mark = p->mark; |
| 13340 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13341 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13342 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13343 | return NULL; |
| 13344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13345 | ssize_t _children_capacity = 1; |
| 13346 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13347 | { // param_with_default |
| 13348 | NameDefaultPair* param_with_default_var; |
| 13349 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13350 | (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] | 13351 | ) |
| 13352 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13353 | _res = param_with_default_var; |
| 13354 | if (_n == _children_capacity) { |
| 13355 | _children_capacity *= 2; |
| 13356 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13357 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13358 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13359 | return NULL; |
| 13360 | } |
| 13361 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13362 | _children[_n++] = _res; |
| 13363 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13364 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13365 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13366 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13367 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13368 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13369 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13370 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13371 | return NULL; |
| 13372 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13373 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13374 | PyMem_Free(_children); |
| 13375 | _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); |
| 13376 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13377 | } |
| 13378 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13379 | // _loop1_56: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13380 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13381 | _loop1_56_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13382 | { |
| 13383 | if (p->error_indicator) { |
| 13384 | return NULL; |
| 13385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13386 | void *_res = NULL; |
| 13387 | int _mark = p->mark; |
| 13388 | int _start_mark = p->mark; |
| 13389 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13390 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13391 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13392 | return NULL; |
| 13393 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13394 | ssize_t _children_capacity = 1; |
| 13395 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13396 | { // param_no_default |
| 13397 | arg_ty param_no_default_var; |
| 13398 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13399 | (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] | 13400 | ) |
| 13401 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13402 | _res = param_no_default_var; |
| 13403 | if (_n == _children_capacity) { |
| 13404 | _children_capacity *= 2; |
| 13405 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13406 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13407 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13408 | return NULL; |
| 13409 | } |
| 13410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13411 | _children[_n++] = _res; |
| 13412 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13413 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13414 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13415 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13416 | if (_n == 0 || p->error_indicator) { |
| 13417 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13418 | return NULL; |
| 13419 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13420 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13421 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13422 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13423 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13424 | return NULL; |
| 13425 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13426 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13427 | PyMem_Free(_children); |
| 13428 | _PyPegen_insert_memo(p, _start_mark, _loop1_56_type, _seq); |
| 13429 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13430 | } |
| 13431 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13432 | // _loop0_57: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13433 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13434 | _loop0_57_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13435 | { |
| 13436 | if (p->error_indicator) { |
| 13437 | return NULL; |
| 13438 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13439 | void *_res = NULL; |
| 13440 | int _mark = p->mark; |
| 13441 | int _start_mark = p->mark; |
| 13442 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13443 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13444 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13445 | return NULL; |
| 13446 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13447 | ssize_t _children_capacity = 1; |
| 13448 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13449 | { // param_with_default |
| 13450 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13451 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13452 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13453 | ) |
| 13454 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13455 | _res = param_with_default_var; |
| 13456 | if (_n == _children_capacity) { |
| 13457 | _children_capacity *= 2; |
| 13458 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13459 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13460 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13461 | return NULL; |
| 13462 | } |
| 13463 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13464 | _children[_n++] = _res; |
| 13465 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13467 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13468 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13469 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13470 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13471 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13472 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13473 | return NULL; |
| 13474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13475 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13476 | PyMem_Free(_children); |
| 13477 | _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); |
| 13478 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13479 | } |
| 13480 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13481 | // _loop1_58: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13482 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13483 | _loop1_58_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13484 | { |
| 13485 | if (p->error_indicator) { |
| 13486 | return NULL; |
| 13487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13488 | void *_res = NULL; |
| 13489 | int _mark = p->mark; |
| 13490 | int _start_mark = p->mark; |
| 13491 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13492 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13493 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13494 | return NULL; |
| 13495 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13496 | ssize_t _children_capacity = 1; |
| 13497 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13498 | { // param_with_default |
| 13499 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13500 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13501 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13502 | ) |
| 13503 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13504 | _res = param_with_default_var; |
| 13505 | if (_n == _children_capacity) { |
| 13506 | _children_capacity *= 2; |
| 13507 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13508 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13509 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13510 | return NULL; |
| 13511 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13512 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13513 | _children[_n++] = _res; |
| 13514 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13516 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13517 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13518 | if (_n == 0 || p->error_indicator) { |
| 13519 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13520 | return NULL; |
| 13521 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13522 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13523 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13524 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13525 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13526 | return NULL; |
| 13527 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13528 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13529 | PyMem_Free(_children); |
| 13530 | _PyPegen_insert_memo(p, _start_mark, _loop1_58_type, _seq); |
| 13531 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13532 | } |
| 13533 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13534 | // _loop1_59: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13535 | static asdl_seq * |
| 13536 | _loop1_59_rule(Parser *p) |
| 13537 | { |
| 13538 | if (p->error_indicator) { |
| 13539 | return NULL; |
| 13540 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13541 | void *_res = NULL; |
| 13542 | int _mark = p->mark; |
| 13543 | int _start_mark = p->mark; |
| 13544 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13545 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13546 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13547 | return NULL; |
| 13548 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13549 | ssize_t _children_capacity = 1; |
| 13550 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13551 | { // param_no_default |
| 13552 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13553 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13554 | (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] | 13555 | ) |
| 13556 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13557 | _res = param_no_default_var; |
| 13558 | if (_n == _children_capacity) { |
| 13559 | _children_capacity *= 2; |
| 13560 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13561 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13562 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13563 | return NULL; |
| 13564 | } |
| 13565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13566 | _children[_n++] = _res; |
| 13567 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13568 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13569 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13570 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13571 | if (_n == 0 || p->error_indicator) { |
| 13572 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13573 | return NULL; |
| 13574 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13575 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13576 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13577 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13578 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13579 | return NULL; |
| 13580 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13581 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13582 | PyMem_Free(_children); |
| 13583 | _PyPegen_insert_memo(p, _start_mark, _loop1_59_type, _seq); |
| 13584 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13585 | } |
| 13586 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13587 | // _loop1_60: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13588 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13589 | _loop1_60_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13590 | { |
| 13591 | if (p->error_indicator) { |
| 13592 | return NULL; |
| 13593 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13594 | void *_res = NULL; |
| 13595 | int _mark = p->mark; |
| 13596 | int _start_mark = p->mark; |
| 13597 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13598 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13599 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13600 | return NULL; |
| 13601 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13602 | ssize_t _children_capacity = 1; |
| 13603 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13604 | { // param_no_default |
| 13605 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13606 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13607 | (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] | 13608 | ) |
| 13609 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13610 | _res = param_no_default_var; |
| 13611 | if (_n == _children_capacity) { |
| 13612 | _children_capacity *= 2; |
| 13613 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13614 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13615 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13616 | return NULL; |
| 13617 | } |
| 13618 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13619 | _children[_n++] = _res; |
| 13620 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13621 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13622 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13623 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13624 | if (_n == 0 || p->error_indicator) { |
| 13625 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13626 | return NULL; |
| 13627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13628 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13629 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13630 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13631 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13632 | return NULL; |
| 13633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13634 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13635 | PyMem_Free(_children); |
| 13636 | _PyPegen_insert_memo(p, _start_mark, _loop1_60_type, _seq); |
| 13637 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13638 | } |
| 13639 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13640 | // _loop0_61: param_no_default |
| 13641 | static asdl_seq * |
| 13642 | _loop0_61_rule(Parser *p) |
| 13643 | { |
| 13644 | if (p->error_indicator) { |
| 13645 | return NULL; |
| 13646 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13647 | void *_res = NULL; |
| 13648 | int _mark = p->mark; |
| 13649 | int _start_mark = p->mark; |
| 13650 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13651 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13652 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13653 | return NULL; |
| 13654 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13655 | ssize_t _children_capacity = 1; |
| 13656 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13657 | { // param_no_default |
| 13658 | arg_ty param_no_default_var; |
| 13659 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13660 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13661 | ) |
| 13662 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13663 | _res = param_no_default_var; |
| 13664 | if (_n == _children_capacity) { |
| 13665 | _children_capacity *= 2; |
| 13666 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13667 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13668 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13669 | return NULL; |
| 13670 | } |
| 13671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13672 | _children[_n++] = _res; |
| 13673 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13674 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13675 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13677 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13678 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13679 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13680 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13681 | return NULL; |
| 13682 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13683 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13684 | PyMem_Free(_children); |
| 13685 | _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); |
| 13686 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13687 | } |
| 13688 | |
| 13689 | // _loop1_62: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13690 | static asdl_seq * |
| 13691 | _loop1_62_rule(Parser *p) |
| 13692 | { |
| 13693 | if (p->error_indicator) { |
| 13694 | return NULL; |
| 13695 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13696 | void *_res = NULL; |
| 13697 | int _mark = p->mark; |
| 13698 | int _start_mark = p->mark; |
| 13699 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13700 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13701 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13702 | return NULL; |
| 13703 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13704 | ssize_t _children_capacity = 1; |
| 13705 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13706 | { // param_with_default |
| 13707 | NameDefaultPair* param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13708 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13709 | (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] | 13710 | ) |
| 13711 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13712 | _res = param_with_default_var; |
| 13713 | if (_n == _children_capacity) { |
| 13714 | _children_capacity *= 2; |
| 13715 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13716 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13717 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13718 | return NULL; |
| 13719 | } |
| 13720 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13721 | _children[_n++] = _res; |
| 13722 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13723 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13724 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13725 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13726 | if (_n == 0 || p->error_indicator) { |
| 13727 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13728 | return NULL; |
| 13729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13730 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13731 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13732 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13733 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13734 | return NULL; |
| 13735 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13736 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13737 | PyMem_Free(_children); |
| 13738 | _PyPegen_insert_memo(p, _start_mark, _loop1_62_type, _seq); |
| 13739 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13740 | } |
| 13741 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13742 | // _loop0_63: param_no_default |
| 13743 | static asdl_seq * |
| 13744 | _loop0_63_rule(Parser *p) |
| 13745 | { |
| 13746 | if (p->error_indicator) { |
| 13747 | return NULL; |
| 13748 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13749 | void *_res = NULL; |
| 13750 | int _mark = p->mark; |
| 13751 | int _start_mark = p->mark; |
| 13752 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13753 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13754 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13755 | return NULL; |
| 13756 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13757 | ssize_t _children_capacity = 1; |
| 13758 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13759 | { // param_no_default |
| 13760 | arg_ty param_no_default_var; |
| 13761 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13762 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13763 | ) |
| 13764 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13765 | _res = param_no_default_var; |
| 13766 | if (_n == _children_capacity) { |
| 13767 | _children_capacity *= 2; |
| 13768 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13769 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13770 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13771 | return NULL; |
| 13772 | } |
| 13773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13774 | _children[_n++] = _res; |
| 13775 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13777 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13779 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13780 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13781 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13782 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13783 | return NULL; |
| 13784 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13785 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13786 | PyMem_Free(_children); |
| 13787 | _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); |
| 13788 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13789 | } |
| 13790 | |
| 13791 | // _loop1_64: param_with_default |
| 13792 | static asdl_seq * |
| 13793 | _loop1_64_rule(Parser *p) |
| 13794 | { |
| 13795 | if (p->error_indicator) { |
| 13796 | return NULL; |
| 13797 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13798 | void *_res = NULL; |
| 13799 | int _mark = p->mark; |
| 13800 | int _start_mark = p->mark; |
| 13801 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13802 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13803 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13804 | return NULL; |
| 13805 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13806 | ssize_t _children_capacity = 1; |
| 13807 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13808 | { // param_with_default |
| 13809 | NameDefaultPair* param_with_default_var; |
| 13810 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13811 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13812 | ) |
| 13813 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13814 | _res = param_with_default_var; |
| 13815 | if (_n == _children_capacity) { |
| 13816 | _children_capacity *= 2; |
| 13817 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13818 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13819 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13820 | return NULL; |
| 13821 | } |
| 13822 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13823 | _children[_n++] = _res; |
| 13824 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13825 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13826 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13827 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13828 | if (_n == 0 || p->error_indicator) { |
| 13829 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13830 | return NULL; |
| 13831 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13832 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13833 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13834 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13835 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13836 | return NULL; |
| 13837 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13838 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13839 | PyMem_Free(_children); |
| 13840 | _PyPegen_insert_memo(p, _start_mark, _loop1_64_type, _seq); |
| 13841 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13842 | } |
| 13843 | |
| 13844 | // _loop0_65: param_maybe_default |
| 13845 | static asdl_seq * |
| 13846 | _loop0_65_rule(Parser *p) |
| 13847 | { |
| 13848 | if (p->error_indicator) { |
| 13849 | return NULL; |
| 13850 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13851 | void *_res = NULL; |
| 13852 | int _mark = p->mark; |
| 13853 | int _start_mark = p->mark; |
| 13854 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13855 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13856 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13857 | return NULL; |
| 13858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13859 | ssize_t _children_capacity = 1; |
| 13860 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13861 | { // param_maybe_default |
| 13862 | NameDefaultPair* param_maybe_default_var; |
| 13863 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13864 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13865 | ) |
| 13866 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13867 | _res = param_maybe_default_var; |
| 13868 | if (_n == _children_capacity) { |
| 13869 | _children_capacity *= 2; |
| 13870 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13871 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13872 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13873 | return NULL; |
| 13874 | } |
| 13875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13876 | _children[_n++] = _res; |
| 13877 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13879 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13881 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13882 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13883 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13884 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13885 | return NULL; |
| 13886 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13887 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13888 | PyMem_Free(_children); |
| 13889 | _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); |
| 13890 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13891 | } |
| 13892 | |
| 13893 | // _loop1_66: param_maybe_default |
| 13894 | static asdl_seq * |
| 13895 | _loop1_66_rule(Parser *p) |
| 13896 | { |
| 13897 | if (p->error_indicator) { |
| 13898 | return NULL; |
| 13899 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13900 | void *_res = NULL; |
| 13901 | int _mark = p->mark; |
| 13902 | int _start_mark = p->mark; |
| 13903 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13904 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13905 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13906 | return NULL; |
| 13907 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13908 | ssize_t _children_capacity = 1; |
| 13909 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13910 | { // param_maybe_default |
| 13911 | NameDefaultPair* param_maybe_default_var; |
| 13912 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13913 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13914 | ) |
| 13915 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13916 | _res = param_maybe_default_var; |
| 13917 | if (_n == _children_capacity) { |
| 13918 | _children_capacity *= 2; |
| 13919 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13920 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13921 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13922 | return NULL; |
| 13923 | } |
| 13924 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13925 | _children[_n++] = _res; |
| 13926 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13927 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13928 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13929 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13930 | if (_n == 0 || p->error_indicator) { |
| 13931 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13932 | return NULL; |
| 13933 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13934 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13935 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13936 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13937 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13938 | return NULL; |
| 13939 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13940 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13941 | PyMem_Free(_children); |
| 13942 | _PyPegen_insert_memo(p, _start_mark, _loop1_66_type, _seq); |
| 13943 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13944 | } |
| 13945 | |
| 13946 | // _loop1_67: ('@' named_expression NEWLINE) |
| 13947 | static asdl_seq * |
| 13948 | _loop1_67_rule(Parser *p) |
| 13949 | { |
| 13950 | if (p->error_indicator) { |
| 13951 | return NULL; |
| 13952 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13953 | void *_res = NULL; |
| 13954 | int _mark = p->mark; |
| 13955 | int _start_mark = p->mark; |
| 13956 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13957 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13958 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13959 | return NULL; |
| 13960 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13961 | ssize_t _children_capacity = 1; |
| 13962 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13963 | { // ('@' named_expression NEWLINE) |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13964 | void *_tmp_138_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13965 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13966 | (_tmp_138_var = _tmp_138_rule(p)) // '@' named_expression NEWLINE |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13967 | ) |
| 13968 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13969 | _res = _tmp_138_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13970 | if (_n == _children_capacity) { |
| 13971 | _children_capacity *= 2; |
| 13972 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13973 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13974 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13975 | return NULL; |
| 13976 | } |
| 13977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13978 | _children[_n++] = _res; |
| 13979 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13980 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13981 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13983 | if (_n == 0 || p->error_indicator) { |
| 13984 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13985 | return NULL; |
| 13986 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13987 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13988 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13989 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13990 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13991 | return NULL; |
| 13992 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13993 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13994 | PyMem_Free(_children); |
| 13995 | _PyPegen_insert_memo(p, _start_mark, _loop1_67_type, _seq); |
| 13996 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13997 | } |
| 13998 | |
| 13999 | // _tmp_68: '(' arguments? ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14000 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14001 | _tmp_68_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14002 | { |
| 14003 | if (p->error_indicator) { |
| 14004 | return NULL; |
| 14005 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14006 | void * _res = NULL; |
| 14007 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14008 | { // '(' arguments? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14009 | Token * _literal; |
| 14010 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14011 | void *z; |
| 14012 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14013 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14014 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14015 | (z = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14016 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14017 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14018 | ) |
| 14019 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14020 | _res = z; |
| 14021 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14022 | p->error_indicator = 1; |
| 14023 | return NULL; |
| 14024 | } |
| 14025 | goto done; |
| 14026 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14027 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14028 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14029 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14030 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14031 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14032 | } |
| 14033 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14034 | // _loop0_70: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14035 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14036 | _loop0_70_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14037 | { |
| 14038 | if (p->error_indicator) { |
| 14039 | return NULL; |
| 14040 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14041 | void *_res = NULL; |
| 14042 | int _mark = p->mark; |
| 14043 | int _start_mark = p->mark; |
| 14044 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14045 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14046 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14047 | return NULL; |
| 14048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14049 | ssize_t _children_capacity = 1; |
| 14050 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14051 | { // ',' star_expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14052 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14053 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14054 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14055 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14056 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14057 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14058 | ) |
| 14059 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14060 | _res = elem; |
| 14061 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14062 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14063 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14064 | return NULL; |
| 14065 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14066 | if (_n == _children_capacity) { |
| 14067 | _children_capacity *= 2; |
| 14068 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14069 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14070 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14071 | return NULL; |
| 14072 | } |
| 14073 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14074 | _children[_n++] = _res; |
| 14075 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14076 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14077 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14079 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14080 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14081 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14082 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14083 | return NULL; |
| 14084 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14085 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14086 | PyMem_Free(_children); |
| 14087 | _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); |
| 14088 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14089 | } |
| 14090 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14091 | // _gather_69: star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14092 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14093 | _gather_69_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14094 | { |
| 14095 | if (p->error_indicator) { |
| 14096 | return NULL; |
| 14097 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14098 | asdl_seq * _res = NULL; |
| 14099 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14100 | { // star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14101 | expr_ty elem; |
| 14102 | asdl_seq * seq; |
| 14103 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14104 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14105 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14106 | (seq = _loop0_70_rule(p)) // _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14107 | ) |
| 14108 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14109 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14110 | goto done; |
| 14111 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14112 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14113 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14114 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14115 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14116 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14117 | } |
| 14118 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14119 | // _loop1_71: (',' star_expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14120 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14121 | _loop1_71_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14122 | { |
| 14123 | if (p->error_indicator) { |
| 14124 | return NULL; |
| 14125 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14126 | void *_res = NULL; |
| 14127 | int _mark = p->mark; |
| 14128 | int _start_mark = p->mark; |
| 14129 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14130 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14131 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14132 | return NULL; |
| 14133 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14134 | ssize_t _children_capacity = 1; |
| 14135 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14136 | { // (',' star_expression) |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14137 | void *_tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14138 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14139 | (_tmp_139_var = _tmp_139_rule(p)) // ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14140 | ) |
| 14141 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14142 | _res = _tmp_139_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14143 | if (_n == _children_capacity) { |
| 14144 | _children_capacity *= 2; |
| 14145 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14146 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14147 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14148 | return NULL; |
| 14149 | } |
| 14150 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14151 | _children[_n++] = _res; |
| 14152 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14153 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14154 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14155 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14156 | if (_n == 0 || p->error_indicator) { |
| 14157 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14158 | return NULL; |
| 14159 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14160 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14161 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14162 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14163 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14164 | return NULL; |
| 14165 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14166 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14167 | PyMem_Free(_children); |
| 14168 | _PyPegen_insert_memo(p, _start_mark, _loop1_71_type, _seq); |
| 14169 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14170 | } |
| 14171 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14172 | // _loop0_73: ',' star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14173 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14174 | _loop0_73_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14175 | { |
| 14176 | if (p->error_indicator) { |
| 14177 | return NULL; |
| 14178 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14179 | void *_res = NULL; |
| 14180 | int _mark = p->mark; |
| 14181 | int _start_mark = p->mark; |
| 14182 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14183 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14184 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14185 | return NULL; |
| 14186 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14187 | ssize_t _children_capacity = 1; |
| 14188 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14189 | { // ',' star_named_expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14190 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14191 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14192 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14193 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14194 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14195 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14196 | ) |
| 14197 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14198 | _res = elem; |
| 14199 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14200 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14201 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14202 | return NULL; |
| 14203 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14204 | if (_n == _children_capacity) { |
| 14205 | _children_capacity *= 2; |
| 14206 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14207 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14208 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14209 | return NULL; |
| 14210 | } |
| 14211 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14212 | _children[_n++] = _res; |
| 14213 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14214 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14215 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14217 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14218 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14219 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14220 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14221 | return NULL; |
| 14222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14223 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14224 | PyMem_Free(_children); |
| 14225 | _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); |
| 14226 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14227 | } |
| 14228 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14229 | // _gather_72: star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14230 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14231 | _gather_72_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14232 | { |
| 14233 | if (p->error_indicator) { |
| 14234 | return NULL; |
| 14235 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14236 | asdl_seq * _res = NULL; |
| 14237 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14238 | { // star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14239 | expr_ty elem; |
| 14240 | asdl_seq * seq; |
| 14241 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14242 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14243 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14244 | (seq = _loop0_73_rule(p)) // _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14245 | ) |
| 14246 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14247 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14248 | goto done; |
| 14249 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14250 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14252 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14253 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14254 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14255 | } |
| 14256 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14257 | // _loop1_74: (',' expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14258 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14259 | _loop1_74_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14260 | { |
| 14261 | if (p->error_indicator) { |
| 14262 | return NULL; |
| 14263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14264 | void *_res = NULL; |
| 14265 | int _mark = p->mark; |
| 14266 | int _start_mark = p->mark; |
| 14267 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14268 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14269 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14270 | return NULL; |
| 14271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14272 | ssize_t _children_capacity = 1; |
| 14273 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14274 | { // (',' expression) |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14275 | void *_tmp_140_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14276 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14277 | (_tmp_140_var = _tmp_140_rule(p)) // ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14278 | ) |
| 14279 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14280 | _res = _tmp_140_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14281 | if (_n == _children_capacity) { |
| 14282 | _children_capacity *= 2; |
| 14283 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14284 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14285 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14286 | return NULL; |
| 14287 | } |
| 14288 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14289 | _children[_n++] = _res; |
| 14290 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14291 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14292 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14293 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14294 | if (_n == 0 || p->error_indicator) { |
| 14295 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14296 | return NULL; |
| 14297 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14298 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14299 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14300 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14301 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14302 | return NULL; |
| 14303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14304 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14305 | PyMem_Free(_children); |
| 14306 | _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq); |
| 14307 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14308 | } |
| 14309 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14310 | // _loop0_75: lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14311 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14312 | _loop0_75_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14313 | { |
| 14314 | if (p->error_indicator) { |
| 14315 | return NULL; |
| 14316 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14317 | void *_res = NULL; |
| 14318 | int _mark = p->mark; |
| 14319 | int _start_mark = p->mark; |
| 14320 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14321 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14322 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14323 | return NULL; |
| 14324 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14325 | ssize_t _children_capacity = 1; |
| 14326 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14327 | { // lambda_param_no_default |
| 14328 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14329 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14330 | (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] | 14331 | ) |
| 14332 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14333 | _res = lambda_param_no_default_var; |
| 14334 | if (_n == _children_capacity) { |
| 14335 | _children_capacity *= 2; |
| 14336 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14337 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14338 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14339 | return NULL; |
| 14340 | } |
| 14341 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14342 | _children[_n++] = _res; |
| 14343 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14345 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14347 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14348 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14349 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14350 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14351 | return NULL; |
| 14352 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14353 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14354 | PyMem_Free(_children); |
| 14355 | _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq); |
| 14356 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14357 | } |
| 14358 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14359 | // _loop0_76: lambda_param_with_default |
| 14360 | static asdl_seq * |
| 14361 | _loop0_76_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14362 | { |
| 14363 | if (p->error_indicator) { |
| 14364 | return NULL; |
| 14365 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14366 | void *_res = NULL; |
| 14367 | int _mark = p->mark; |
| 14368 | int _start_mark = p->mark; |
| 14369 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14370 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14371 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14372 | return NULL; |
| 14373 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14374 | ssize_t _children_capacity = 1; |
| 14375 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14376 | { // lambda_param_with_default |
| 14377 | NameDefaultPair* lambda_param_with_default_var; |
| 14378 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14379 | (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] | 14380 | ) |
| 14381 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14382 | _res = lambda_param_with_default_var; |
| 14383 | if (_n == _children_capacity) { |
| 14384 | _children_capacity *= 2; |
| 14385 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14386 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14387 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14388 | return NULL; |
| 14389 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14391 | _children[_n++] = _res; |
| 14392 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14393 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14394 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14396 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14397 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14398 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14399 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14400 | return NULL; |
| 14401 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14402 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14403 | PyMem_Free(_children); |
| 14404 | _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq); |
| 14405 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14406 | } |
| 14407 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14408 | // _loop0_77: lambda_param_with_default |
| 14409 | static asdl_seq * |
| 14410 | _loop0_77_rule(Parser *p) |
| 14411 | { |
| 14412 | if (p->error_indicator) { |
| 14413 | return NULL; |
| 14414 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14415 | void *_res = NULL; |
| 14416 | int _mark = p->mark; |
| 14417 | int _start_mark = p->mark; |
| 14418 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14419 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14420 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14421 | return NULL; |
| 14422 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14423 | ssize_t _children_capacity = 1; |
| 14424 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14425 | { // lambda_param_with_default |
| 14426 | NameDefaultPair* lambda_param_with_default_var; |
| 14427 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14428 | (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] | 14429 | ) |
| 14430 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14431 | _res = lambda_param_with_default_var; |
| 14432 | if (_n == _children_capacity) { |
| 14433 | _children_capacity *= 2; |
| 14434 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14435 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14436 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14437 | return NULL; |
| 14438 | } |
| 14439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14440 | _children[_n++] = _res; |
| 14441 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14443 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14444 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14445 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14446 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14447 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14448 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14449 | return NULL; |
| 14450 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14451 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14452 | PyMem_Free(_children); |
| 14453 | _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); |
| 14454 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14455 | } |
| 14456 | |
| 14457 | // _loop1_78: lambda_param_no_default |
| 14458 | static asdl_seq * |
| 14459 | _loop1_78_rule(Parser *p) |
| 14460 | { |
| 14461 | if (p->error_indicator) { |
| 14462 | return NULL; |
| 14463 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14464 | void *_res = NULL; |
| 14465 | int _mark = p->mark; |
| 14466 | int _start_mark = p->mark; |
| 14467 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14468 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14469 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14470 | return NULL; |
| 14471 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14472 | ssize_t _children_capacity = 1; |
| 14473 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14474 | { // lambda_param_no_default |
| 14475 | arg_ty lambda_param_no_default_var; |
| 14476 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14477 | (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] | 14478 | ) |
| 14479 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14480 | _res = lambda_param_no_default_var; |
| 14481 | if (_n == _children_capacity) { |
| 14482 | _children_capacity *= 2; |
| 14483 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14484 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14485 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14486 | return NULL; |
| 14487 | } |
| 14488 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14489 | _children[_n++] = _res; |
| 14490 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14491 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14492 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14493 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14494 | if (_n == 0 || p->error_indicator) { |
| 14495 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14496 | return NULL; |
| 14497 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14498 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14499 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14500 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14501 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14502 | return NULL; |
| 14503 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14504 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14505 | PyMem_Free(_children); |
| 14506 | _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq); |
| 14507 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14508 | } |
| 14509 | |
| 14510 | // _loop0_79: lambda_param_with_default |
| 14511 | static asdl_seq * |
| 14512 | _loop0_79_rule(Parser *p) |
| 14513 | { |
| 14514 | if (p->error_indicator) { |
| 14515 | return NULL; |
| 14516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14517 | void *_res = NULL; |
| 14518 | int _mark = p->mark; |
| 14519 | int _start_mark = p->mark; |
| 14520 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14521 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14522 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14523 | return NULL; |
| 14524 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14525 | ssize_t _children_capacity = 1; |
| 14526 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14527 | { // lambda_param_with_default |
| 14528 | NameDefaultPair* lambda_param_with_default_var; |
| 14529 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14530 | (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] | 14531 | ) |
| 14532 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14533 | _res = lambda_param_with_default_var; |
| 14534 | if (_n == _children_capacity) { |
| 14535 | _children_capacity *= 2; |
| 14536 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14537 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14538 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14539 | return NULL; |
| 14540 | } |
| 14541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14542 | _children[_n++] = _res; |
| 14543 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14544 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14545 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14546 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14547 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14548 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14549 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14550 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14551 | return NULL; |
| 14552 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14553 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14554 | PyMem_Free(_children); |
| 14555 | _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); |
| 14556 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14557 | } |
| 14558 | |
| 14559 | // _loop1_80: lambda_param_with_default |
| 14560 | static asdl_seq * |
| 14561 | _loop1_80_rule(Parser *p) |
| 14562 | { |
| 14563 | if (p->error_indicator) { |
| 14564 | return NULL; |
| 14565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14566 | void *_res = NULL; |
| 14567 | int _mark = p->mark; |
| 14568 | int _start_mark = p->mark; |
| 14569 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14570 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14571 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14572 | return NULL; |
| 14573 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14574 | ssize_t _children_capacity = 1; |
| 14575 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14576 | { // lambda_param_with_default |
| 14577 | NameDefaultPair* lambda_param_with_default_var; |
| 14578 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14579 | (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] | 14580 | ) |
| 14581 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14582 | _res = lambda_param_with_default_var; |
| 14583 | if (_n == _children_capacity) { |
| 14584 | _children_capacity *= 2; |
| 14585 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14586 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14587 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14588 | return NULL; |
| 14589 | } |
| 14590 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14591 | _children[_n++] = _res; |
| 14592 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14593 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14594 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14595 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14596 | if (_n == 0 || p->error_indicator) { |
| 14597 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14598 | return NULL; |
| 14599 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14600 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14601 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14602 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14603 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14604 | return NULL; |
| 14605 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14606 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14607 | PyMem_Free(_children); |
| 14608 | _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); |
| 14609 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14610 | } |
| 14611 | |
| 14612 | // _loop1_81: lambda_param_no_default |
| 14613 | static asdl_seq * |
| 14614 | _loop1_81_rule(Parser *p) |
| 14615 | { |
| 14616 | if (p->error_indicator) { |
| 14617 | return NULL; |
| 14618 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14619 | void *_res = NULL; |
| 14620 | int _mark = p->mark; |
| 14621 | int _start_mark = p->mark; |
| 14622 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14623 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14624 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14625 | return NULL; |
| 14626 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14627 | ssize_t _children_capacity = 1; |
| 14628 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14629 | { // lambda_param_no_default |
| 14630 | arg_ty lambda_param_no_default_var; |
| 14631 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14632 | (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] | 14633 | ) |
| 14634 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14635 | _res = lambda_param_no_default_var; |
| 14636 | if (_n == _children_capacity) { |
| 14637 | _children_capacity *= 2; |
| 14638 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14639 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14640 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14641 | return NULL; |
| 14642 | } |
| 14643 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14644 | _children[_n++] = _res; |
| 14645 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14646 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14647 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14648 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14649 | if (_n == 0 || p->error_indicator) { |
| 14650 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14651 | return NULL; |
| 14652 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14653 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14654 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14655 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14656 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14657 | return NULL; |
| 14658 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14659 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14660 | PyMem_Free(_children); |
| 14661 | _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); |
| 14662 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14663 | } |
| 14664 | |
| 14665 | // _loop1_82: lambda_param_no_default |
| 14666 | static asdl_seq * |
| 14667 | _loop1_82_rule(Parser *p) |
| 14668 | { |
| 14669 | if (p->error_indicator) { |
| 14670 | return NULL; |
| 14671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14672 | void *_res = NULL; |
| 14673 | int _mark = p->mark; |
| 14674 | int _start_mark = p->mark; |
| 14675 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14676 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14677 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14678 | return NULL; |
| 14679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14680 | ssize_t _children_capacity = 1; |
| 14681 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14682 | { // lambda_param_no_default |
| 14683 | arg_ty lambda_param_no_default_var; |
| 14684 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14685 | (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] | 14686 | ) |
| 14687 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14688 | _res = lambda_param_no_default_var; |
| 14689 | if (_n == _children_capacity) { |
| 14690 | _children_capacity *= 2; |
| 14691 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14692 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14693 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14694 | return NULL; |
| 14695 | } |
| 14696 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14697 | _children[_n++] = _res; |
| 14698 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14699 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14700 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14701 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14702 | if (_n == 0 || p->error_indicator) { |
| 14703 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14704 | return NULL; |
| 14705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14706 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14707 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14708 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14709 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14710 | return NULL; |
| 14711 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14712 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14713 | PyMem_Free(_children); |
| 14714 | _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); |
| 14715 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14716 | } |
| 14717 | |
| 14718 | // _loop0_83: lambda_param_no_default |
| 14719 | static asdl_seq * |
| 14720 | _loop0_83_rule(Parser *p) |
| 14721 | { |
| 14722 | if (p->error_indicator) { |
| 14723 | return NULL; |
| 14724 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14725 | void *_res = NULL; |
| 14726 | int _mark = p->mark; |
| 14727 | int _start_mark = p->mark; |
| 14728 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14729 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14730 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14731 | return NULL; |
| 14732 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14733 | ssize_t _children_capacity = 1; |
| 14734 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14735 | { // lambda_param_no_default |
| 14736 | arg_ty lambda_param_no_default_var; |
| 14737 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14738 | (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] | 14739 | ) |
| 14740 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14741 | _res = lambda_param_no_default_var; |
| 14742 | if (_n == _children_capacity) { |
| 14743 | _children_capacity *= 2; |
| 14744 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14745 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14746 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14747 | return NULL; |
| 14748 | } |
| 14749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14750 | _children[_n++] = _res; |
| 14751 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14753 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14754 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14755 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14756 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14757 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14758 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14759 | return NULL; |
| 14760 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14761 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14762 | PyMem_Free(_children); |
| 14763 | _PyPegen_insert_memo(p, _start_mark, _loop0_83_type, _seq); |
| 14764 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14765 | } |
| 14766 | |
| 14767 | // _loop1_84: lambda_param_with_default |
| 14768 | static asdl_seq * |
| 14769 | _loop1_84_rule(Parser *p) |
| 14770 | { |
| 14771 | if (p->error_indicator) { |
| 14772 | return NULL; |
| 14773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14774 | void *_res = NULL; |
| 14775 | int _mark = p->mark; |
| 14776 | int _start_mark = p->mark; |
| 14777 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14778 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14779 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14780 | return NULL; |
| 14781 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14782 | ssize_t _children_capacity = 1; |
| 14783 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14784 | { // lambda_param_with_default |
| 14785 | NameDefaultPair* lambda_param_with_default_var; |
| 14786 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14787 | (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] | 14788 | ) |
| 14789 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14790 | _res = lambda_param_with_default_var; |
| 14791 | if (_n == _children_capacity) { |
| 14792 | _children_capacity *= 2; |
| 14793 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14794 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14795 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14796 | return NULL; |
| 14797 | } |
| 14798 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14799 | _children[_n++] = _res; |
| 14800 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14801 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14802 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14803 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14804 | if (_n == 0 || p->error_indicator) { |
| 14805 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14806 | return NULL; |
| 14807 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14808 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14809 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14810 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14811 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14812 | return NULL; |
| 14813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14814 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14815 | PyMem_Free(_children); |
| 14816 | _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); |
| 14817 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14818 | } |
| 14819 | |
| 14820 | // _loop0_85: lambda_param_no_default |
| 14821 | static asdl_seq * |
| 14822 | _loop0_85_rule(Parser *p) |
| 14823 | { |
| 14824 | if (p->error_indicator) { |
| 14825 | return NULL; |
| 14826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14827 | void *_res = NULL; |
| 14828 | int _mark = p->mark; |
| 14829 | int _start_mark = p->mark; |
| 14830 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14831 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14832 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14833 | return NULL; |
| 14834 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14835 | ssize_t _children_capacity = 1; |
| 14836 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14837 | { // lambda_param_no_default |
| 14838 | arg_ty lambda_param_no_default_var; |
| 14839 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14840 | (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] | 14841 | ) |
| 14842 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14843 | _res = lambda_param_no_default_var; |
| 14844 | if (_n == _children_capacity) { |
| 14845 | _children_capacity *= 2; |
| 14846 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14847 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14848 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14849 | return NULL; |
| 14850 | } |
| 14851 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14852 | _children[_n++] = _res; |
| 14853 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14854 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14855 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14856 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14857 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14858 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14859 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14860 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14861 | return NULL; |
| 14862 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14863 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14864 | PyMem_Free(_children); |
| 14865 | _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq); |
| 14866 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14867 | } |
| 14868 | |
| 14869 | // _loop1_86: lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14870 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14871 | _loop1_86_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14872 | { |
| 14873 | if (p->error_indicator) { |
| 14874 | return NULL; |
| 14875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14876 | void *_res = NULL; |
| 14877 | int _mark = p->mark; |
| 14878 | int _start_mark = p->mark; |
| 14879 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14880 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14881 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14882 | return NULL; |
| 14883 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14884 | ssize_t _children_capacity = 1; |
| 14885 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14886 | { // lambda_param_with_default |
| 14887 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14888 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14889 | (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] | 14890 | ) |
| 14891 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14892 | _res = lambda_param_with_default_var; |
| 14893 | if (_n == _children_capacity) { |
| 14894 | _children_capacity *= 2; |
| 14895 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14896 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14897 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14898 | return NULL; |
| 14899 | } |
| 14900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14901 | _children[_n++] = _res; |
| 14902 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14903 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14904 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14905 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14906 | if (_n == 0 || p->error_indicator) { |
| 14907 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14908 | return NULL; |
| 14909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14910 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14911 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14912 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14913 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14914 | return NULL; |
| 14915 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14916 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14917 | PyMem_Free(_children); |
| 14918 | _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); |
| 14919 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14920 | } |
| 14921 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14922 | // _loop0_87: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14923 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14924 | _loop0_87_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14925 | { |
| 14926 | if (p->error_indicator) { |
| 14927 | return NULL; |
| 14928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14929 | void *_res = NULL; |
| 14930 | int _mark = p->mark; |
| 14931 | int _start_mark = p->mark; |
| 14932 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14933 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14934 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14935 | return NULL; |
| 14936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14937 | ssize_t _children_capacity = 1; |
| 14938 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14939 | { // lambda_param_maybe_default |
| 14940 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14941 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14942 | (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] | 14943 | ) |
| 14944 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14945 | _res = lambda_param_maybe_default_var; |
| 14946 | if (_n == _children_capacity) { |
| 14947 | _children_capacity *= 2; |
| 14948 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14949 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14950 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14951 | return NULL; |
| 14952 | } |
| 14953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14954 | _children[_n++] = _res; |
| 14955 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14957 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14958 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14959 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14960 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14961 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14962 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14963 | return NULL; |
| 14964 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14965 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14966 | PyMem_Free(_children); |
| 14967 | _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq); |
| 14968 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14969 | } |
| 14970 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14971 | // _loop1_88: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14972 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14973 | _loop1_88_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14974 | { |
| 14975 | if (p->error_indicator) { |
| 14976 | return NULL; |
| 14977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14978 | void *_res = NULL; |
| 14979 | int _mark = p->mark; |
| 14980 | int _start_mark = p->mark; |
| 14981 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14982 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14983 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14984 | return NULL; |
| 14985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14986 | ssize_t _children_capacity = 1; |
| 14987 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14988 | { // lambda_param_maybe_default |
| 14989 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14990 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14991 | (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] | 14992 | ) |
| 14993 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14994 | _res = lambda_param_maybe_default_var; |
| 14995 | if (_n == _children_capacity) { |
| 14996 | _children_capacity *= 2; |
| 14997 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14998 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14999 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15000 | return NULL; |
| 15001 | } |
| 15002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15003 | _children[_n++] = _res; |
| 15004 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15005 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15006 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15007 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15008 | if (_n == 0 || p->error_indicator) { |
| 15009 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15010 | return NULL; |
| 15011 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15012 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15013 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15014 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15015 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15016 | return NULL; |
| 15017 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15018 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15019 | PyMem_Free(_children); |
| 15020 | _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); |
| 15021 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15022 | } |
| 15023 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15024 | // _loop1_89: ('or' conjunction) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15025 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15026 | _loop1_89_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15027 | { |
| 15028 | if (p->error_indicator) { |
| 15029 | return NULL; |
| 15030 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15031 | void *_res = NULL; |
| 15032 | int _mark = p->mark; |
| 15033 | int _start_mark = p->mark; |
| 15034 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15035 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15036 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15037 | return NULL; |
| 15038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15039 | ssize_t _children_capacity = 1; |
| 15040 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15041 | { // ('or' conjunction) |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15042 | void *_tmp_141_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15043 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15044 | (_tmp_141_var = _tmp_141_rule(p)) // 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15045 | ) |
| 15046 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15047 | _res = _tmp_141_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15048 | if (_n == _children_capacity) { |
| 15049 | _children_capacity *= 2; |
| 15050 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15051 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15052 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15053 | return NULL; |
| 15054 | } |
| 15055 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15056 | _children[_n++] = _res; |
| 15057 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15059 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15060 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15061 | if (_n == 0 || p->error_indicator) { |
| 15062 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15063 | return NULL; |
| 15064 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15065 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15066 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15067 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15068 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15069 | return NULL; |
| 15070 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15071 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15072 | PyMem_Free(_children); |
| 15073 | _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); |
| 15074 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15075 | } |
| 15076 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15077 | // _loop1_90: ('and' inversion) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15078 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15079 | _loop1_90_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15080 | { |
| 15081 | if (p->error_indicator) { |
| 15082 | return NULL; |
| 15083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15084 | void *_res = NULL; |
| 15085 | int _mark = p->mark; |
| 15086 | int _start_mark = p->mark; |
| 15087 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15088 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15089 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15090 | return NULL; |
| 15091 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15092 | ssize_t _children_capacity = 1; |
| 15093 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15094 | { // ('and' inversion) |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15095 | void *_tmp_142_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15096 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15097 | (_tmp_142_var = _tmp_142_rule(p)) // 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15098 | ) |
| 15099 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15100 | _res = _tmp_142_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15101 | if (_n == _children_capacity) { |
| 15102 | _children_capacity *= 2; |
| 15103 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15104 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15105 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15106 | return NULL; |
| 15107 | } |
| 15108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15109 | _children[_n++] = _res; |
| 15110 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15111 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15112 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15113 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15114 | if (_n == 0 || p->error_indicator) { |
| 15115 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15116 | return NULL; |
| 15117 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15118 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15119 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15120 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15121 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15122 | return NULL; |
| 15123 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15124 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15125 | PyMem_Free(_children); |
| 15126 | _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); |
| 15127 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15128 | } |
| 15129 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15130 | // _loop1_91: compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15131 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15132 | _loop1_91_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15133 | { |
| 15134 | if (p->error_indicator) { |
| 15135 | return NULL; |
| 15136 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15137 | void *_res = NULL; |
| 15138 | int _mark = p->mark; |
| 15139 | int _start_mark = p->mark; |
| 15140 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15141 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15142 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15143 | return NULL; |
| 15144 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15145 | ssize_t _children_capacity = 1; |
| 15146 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15147 | { // compare_op_bitwise_or_pair |
| 15148 | CmpopExprPair* compare_op_bitwise_or_pair_var; |
| 15149 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15150 | (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] | 15151 | ) |
| 15152 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15153 | _res = compare_op_bitwise_or_pair_var; |
| 15154 | if (_n == _children_capacity) { |
| 15155 | _children_capacity *= 2; |
| 15156 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15157 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15158 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15159 | return NULL; |
| 15160 | } |
| 15161 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15162 | _children[_n++] = _res; |
| 15163 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15164 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15165 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15166 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15167 | if (_n == 0 || p->error_indicator) { |
| 15168 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15169 | return NULL; |
| 15170 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15171 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15172 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15173 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15174 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15175 | return NULL; |
| 15176 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15177 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15178 | PyMem_Free(_children); |
| 15179 | _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); |
| 15180 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15181 | } |
| 15182 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15183 | // _tmp_92: '!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15184 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15185 | _tmp_92_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15186 | { |
| 15187 | if (p->error_indicator) { |
| 15188 | return NULL; |
| 15189 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15190 | void * _res = NULL; |
| 15191 | int _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15192 | { // '!=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15193 | Token * tok; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15194 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15195 | (tok = _PyPegen_expect_token(p, 28)) // token='!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15196 | ) |
| 15197 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15198 | _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; |
| 15199 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15200 | p->error_indicator = 1; |
| 15201 | return NULL; |
| 15202 | } |
| 15203 | goto done; |
| 15204 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15205 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15206 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15207 | _res = NULL; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15208 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15209 | return _res; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15210 | } |
| 15211 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15212 | // _loop0_94: ',' slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15213 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15214 | _loop0_94_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15215 | { |
| 15216 | if (p->error_indicator) { |
| 15217 | return NULL; |
| 15218 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15219 | void *_res = NULL; |
| 15220 | int _mark = p->mark; |
| 15221 | int _start_mark = p->mark; |
| 15222 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15223 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15224 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15225 | return NULL; |
| 15226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15227 | ssize_t _children_capacity = 1; |
| 15228 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15229 | { // ',' slice |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15230 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15231 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15232 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15233 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15234 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15235 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15236 | ) |
| 15237 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15238 | _res = elem; |
| 15239 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15240 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15241 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15242 | return NULL; |
| 15243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15244 | if (_n == _children_capacity) { |
| 15245 | _children_capacity *= 2; |
| 15246 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15247 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15248 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15249 | return NULL; |
| 15250 | } |
| 15251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15252 | _children[_n++] = _res; |
| 15253 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15254 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15255 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15256 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15257 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15258 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15259 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15260 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15261 | return NULL; |
| 15262 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15263 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15264 | PyMem_Free(_children); |
| 15265 | _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); |
| 15266 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15267 | } |
| 15268 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15269 | // _gather_93: slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15270 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15271 | _gather_93_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15272 | { |
| 15273 | if (p->error_indicator) { |
| 15274 | return NULL; |
| 15275 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15276 | asdl_seq * _res = NULL; |
| 15277 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15278 | { // slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15279 | expr_ty elem; |
| 15280 | asdl_seq * seq; |
| 15281 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15282 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15283 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15284 | (seq = _loop0_94_rule(p)) // _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15285 | ) |
| 15286 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15287 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15288 | goto done; |
| 15289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15290 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15291 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15292 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15293 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15294 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15295 | } |
| 15296 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15297 | // _tmp_95: ':' expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15298 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15299 | _tmp_95_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15300 | { |
| 15301 | if (p->error_indicator) { |
| 15302 | return NULL; |
| 15303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15304 | void * _res = NULL; |
| 15305 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15306 | { // ':' expression? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15307 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15308 | void *d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15309 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15310 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15311 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15312 | (d = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15313 | ) |
| 15314 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15315 | _res = d; |
| 15316 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15317 | p->error_indicator = 1; |
| 15318 | return NULL; |
| 15319 | } |
| 15320 | goto done; |
| 15321 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15322 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15324 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15325 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15326 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15327 | } |
| 15328 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15329 | // _tmp_96: tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15330 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15331 | _tmp_96_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15332 | { |
| 15333 | if (p->error_indicator) { |
| 15334 | return NULL; |
| 15335 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15336 | void * _res = NULL; |
| 15337 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15338 | { // tuple |
| 15339 | expr_ty tuple_var; |
| 15340 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15341 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15342 | ) |
| 15343 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15344 | _res = tuple_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15345 | goto done; |
| 15346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15347 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15348 | } |
| 15349 | { // group |
| 15350 | expr_ty group_var; |
| 15351 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15352 | (group_var = group_rule(p)) // group |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15353 | ) |
| 15354 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15355 | _res = group_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15356 | goto done; |
| 15357 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15358 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15359 | } |
| 15360 | { // genexp |
| 15361 | expr_ty genexp_var; |
| 15362 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15363 | (genexp_var = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15364 | ) |
| 15365 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15366 | _res = genexp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15367 | goto done; |
| 15368 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15369 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15370 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15371 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15372 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15373 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15374 | } |
| 15375 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15376 | // _tmp_97: list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15377 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15378 | _tmp_97_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15379 | { |
| 15380 | if (p->error_indicator) { |
| 15381 | return NULL; |
| 15382 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15383 | void * _res = NULL; |
| 15384 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15385 | { // list |
| 15386 | expr_ty list_var; |
| 15387 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15388 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15389 | ) |
| 15390 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15391 | _res = list_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15392 | goto done; |
| 15393 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15394 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15395 | } |
| 15396 | { // listcomp |
| 15397 | expr_ty listcomp_var; |
| 15398 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15399 | (listcomp_var = listcomp_rule(p)) // listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15400 | ) |
| 15401 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15402 | _res = listcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15403 | goto done; |
| 15404 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15405 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15406 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15407 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15408 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15409 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15410 | } |
| 15411 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15412 | // _tmp_98: dict | set | dictcomp | setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15413 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15414 | _tmp_98_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15415 | { |
| 15416 | if (p->error_indicator) { |
| 15417 | return NULL; |
| 15418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15419 | void * _res = NULL; |
| 15420 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15421 | { // dict |
| 15422 | expr_ty dict_var; |
| 15423 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15424 | (dict_var = dict_rule(p)) // dict |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15425 | ) |
| 15426 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15427 | _res = dict_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15428 | goto done; |
| 15429 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15430 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15431 | } |
| 15432 | { // set |
| 15433 | expr_ty set_var; |
| 15434 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15435 | (set_var = set_rule(p)) // set |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15436 | ) |
| 15437 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15438 | _res = set_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15439 | goto done; |
| 15440 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15441 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15442 | } |
| 15443 | { // dictcomp |
| 15444 | expr_ty dictcomp_var; |
| 15445 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15446 | (dictcomp_var = dictcomp_rule(p)) // dictcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15447 | ) |
| 15448 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15449 | _res = dictcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15450 | goto done; |
| 15451 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15452 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15453 | } |
| 15454 | { // setcomp |
| 15455 | expr_ty setcomp_var; |
| 15456 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15457 | (setcomp_var = setcomp_rule(p)) // setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15458 | ) |
| 15459 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15460 | _res = setcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15461 | goto done; |
| 15462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15463 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15464 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15465 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15466 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15467 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15468 | } |
| 15469 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15470 | // _loop1_99: STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15471 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15472 | _loop1_99_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15473 | { |
| 15474 | if (p->error_indicator) { |
| 15475 | return NULL; |
| 15476 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15477 | void *_res = NULL; |
| 15478 | int _mark = p->mark; |
| 15479 | int _start_mark = p->mark; |
| 15480 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15481 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15482 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15483 | return NULL; |
| 15484 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15485 | ssize_t _children_capacity = 1; |
| 15486 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15487 | { // STRING |
| 15488 | expr_ty string_var; |
| 15489 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15490 | (string_var = _PyPegen_string_token(p)) // STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15491 | ) |
| 15492 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15493 | _res = string_var; |
| 15494 | if (_n == _children_capacity) { |
| 15495 | _children_capacity *= 2; |
| 15496 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15497 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15498 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15499 | return NULL; |
| 15500 | } |
| 15501 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15502 | _children[_n++] = _res; |
| 15503 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15504 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15505 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15507 | if (_n == 0 || p->error_indicator) { |
| 15508 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15509 | return NULL; |
| 15510 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15511 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15512 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15513 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15514 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15515 | return NULL; |
| 15516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15517 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15518 | PyMem_Free(_children); |
| 15519 | _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); |
| 15520 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15521 | } |
| 15522 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15523 | // _tmp_100: star_named_expression ',' star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15524 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15525 | _tmp_100_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15526 | { |
| 15527 | if (p->error_indicator) { |
| 15528 | return NULL; |
| 15529 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15530 | void * _res = NULL; |
| 15531 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15532 | { // star_named_expression ',' star_named_expressions? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15533 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15534 | expr_ty y; |
| 15535 | void *z; |
| 15536 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15537 | (y = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15538 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15539 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15540 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15541 | (z = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15542 | ) |
| 15543 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15544 | _res = _PyPegen_seq_insert_in_front ( p , y , z ); |
| 15545 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15546 | p->error_indicator = 1; |
| 15547 | return NULL; |
| 15548 | } |
| 15549 | goto done; |
| 15550 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15551 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15552 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15553 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15554 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15555 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15556 | } |
| 15557 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15558 | // _tmp_101: yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15559 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15560 | _tmp_101_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15561 | { |
| 15562 | if (p->error_indicator) { |
| 15563 | return NULL; |
| 15564 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15565 | void * _res = NULL; |
| 15566 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15567 | { // yield_expr |
| 15568 | expr_ty yield_expr_var; |
| 15569 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15570 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15571 | ) |
| 15572 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15573 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15574 | goto done; |
| 15575 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15576 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15577 | } |
| 15578 | { // named_expression |
| 15579 | expr_ty named_expression_var; |
| 15580 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15581 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15582 | ) |
| 15583 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15584 | _res = named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15585 | goto done; |
| 15586 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15587 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15588 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15589 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15590 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15591 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15592 | } |
| 15593 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15594 | // _loop0_103: ',' kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15595 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15596 | _loop0_103_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15597 | { |
| 15598 | if (p->error_indicator) { |
| 15599 | return NULL; |
| 15600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15601 | void *_res = NULL; |
| 15602 | int _mark = p->mark; |
| 15603 | int _start_mark = p->mark; |
| 15604 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15605 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15606 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15607 | return NULL; |
| 15608 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15609 | ssize_t _children_capacity = 1; |
| 15610 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15611 | { // ',' kvpair |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15612 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15613 | KeyValuePair* elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15614 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15615 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15616 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15617 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15618 | ) |
| 15619 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15620 | _res = elem; |
| 15621 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15622 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15623 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15624 | return NULL; |
| 15625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15626 | if (_n == _children_capacity) { |
| 15627 | _children_capacity *= 2; |
| 15628 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15629 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15630 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15631 | return NULL; |
| 15632 | } |
| 15633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15634 | _children[_n++] = _res; |
| 15635 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15636 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15637 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15638 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15639 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15640 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15641 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15642 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15643 | return NULL; |
| 15644 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15645 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15646 | PyMem_Free(_children); |
| 15647 | _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); |
| 15648 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15649 | } |
| 15650 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15651 | // _gather_102: kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15652 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15653 | _gather_102_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15654 | { |
| 15655 | if (p->error_indicator) { |
| 15656 | return NULL; |
| 15657 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15658 | asdl_seq * _res = NULL; |
| 15659 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15660 | { // kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15661 | KeyValuePair* elem; |
| 15662 | asdl_seq * seq; |
| 15663 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15664 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15665 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15666 | (seq = _loop0_103_rule(p)) // _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15667 | ) |
| 15668 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15669 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15670 | goto done; |
| 15671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15672 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15673 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15674 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15675 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15676 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15677 | } |
| 15678 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15679 | // _loop1_104: for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15680 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15681 | _loop1_104_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15682 | { |
| 15683 | if (p->error_indicator) { |
| 15684 | return NULL; |
| 15685 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15686 | void *_res = NULL; |
| 15687 | int _mark = p->mark; |
| 15688 | int _start_mark = p->mark; |
| 15689 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15690 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15691 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15692 | return NULL; |
| 15693 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15694 | ssize_t _children_capacity = 1; |
| 15695 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15696 | { // for_if_clause |
| 15697 | comprehension_ty for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15698 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15699 | (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15700 | ) |
| 15701 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15702 | _res = for_if_clause_var; |
| 15703 | if (_n == _children_capacity) { |
| 15704 | _children_capacity *= 2; |
| 15705 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15706 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15707 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15708 | return NULL; |
| 15709 | } |
| 15710 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15711 | _children[_n++] = _res; |
| 15712 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15713 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15714 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15716 | if (_n == 0 || p->error_indicator) { |
| 15717 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15718 | return NULL; |
| 15719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15720 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15721 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15722 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15723 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15724 | return NULL; |
| 15725 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15726 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15727 | PyMem_Free(_children); |
| 15728 | _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); |
| 15729 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15730 | } |
| 15731 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15732 | // _loop0_105: ('if' disjunction) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15733 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15734 | _loop0_105_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15735 | { |
| 15736 | if (p->error_indicator) { |
| 15737 | return NULL; |
| 15738 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15739 | void *_res = NULL; |
| 15740 | int _mark = p->mark; |
| 15741 | int _start_mark = p->mark; |
| 15742 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15743 | if (!_children) { |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15744 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15745 | return NULL; |
| 15746 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15747 | ssize_t _children_capacity = 1; |
| 15748 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15749 | { // ('if' disjunction) |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15750 | void *_tmp_143_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15751 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15752 | (_tmp_143_var = _tmp_143_rule(p)) // 'if' disjunction |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15753 | ) |
| 15754 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15755 | _res = _tmp_143_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15756 | if (_n == _children_capacity) { |
| 15757 | _children_capacity *= 2; |
| 15758 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15759 | if (!_children) { |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15760 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15761 | return NULL; |
| 15762 | } |
| 15763 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15764 | _children[_n++] = _res; |
| 15765 | _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15766 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15767 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15768 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15769 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15770 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15771 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15772 | PyMem_Free(_children); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15773 | return NULL; |
| 15774 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15775 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15776 | PyMem_Free(_children); |
| 15777 | _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq); |
| 15778 | return _seq; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15779 | } |
| 15780 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15781 | // _loop0_106: ('if' disjunction) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15782 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15783 | _loop0_106_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15784 | { |
| 15785 | if (p->error_indicator) { |
| 15786 | return NULL; |
| 15787 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15788 | void *_res = NULL; |
| 15789 | int _mark = p->mark; |
| 15790 | int _start_mark = p->mark; |
| 15791 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15792 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15793 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15794 | return NULL; |
| 15795 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15796 | ssize_t _children_capacity = 1; |
| 15797 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15798 | { // ('if' disjunction) |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15799 | void *_tmp_144_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15800 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15801 | (_tmp_144_var = _tmp_144_rule(p)) // 'if' disjunction |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15802 | ) |
| 15803 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15804 | _res = _tmp_144_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15805 | if (_n == _children_capacity) { |
| 15806 | _children_capacity *= 2; |
| 15807 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15808 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15809 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15810 | return NULL; |
| 15811 | } |
| 15812 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15813 | _children[_n++] = _res; |
| 15814 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15816 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15817 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15818 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15819 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15820 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15821 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15822 | return NULL; |
| 15823 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15824 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15825 | PyMem_Free(_children); |
| 15826 | _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); |
| 15827 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15828 | } |
| 15829 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15830 | // _tmp_107: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15831 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15832 | _tmp_107_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15833 | { |
| 15834 | if (p->error_indicator) { |
| 15835 | return NULL; |
| 15836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15837 | void * _res = NULL; |
| 15838 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15839 | { // ',' args |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15840 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15841 | expr_ty c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15842 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15843 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15844 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15845 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15846 | ) |
| 15847 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15848 | _res = c; |
| 15849 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15850 | p->error_indicator = 1; |
| 15851 | return NULL; |
| 15852 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15853 | goto done; |
| 15854 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15855 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15856 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15857 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15858 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15859 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15860 | } |
| 15861 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15862 | // _tmp_108: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15863 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15864 | _tmp_108_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15865 | { |
| 15866 | if (p->error_indicator) { |
| 15867 | return NULL; |
| 15868 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15869 | void * _res = NULL; |
| 15870 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15871 | { // ',' args |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15872 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15873 | expr_ty c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15874 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15875 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15876 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15877 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15878 | ) |
| 15879 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15880 | _res = c; |
| 15881 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15882 | p->error_indicator = 1; |
| 15883 | return NULL; |
| 15884 | } |
| 15885 | goto done; |
| 15886 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15887 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15888 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15889 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15890 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15891 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15892 | } |
| 15893 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15894 | // _loop0_110: ',' kwarg_or_starred |
| 15895 | static asdl_seq * |
| 15896 | _loop0_110_rule(Parser *p) |
| 15897 | { |
| 15898 | if (p->error_indicator) { |
| 15899 | return NULL; |
| 15900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15901 | void *_res = NULL; |
| 15902 | int _mark = p->mark; |
| 15903 | int _start_mark = p->mark; |
| 15904 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15905 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15906 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15907 | return NULL; |
| 15908 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15909 | ssize_t _children_capacity = 1; |
| 15910 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15911 | { // ',' kwarg_or_starred |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15912 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15913 | KeywordOrStarred* elem; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15914 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15915 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15916 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15917 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15918 | ) |
| 15919 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15920 | _res = elem; |
| 15921 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15922 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15923 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15924 | return NULL; |
| 15925 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15926 | if (_n == _children_capacity) { |
| 15927 | _children_capacity *= 2; |
| 15928 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15929 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15930 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15931 | return NULL; |
| 15932 | } |
| 15933 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15934 | _children[_n++] = _res; |
| 15935 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15937 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15938 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15939 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15940 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15941 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15942 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15943 | return NULL; |
| 15944 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15945 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15946 | PyMem_Free(_children); |
| 15947 | _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); |
| 15948 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15949 | } |
| 15950 | |
| 15951 | // _gather_109: kwarg_or_starred _loop0_110 |
| 15952 | static asdl_seq * |
| 15953 | _gather_109_rule(Parser *p) |
| 15954 | { |
| 15955 | if (p->error_indicator) { |
| 15956 | return NULL; |
| 15957 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15958 | asdl_seq * _res = NULL; |
| 15959 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15960 | { // kwarg_or_starred _loop0_110 |
| 15961 | KeywordOrStarred* elem; |
| 15962 | asdl_seq * seq; |
| 15963 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15964 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15965 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15966 | (seq = _loop0_110_rule(p)) // _loop0_110 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15967 | ) |
| 15968 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15969 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15970 | goto done; |
| 15971 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15972 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15973 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15974 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15975 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15976 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15977 | } |
| 15978 | |
| 15979 | // _loop0_112: ',' kwarg_or_double_starred |
| 15980 | static asdl_seq * |
| 15981 | _loop0_112_rule(Parser *p) |
| 15982 | { |
| 15983 | if (p->error_indicator) { |
| 15984 | return NULL; |
| 15985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15986 | void *_res = NULL; |
| 15987 | int _mark = p->mark; |
| 15988 | int _start_mark = p->mark; |
| 15989 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15990 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15991 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15992 | return NULL; |
| 15993 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15994 | ssize_t _children_capacity = 1; |
| 15995 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15996 | { // ',' kwarg_or_double_starred |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15997 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15998 | KeywordOrStarred* elem; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15999 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16000 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16001 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16002 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16003 | ) |
| 16004 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16005 | _res = elem; |
| 16006 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16007 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16008 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16009 | return NULL; |
| 16010 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16011 | if (_n == _children_capacity) { |
| 16012 | _children_capacity *= 2; |
| 16013 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16014 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16015 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16016 | return NULL; |
| 16017 | } |
| 16018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16019 | _children[_n++] = _res; |
| 16020 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16021 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16022 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16023 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16024 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16025 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16026 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16027 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16028 | return NULL; |
| 16029 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16030 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16031 | PyMem_Free(_children); |
| 16032 | _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); |
| 16033 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16034 | } |
| 16035 | |
| 16036 | // _gather_111: kwarg_or_double_starred _loop0_112 |
| 16037 | static asdl_seq * |
| 16038 | _gather_111_rule(Parser *p) |
| 16039 | { |
| 16040 | if (p->error_indicator) { |
| 16041 | return NULL; |
| 16042 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16043 | asdl_seq * _res = NULL; |
| 16044 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16045 | { // kwarg_or_double_starred _loop0_112 |
| 16046 | KeywordOrStarred* elem; |
| 16047 | asdl_seq * seq; |
| 16048 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16049 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16050 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16051 | (seq = _loop0_112_rule(p)) // _loop0_112 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16052 | ) |
| 16053 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16054 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16055 | goto done; |
| 16056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16057 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16059 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16060 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16061 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16062 | } |
| 16063 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16064 | // _loop0_114: ',' kwarg_or_starred |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16065 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16066 | _loop0_114_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16067 | { |
| 16068 | if (p->error_indicator) { |
| 16069 | return NULL; |
| 16070 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16071 | void *_res = NULL; |
| 16072 | int _mark = p->mark; |
| 16073 | int _start_mark = p->mark; |
| 16074 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16075 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16076 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16077 | return NULL; |
| 16078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16079 | ssize_t _children_capacity = 1; |
| 16080 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16081 | { // ',' kwarg_or_starred |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16082 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16083 | KeywordOrStarred* elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16084 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16085 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16086 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16087 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16088 | ) |
| 16089 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16090 | _res = elem; |
| 16091 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16092 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16093 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16094 | return NULL; |
| 16095 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16096 | if (_n == _children_capacity) { |
| 16097 | _children_capacity *= 2; |
| 16098 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16099 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16100 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16101 | return NULL; |
| 16102 | } |
| 16103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16104 | _children[_n++] = _res; |
| 16105 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16106 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16107 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16109 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16110 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16111 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16112 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16113 | return NULL; |
| 16114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16115 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16116 | PyMem_Free(_children); |
| 16117 | _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq); |
| 16118 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16119 | } |
| 16120 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16121 | // _gather_113: kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16122 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16123 | _gather_113_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16124 | { |
| 16125 | if (p->error_indicator) { |
| 16126 | return NULL; |
| 16127 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16128 | asdl_seq * _res = NULL; |
| 16129 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16130 | { // kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16131 | KeywordOrStarred* elem; |
| 16132 | asdl_seq * seq; |
| 16133 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16134 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16135 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16136 | (seq = _loop0_114_rule(p)) // _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16137 | ) |
| 16138 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16139 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16140 | goto done; |
| 16141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16142 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16143 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16144 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16145 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16146 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16147 | } |
| 16148 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16149 | // _loop0_116: ',' kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16150 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16151 | _loop0_116_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16152 | { |
| 16153 | if (p->error_indicator) { |
| 16154 | return NULL; |
| 16155 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16156 | void *_res = NULL; |
| 16157 | int _mark = p->mark; |
| 16158 | int _start_mark = p->mark; |
| 16159 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16160 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16161 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16162 | return NULL; |
| 16163 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16164 | ssize_t _children_capacity = 1; |
| 16165 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16166 | { // ',' kwarg_or_double_starred |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16167 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16168 | KeywordOrStarred* elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16169 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16170 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16171 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16172 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16173 | ) |
| 16174 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16175 | _res = elem; |
| 16176 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16177 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16178 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16179 | return NULL; |
| 16180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16181 | if (_n == _children_capacity) { |
| 16182 | _children_capacity *= 2; |
| 16183 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16184 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16185 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16186 | return NULL; |
| 16187 | } |
| 16188 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16189 | _children[_n++] = _res; |
| 16190 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16191 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16192 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16194 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16195 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16196 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16197 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16198 | return NULL; |
| 16199 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16200 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16201 | PyMem_Free(_children); |
| 16202 | _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq); |
| 16203 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16204 | } |
| 16205 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16206 | // _gather_115: kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16207 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16208 | _gather_115_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16209 | { |
| 16210 | if (p->error_indicator) { |
| 16211 | return NULL; |
| 16212 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16213 | asdl_seq * _res = NULL; |
| 16214 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16215 | { // kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16216 | KeywordOrStarred* elem; |
| 16217 | asdl_seq * seq; |
| 16218 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16219 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16220 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16221 | (seq = _loop0_116_rule(p)) // _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16222 | ) |
| 16223 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16224 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16225 | goto done; |
| 16226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16227 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16229 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16230 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16231 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16232 | } |
| 16233 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16234 | // _loop0_117: (',' star_target) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16235 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16236 | _loop0_117_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16237 | { |
| 16238 | if (p->error_indicator) { |
| 16239 | return NULL; |
| 16240 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16241 | void *_res = NULL; |
| 16242 | int _mark = p->mark; |
| 16243 | int _start_mark = p->mark; |
| 16244 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16245 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16246 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16247 | return NULL; |
| 16248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16249 | ssize_t _children_capacity = 1; |
| 16250 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16251 | { // (',' star_target) |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16252 | void *_tmp_145_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16253 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16254 | (_tmp_145_var = _tmp_145_rule(p)) // ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16255 | ) |
| 16256 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16257 | _res = _tmp_145_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16258 | if (_n == _children_capacity) { |
| 16259 | _children_capacity *= 2; |
| 16260 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16261 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16262 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16263 | return NULL; |
| 16264 | } |
| 16265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16266 | _children[_n++] = _res; |
| 16267 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16268 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16269 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16270 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16271 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16272 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16273 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16274 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16275 | return NULL; |
| 16276 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16277 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16278 | PyMem_Free(_children); |
| 16279 | _PyPegen_insert_memo(p, _start_mark, _loop0_117_type, _seq); |
| 16280 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16281 | } |
| 16282 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16283 | // _loop0_119: ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16284 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16285 | _loop0_119_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16286 | { |
| 16287 | if (p->error_indicator) { |
| 16288 | return NULL; |
| 16289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16290 | void *_res = NULL; |
| 16291 | int _mark = p->mark; |
| 16292 | int _start_mark = p->mark; |
| 16293 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16294 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16295 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16296 | return NULL; |
| 16297 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16298 | ssize_t _children_capacity = 1; |
| 16299 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16300 | { // ',' star_target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16301 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16302 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16303 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16304 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16305 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16306 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16307 | ) |
| 16308 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16309 | _res = elem; |
| 16310 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16311 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16312 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16313 | return NULL; |
| 16314 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16315 | if (_n == _children_capacity) { |
| 16316 | _children_capacity *= 2; |
| 16317 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16318 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16319 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16320 | return NULL; |
| 16321 | } |
| 16322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16323 | _children[_n++] = _res; |
| 16324 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16325 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16326 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16327 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16328 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16329 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16330 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16331 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16332 | return NULL; |
| 16333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16334 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16335 | PyMem_Free(_children); |
| 16336 | _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); |
| 16337 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16338 | } |
| 16339 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16340 | // _gather_118: star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16341 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16342 | _gather_118_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16343 | { |
| 16344 | if (p->error_indicator) { |
| 16345 | return NULL; |
| 16346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16347 | asdl_seq * _res = NULL; |
| 16348 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16349 | { // star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16350 | expr_ty elem; |
| 16351 | asdl_seq * seq; |
| 16352 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16353 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16354 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16355 | (seq = _loop0_119_rule(p)) // _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16356 | ) |
| 16357 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16358 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16359 | goto done; |
| 16360 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16361 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16362 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16363 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16364 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16365 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16366 | } |
| 16367 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16368 | // _tmp_120: !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16369 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16370 | _tmp_120_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16371 | { |
| 16372 | if (p->error_indicator) { |
| 16373 | return NULL; |
| 16374 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16375 | void * _res = NULL; |
| 16376 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16377 | { // !'*' star_target |
| 16378 | expr_ty star_target_var; |
| 16379 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16380 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16381 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16382 | (star_target_var = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16383 | ) |
| 16384 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16385 | _res = star_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16386 | goto done; |
| 16387 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16388 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16389 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16390 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16391 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16392 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16393 | } |
| 16394 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16395 | // _loop0_122: ',' del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16396 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16397 | _loop0_122_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16398 | { |
| 16399 | if (p->error_indicator) { |
| 16400 | return NULL; |
| 16401 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16402 | void *_res = NULL; |
| 16403 | int _mark = p->mark; |
| 16404 | int _start_mark = p->mark; |
| 16405 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16406 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16407 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16408 | return NULL; |
| 16409 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16410 | ssize_t _children_capacity = 1; |
| 16411 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16412 | { // ',' del_target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16413 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16414 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16415 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16416 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16417 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16418 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16419 | ) |
| 16420 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16421 | _res = elem; |
| 16422 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16423 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16424 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16425 | return NULL; |
| 16426 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16427 | if (_n == _children_capacity) { |
| 16428 | _children_capacity *= 2; |
| 16429 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16430 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16431 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16432 | return NULL; |
| 16433 | } |
| 16434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16435 | _children[_n++] = _res; |
| 16436 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16437 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16438 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16440 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16441 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16442 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16443 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16444 | return NULL; |
| 16445 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16446 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16447 | PyMem_Free(_children); |
| 16448 | _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq); |
| 16449 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16450 | } |
| 16451 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16452 | // _gather_121: del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16453 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16454 | _gather_121_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16455 | { |
| 16456 | if (p->error_indicator) { |
| 16457 | return NULL; |
| 16458 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16459 | asdl_seq * _res = NULL; |
| 16460 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16461 | { // del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16462 | expr_ty elem; |
| 16463 | asdl_seq * seq; |
| 16464 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16465 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16466 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16467 | (seq = _loop0_122_rule(p)) // _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16468 | ) |
| 16469 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16470 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16471 | goto done; |
| 16472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16473 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16475 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16476 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16477 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16478 | } |
| 16479 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16480 | // _loop0_124: ',' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16481 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16482 | _loop0_124_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16483 | { |
| 16484 | if (p->error_indicator) { |
| 16485 | return NULL; |
| 16486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16487 | void *_res = NULL; |
| 16488 | int _mark = p->mark; |
| 16489 | int _start_mark = p->mark; |
| 16490 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16491 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16492 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16493 | return NULL; |
| 16494 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16495 | ssize_t _children_capacity = 1; |
| 16496 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16497 | { // ',' target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16498 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16499 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16500 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16501 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16502 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16503 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16504 | ) |
| 16505 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16506 | _res = elem; |
| 16507 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16508 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16509 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16510 | return NULL; |
| 16511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16512 | if (_n == _children_capacity) { |
| 16513 | _children_capacity *= 2; |
| 16514 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16515 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16516 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16517 | return NULL; |
| 16518 | } |
| 16519 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16520 | _children[_n++] = _res; |
| 16521 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16522 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16523 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16524 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16525 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16526 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16527 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16528 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16529 | return NULL; |
| 16530 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16531 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16532 | PyMem_Free(_children); |
| 16533 | _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq); |
| 16534 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16535 | } |
| 16536 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16537 | // _gather_123: target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16538 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16539 | _gather_123_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16540 | { |
| 16541 | if (p->error_indicator) { |
| 16542 | return NULL; |
| 16543 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16544 | asdl_seq * _res = NULL; |
| 16545 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16546 | { // target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16547 | expr_ty elem; |
| 16548 | asdl_seq * seq; |
| 16549 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16550 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16551 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16552 | (seq = _loop0_124_rule(p)) // _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16553 | ) |
| 16554 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16555 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16556 | goto done; |
| 16557 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16558 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16560 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16561 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16562 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16563 | } |
| 16564 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16565 | // _tmp_125: args | expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16566 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16567 | _tmp_125_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16568 | { |
| 16569 | if (p->error_indicator) { |
| 16570 | return NULL; |
| 16571 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16572 | void * _res = NULL; |
| 16573 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16574 | { // args |
| 16575 | expr_ty args_var; |
| 16576 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16577 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16578 | ) |
| 16579 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16580 | _res = args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16581 | goto done; |
| 16582 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16583 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16584 | } |
| 16585 | { // expression for_if_clauses |
| 16586 | expr_ty expression_var; |
| 16587 | asdl_seq* for_if_clauses_var; |
| 16588 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16589 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16590 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16591 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16592 | ) |
| 16593 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16594 | _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16595 | goto done; |
| 16596 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16597 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16598 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16599 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16600 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16601 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16602 | } |
| 16603 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16604 | // _loop0_126: star_named_expressions |
| 16605 | static asdl_seq * |
| 16606 | _loop0_126_rule(Parser *p) |
| 16607 | { |
| 16608 | if (p->error_indicator) { |
| 16609 | return NULL; |
| 16610 | } |
| 16611 | void *_res = NULL; |
| 16612 | int _mark = p->mark; |
| 16613 | int _start_mark = p->mark; |
| 16614 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16615 | if (!_children) { |
| 16616 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16617 | return NULL; |
| 16618 | } |
| 16619 | ssize_t _children_capacity = 1; |
| 16620 | ssize_t _n = 0; |
| 16621 | { // star_named_expressions |
| 16622 | asdl_seq* star_named_expressions_var; |
| 16623 | while ( |
| 16624 | (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions |
| 16625 | ) |
| 16626 | { |
| 16627 | _res = star_named_expressions_var; |
| 16628 | if (_n == _children_capacity) { |
| 16629 | _children_capacity *= 2; |
| 16630 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16631 | if (!_children) { |
| 16632 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16633 | return NULL; |
| 16634 | } |
| 16635 | } |
| 16636 | _children[_n++] = _res; |
| 16637 | _mark = p->mark; |
| 16638 | } |
| 16639 | p->mark = _mark; |
| 16640 | } |
| 16641 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16642 | if (!_seq) { |
| 16643 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_126"); |
| 16644 | PyMem_Free(_children); |
| 16645 | return NULL; |
| 16646 | } |
| 16647 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16648 | PyMem_Free(_children); |
| 16649 | _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); |
| 16650 | return _seq; |
| 16651 | } |
| 16652 | |
| 16653 | // _tmp_127: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16654 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16655 | _tmp_127_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16656 | { |
| 16657 | if (p->error_indicator) { |
| 16658 | return NULL; |
| 16659 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16660 | void * _res = NULL; |
| 16661 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16662 | { // '=' annotated_rhs |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16663 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16664 | expr_ty annotated_rhs_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16665 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16666 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16667 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16668 | (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16669 | ) |
| 16670 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16671 | _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16672 | goto done; |
| 16673 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16674 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16675 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16676 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16677 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16678 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16679 | } |
| 16680 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16681 | // _tmp_128: '=' | augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16682 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16683 | _tmp_128_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16684 | { |
| 16685 | if (p->error_indicator) { |
| 16686 | return NULL; |
| 16687 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16688 | void * _res = NULL; |
| 16689 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16690 | { // '=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16691 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16692 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16693 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16694 | ) |
| 16695 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16696 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16697 | goto done; |
| 16698 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16699 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16700 | } |
| 16701 | { // augassign |
| 16702 | AugOperator* augassign_var; |
| 16703 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16704 | (augassign_var = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16705 | ) |
| 16706 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16707 | _res = augassign_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16708 | goto done; |
| 16709 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16710 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16711 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16712 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16713 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16714 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16715 | } |
| 16716 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16717 | // _tmp_129: yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16718 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16719 | _tmp_129_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16720 | { |
| 16721 | if (p->error_indicator) { |
| 16722 | return NULL; |
| 16723 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16724 | void * _res = NULL; |
| 16725 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16726 | { // yield_expr |
| 16727 | expr_ty yield_expr_var; |
| 16728 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16729 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16730 | ) |
| 16731 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16732 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16733 | goto done; |
| 16734 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16735 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16736 | } |
| 16737 | { // star_expressions |
| 16738 | expr_ty star_expressions_var; |
| 16739 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16740 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16741 | ) |
| 16742 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16743 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16744 | goto done; |
| 16745 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16746 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16747 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16748 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16749 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16750 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16751 | } |
| 16752 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16753 | // _tmp_130: '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16754 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16755 | _tmp_130_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16756 | { |
| 16757 | if (p->error_indicator) { |
| 16758 | return NULL; |
| 16759 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16760 | void * _res = NULL; |
| 16761 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16762 | { // '[' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16763 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16764 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16765 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16766 | ) |
| 16767 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16768 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16769 | goto done; |
| 16770 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16771 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16772 | } |
| 16773 | { // '(' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16774 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16775 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16776 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16777 | ) |
| 16778 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16779 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16780 | goto done; |
| 16781 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16782 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16783 | } |
| 16784 | { // '{' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16785 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16786 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16787 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16788 | ) |
| 16789 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16790 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16791 | goto done; |
| 16792 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16793 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16794 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16795 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16796 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16797 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16798 | } |
| 16799 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16800 | // _loop0_131: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16801 | static asdl_seq * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16802 | _loop0_131_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16803 | { |
| 16804 | if (p->error_indicator) { |
| 16805 | return NULL; |
| 16806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16807 | void *_res = NULL; |
| 16808 | int _mark = p->mark; |
| 16809 | int _start_mark = p->mark; |
| 16810 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16811 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16812 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16813 | return NULL; |
| 16814 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16815 | ssize_t _children_capacity = 1; |
| 16816 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16817 | { // param_no_default |
| 16818 | arg_ty param_no_default_var; |
| 16819 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16820 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16821 | ) |
| 16822 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16823 | _res = param_no_default_var; |
| 16824 | if (_n == _children_capacity) { |
| 16825 | _children_capacity *= 2; |
| 16826 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16827 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16828 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16829 | return NULL; |
| 16830 | } |
| 16831 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16832 | _children[_n++] = _res; |
| 16833 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16834 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16835 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16837 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16838 | if (!_seq) { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16839 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_131"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16840 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16841 | return NULL; |
| 16842 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16843 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16844 | PyMem_Free(_children); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16845 | _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16846 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16847 | } |
| 16848 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16849 | // _tmp_132: slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16850 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16851 | _tmp_132_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16852 | { |
| 16853 | if (p->error_indicator) { |
| 16854 | return NULL; |
| 16855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16856 | void * _res = NULL; |
| 16857 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16858 | { // slash_with_default |
| 16859 | SlashWithDefault* slash_with_default_var; |
| 16860 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16861 | (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16862 | ) |
| 16863 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16864 | _res = slash_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16865 | goto done; |
| 16866 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16867 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16868 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16869 | { // param_with_default+ |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16870 | asdl_seq * _loop1_146_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16871 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16872 | (_loop1_146_var = _loop1_146_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16873 | ) |
| 16874 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16875 | _res = _loop1_146_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16876 | goto done; |
| 16877 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16878 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16879 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16880 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16881 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16882 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16883 | } |
| 16884 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16885 | // _tmp_133: ')' | ',' (')' | '**') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16886 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16887 | _tmp_133_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16888 | { |
| 16889 | if (p->error_indicator) { |
| 16890 | return NULL; |
| 16891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16892 | void * _res = NULL; |
| 16893 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16894 | { // ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16895 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16896 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16897 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16898 | ) |
| 16899 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16900 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16901 | goto done; |
| 16902 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16903 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16904 | } |
| 16905 | { // ',' (')' | '**') |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16906 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16907 | void *_tmp_147_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16908 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16909 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16910 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16911 | (_tmp_147_var = _tmp_147_rule(p)) // ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16912 | ) |
| 16913 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16914 | _res = _PyPegen_dummy_name(p, _literal, _tmp_147_var); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16915 | goto done; |
| 16916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16917 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16918 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16919 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16920 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16921 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16922 | } |
| 16923 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16924 | // _tmp_134: ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16925 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16926 | _tmp_134_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16927 | { |
| 16928 | if (p->error_indicator) { |
| 16929 | return NULL; |
| 16930 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16931 | void * _res = NULL; |
| 16932 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16933 | { // ':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16934 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16935 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16936 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16937 | ) |
| 16938 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16939 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16940 | goto done; |
| 16941 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16942 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16943 | } |
| 16944 | { // ',' (':' | '**') |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16945 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16946 | void *_tmp_148_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16947 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16948 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16949 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16950 | (_tmp_148_var = _tmp_148_rule(p)) // ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16951 | ) |
| 16952 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16953 | _res = _PyPegen_dummy_name(p, _literal, _tmp_148_var); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16954 | goto done; |
| 16955 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16956 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16957 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16958 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16959 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16960 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16961 | } |
| 16962 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16963 | // _tmp_135: star_targets '=' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16964 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16965 | _tmp_135_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16966 | { |
| 16967 | if (p->error_indicator) { |
| 16968 | return NULL; |
| 16969 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16970 | void * _res = NULL; |
| 16971 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16972 | { // star_targets '=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16973 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16974 | expr_ty z; |
| 16975 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16976 | (z = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16977 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16978 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16979 | ) |
| 16980 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16981 | _res = z; |
| 16982 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16983 | p->error_indicator = 1; |
| 16984 | return NULL; |
| 16985 | } |
| 16986 | goto done; |
| 16987 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16988 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16989 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16990 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16991 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16992 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16993 | } |
| 16994 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16995 | // _tmp_136: '.' | '...' |
| 16996 | static void * |
| 16997 | _tmp_136_rule(Parser *p) |
| 16998 | { |
| 16999 | if (p->error_indicator) { |
| 17000 | return NULL; |
| 17001 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17002 | void * _res = NULL; |
| 17003 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17004 | { // '.' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17005 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17006 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17007 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17008 | ) |
| 17009 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17010 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17011 | goto done; |
| 17012 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17013 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17014 | } |
| 17015 | { // '...' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17016 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17017 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17018 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17019 | ) |
| 17020 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17021 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17022 | goto done; |
| 17023 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17024 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17025 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17026 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17027 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17028 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17029 | } |
| 17030 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17031 | // _tmp_137: '.' | '...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17032 | static void * |
| 17033 | _tmp_137_rule(Parser *p) |
| 17034 | { |
| 17035 | if (p->error_indicator) { |
| 17036 | return NULL; |
| 17037 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17038 | void * _res = NULL; |
| 17039 | int _mark = p->mark; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17040 | { // '.' |
| 17041 | Token * _literal; |
| 17042 | if ( |
| 17043 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 17044 | ) |
| 17045 | { |
| 17046 | _res = _literal; |
| 17047 | goto done; |
| 17048 | } |
| 17049 | p->mark = _mark; |
| 17050 | } |
| 17051 | { // '...' |
| 17052 | Token * _literal; |
| 17053 | if ( |
| 17054 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
| 17055 | ) |
| 17056 | { |
| 17057 | _res = _literal; |
| 17058 | goto done; |
| 17059 | } |
| 17060 | p->mark = _mark; |
| 17061 | } |
| 17062 | _res = NULL; |
| 17063 | done: |
| 17064 | return _res; |
| 17065 | } |
| 17066 | |
| 17067 | // _tmp_138: '@' named_expression NEWLINE |
| 17068 | static void * |
| 17069 | _tmp_138_rule(Parser *p) |
| 17070 | { |
| 17071 | if (p->error_indicator) { |
| 17072 | return NULL; |
| 17073 | } |
| 17074 | void * _res = NULL; |
| 17075 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17076 | { // '@' named_expression NEWLINE |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17077 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17078 | expr_ty f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 17079 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17080 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17081 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17082 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17083 | (f = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17084 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17085 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17086 | ) |
| 17087 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17088 | _res = f; |
| 17089 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17090 | p->error_indicator = 1; |
| 17091 | return NULL; |
| 17092 | } |
| 17093 | goto done; |
| 17094 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17095 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17097 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17098 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17099 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17100 | } |
| 17101 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17102 | // _tmp_139: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17103 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17104 | _tmp_139_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17105 | { |
| 17106 | if (p->error_indicator) { |
| 17107 | return NULL; |
| 17108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17109 | void * _res = NULL; |
| 17110 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17111 | { // ',' star_expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17112 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17113 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17114 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17115 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17116 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17117 | (c = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17118 | ) |
| 17119 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17120 | _res = c; |
| 17121 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17122 | p->error_indicator = 1; |
| 17123 | return NULL; |
| 17124 | } |
| 17125 | goto done; |
| 17126 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17127 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17128 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17129 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17130 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17131 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17132 | } |
| 17133 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17134 | // _tmp_140: ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17135 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17136 | _tmp_140_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17137 | { |
| 17138 | if (p->error_indicator) { |
| 17139 | return NULL; |
| 17140 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17141 | void * _res = NULL; |
| 17142 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17143 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17144 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17145 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17146 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17147 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17148 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17149 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17150 | ) |
| 17151 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17152 | _res = c; |
| 17153 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17154 | p->error_indicator = 1; |
| 17155 | return NULL; |
| 17156 | } |
| 17157 | goto done; |
| 17158 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17159 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17160 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17161 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17162 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17163 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17164 | } |
| 17165 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17166 | // _tmp_141: 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17167 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17168 | _tmp_141_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17169 | { |
| 17170 | if (p->error_indicator) { |
| 17171 | return NULL; |
| 17172 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17173 | void * _res = NULL; |
| 17174 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17175 | { // 'or' conjunction |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17176 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17177 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17178 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17179 | (_keyword = _PyPegen_expect_token(p, 532)) // token='or' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17180 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17181 | (c = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17182 | ) |
| 17183 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17184 | _res = c; |
| 17185 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17186 | p->error_indicator = 1; |
| 17187 | return NULL; |
| 17188 | } |
| 17189 | goto done; |
| 17190 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17191 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17192 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17193 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17194 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17195 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17196 | } |
| 17197 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17198 | // _tmp_142: 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17199 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17200 | _tmp_142_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17201 | { |
| 17202 | if (p->error_indicator) { |
| 17203 | return NULL; |
| 17204 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17205 | void * _res = NULL; |
| 17206 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17207 | { // 'and' inversion |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17208 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17209 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17210 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17211 | (_keyword = _PyPegen_expect_token(p, 533)) // token='and' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17212 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17213 | (c = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17214 | ) |
| 17215 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17216 | _res = c; |
| 17217 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17218 | p->error_indicator = 1; |
| 17219 | return NULL; |
| 17220 | } |
| 17221 | goto done; |
| 17222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17223 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17225 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17226 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17227 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17228 | } |
| 17229 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17230 | // _tmp_143: 'if' disjunction |
| 17231 | static void * |
| 17232 | _tmp_143_rule(Parser *p) |
| 17233 | { |
| 17234 | if (p->error_indicator) { |
| 17235 | return NULL; |
| 17236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17237 | void * _res = NULL; |
| 17238 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17239 | { // 'if' disjunction |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17240 | Token * _keyword; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17241 | expr_ty z; |
| 17242 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17243 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17244 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17245 | (z = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17246 | ) |
| 17247 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17248 | _res = z; |
| 17249 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17250 | p->error_indicator = 1; |
| 17251 | return NULL; |
| 17252 | } |
| 17253 | goto done; |
| 17254 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17255 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17256 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17257 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17258 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17259 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17260 | } |
| 17261 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17262 | // _tmp_144: 'if' disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17263 | static void * |
| 17264 | _tmp_144_rule(Parser *p) |
| 17265 | { |
| 17266 | if (p->error_indicator) { |
| 17267 | return NULL; |
| 17268 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17269 | void * _res = NULL; |
| 17270 | int _mark = p->mark; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17271 | { // 'if' disjunction |
| 17272 | Token * _keyword; |
| 17273 | expr_ty z; |
| 17274 | if ( |
| 17275 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 17276 | && |
| 17277 | (z = disjunction_rule(p)) // disjunction |
| 17278 | ) |
| 17279 | { |
| 17280 | _res = z; |
| 17281 | if (_res == NULL && PyErr_Occurred()) { |
| 17282 | p->error_indicator = 1; |
| 17283 | return NULL; |
| 17284 | } |
| 17285 | goto done; |
| 17286 | } |
| 17287 | p->mark = _mark; |
| 17288 | } |
| 17289 | _res = NULL; |
| 17290 | done: |
| 17291 | return _res; |
| 17292 | } |
| 17293 | |
| 17294 | // _tmp_145: ',' star_target |
| 17295 | static void * |
| 17296 | _tmp_145_rule(Parser *p) |
| 17297 | { |
| 17298 | if (p->error_indicator) { |
| 17299 | return NULL; |
| 17300 | } |
| 17301 | void * _res = NULL; |
| 17302 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17303 | { // ',' star_target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17304 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17305 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17306 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17307 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17308 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17309 | (c = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17310 | ) |
| 17311 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17312 | _res = c; |
| 17313 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17314 | p->error_indicator = 1; |
| 17315 | return NULL; |
| 17316 | } |
| 17317 | goto done; |
| 17318 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17319 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17320 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17321 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17322 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17323 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17324 | } |
| 17325 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17326 | // _loop1_146: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17327 | static asdl_seq * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17328 | _loop1_146_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17329 | { |
| 17330 | if (p->error_indicator) { |
| 17331 | return NULL; |
| 17332 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17333 | void *_res = NULL; |
| 17334 | int _mark = p->mark; |
| 17335 | int _start_mark = p->mark; |
| 17336 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17337 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17338 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 17339 | return NULL; |
| 17340 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17341 | ssize_t _children_capacity = 1; |
| 17342 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17343 | { // param_with_default |
| 17344 | NameDefaultPair* param_with_default_var; |
| 17345 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17346 | (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] | 17347 | ) |
| 17348 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17349 | _res = param_with_default_var; |
| 17350 | if (_n == _children_capacity) { |
| 17351 | _children_capacity *= 2; |
| 17352 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17353 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17354 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 17355 | return NULL; |
| 17356 | } |
| 17357 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17358 | _children[_n++] = _res; |
| 17359 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17360 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17361 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17362 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17363 | if (_n == 0 || p->error_indicator) { |
| 17364 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17365 | return NULL; |
| 17366 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17367 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17368 | if (!_seq) { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17369 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_146"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17370 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17371 | return NULL; |
| 17372 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17373 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17374 | PyMem_Free(_children); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17375 | _PyPegen_insert_memo(p, _start_mark, _loop1_146_type, _seq); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17376 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17377 | } |
| 17378 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17379 | // _tmp_147: ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17380 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17381 | _tmp_147_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17382 | { |
| 17383 | if (p->error_indicator) { |
| 17384 | return NULL; |
| 17385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17386 | void * _res = NULL; |
| 17387 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17388 | { // ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17389 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17390 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17391 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17392 | ) |
| 17393 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17394 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17395 | goto done; |
| 17396 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17397 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17398 | } |
| 17399 | { // '**' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17400 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17401 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17402 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17403 | ) |
| 17404 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17405 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17406 | goto done; |
| 17407 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17408 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17409 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17410 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17411 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17412 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17413 | } |
| 17414 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17415 | // _tmp_148: ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17416 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17417 | _tmp_148_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17418 | { |
| 17419 | if (p->error_indicator) { |
| 17420 | return NULL; |
| 17421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17422 | void * _res = NULL; |
| 17423 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17424 | { // ':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17425 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17426 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17427 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17428 | ) |
| 17429 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17430 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17431 | goto done; |
| 17432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17433 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17434 | } |
| 17435 | { // '**' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17436 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17437 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17438 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17439 | ) |
| 17440 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17441 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17442 | goto done; |
| 17443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17444 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17445 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17446 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17447 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17448 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17449 | } |
| 17450 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17451 | void * |
| 17452 | _PyPegen_parse(Parser *p) |
| 17453 | { |
| 17454 | // Initialize keywords |
| 17455 | p->keywords = reserved_keywords; |
| 17456 | p->n_keyword_lists = n_keyword_lists; |
| 17457 | |
| 17458 | // Run parser |
| 17459 | void *result = NULL; |
| 17460 | if (p->start_rule == Py_file_input) { |
| 17461 | result = file_rule(p); |
| 17462 | } else if (p->start_rule == Py_single_input) { |
| 17463 | result = interactive_rule(p); |
| 17464 | } else if (p->start_rule == Py_eval_input) { |
| 17465 | result = eval_rule(p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17466 | } else if (p->start_rule == Py_func_type_input) { |
| 17467 | result = func_type_rule(p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17468 | } else if (p->start_rule == Py_fstring_input) { |
| 17469 | result = fstring_rule(p); |
| 17470 | } |
| 17471 | |
| 17472 | return result; |
| 17473 | } |
| 17474 | |
| 17475 | // The end |