Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1 | // @generated by pegen.py from ./Grammar/python.gram |
| 2 | #include "pegen.h" |
| 3 | static const int n_keyword_lists = 15; |
| 4 | static KeywordToken *reserved_keywords[] = { |
| 5 | NULL, |
| 6 | NULL, |
| 7 | (KeywordToken[]) { |
| 8 | {"if", 510}, |
| 9 | {"in", 518}, |
| 10 | {"is", 526}, |
| 11 | {"as", 531}, |
| 12 | {"or", 532}, |
| 13 | {NULL, -1}, |
| 14 | }, |
| 15 | (KeywordToken[]) { |
| 16 | {"del", 503}, |
| 17 | {"try", 511}, |
| 18 | {"for", 517}, |
| 19 | {"def", 522}, |
| 20 | {"not", 525}, |
| 21 | {"and", 533}, |
| 22 | {NULL, -1}, |
| 23 | }, |
| 24 | (KeywordToken[]) { |
| 25 | {"pass", 502}, |
| 26 | {"from", 514}, |
| 27 | {"elif", 515}, |
| 28 | {"else", 516}, |
| 29 | {"with", 519}, |
| 30 | {"True", 527}, |
| 31 | {"None", 529}, |
| 32 | {NULL, -1}, |
| 33 | }, |
| 34 | (KeywordToken[]) { |
| 35 | {"raise", 501}, |
| 36 | {"yield", 504}, |
| 37 | {"break", 506}, |
| 38 | {"while", 512}, |
| 39 | {"class", 523}, |
| 40 | {"False", 528}, |
| 41 | {NULL, -1}, |
| 42 | }, |
| 43 | (KeywordToken[]) { |
| 44 | {"return", 500}, |
| 45 | {"assert", 505}, |
| 46 | {"global", 508}, |
| 47 | {"import", 513}, |
| 48 | {"except", 520}, |
| 49 | {"lambda", 524}, |
| 50 | {NULL, -1}, |
| 51 | }, |
| 52 | (KeywordToken[]) { |
| 53 | {"finally", 521}, |
| 54 | {NULL, -1}, |
| 55 | }, |
| 56 | (KeywordToken[]) { |
| 57 | {"continue", 507}, |
| 58 | {"nonlocal", 509}, |
| 59 | {NULL, -1}, |
| 60 | }, |
| 61 | NULL, |
| 62 | NULL, |
| 63 | NULL, |
| 64 | NULL, |
| 65 | NULL, |
| 66 | (KeywordToken[]) { |
| 67 | {"__new_parser__", 530}, |
| 68 | {NULL, -1}, |
| 69 | }, |
| 70 | }; |
| 71 | #define file_type 1000 |
| 72 | #define interactive_type 1001 |
| 73 | #define eval_type 1002 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 74 | #define func_type_type 1003 |
| 75 | #define fstring_type 1004 |
| 76 | #define type_expressions_type 1005 |
| 77 | #define statements_type 1006 |
| 78 | #define statement_type 1007 |
| 79 | #define statement_newline_type 1008 |
| 80 | #define simple_stmt_type 1009 |
| 81 | #define small_stmt_type 1010 |
| 82 | #define compound_stmt_type 1011 |
| 83 | #define assignment_type 1012 |
| 84 | #define augassign_type 1013 |
| 85 | #define global_stmt_type 1014 |
| 86 | #define nonlocal_stmt_type 1015 |
| 87 | #define yield_stmt_type 1016 |
| 88 | #define assert_stmt_type 1017 |
| 89 | #define del_stmt_type 1018 |
| 90 | #define import_stmt_type 1019 |
| 91 | #define import_name_type 1020 |
| 92 | #define import_from_type 1021 |
| 93 | #define import_from_targets_type 1022 |
| 94 | #define import_from_as_names_type 1023 |
| 95 | #define import_from_as_name_type 1024 |
| 96 | #define dotted_as_names_type 1025 |
| 97 | #define dotted_as_name_type 1026 |
| 98 | #define dotted_name_type 1027 // Left-recursive |
| 99 | #define if_stmt_type 1028 |
| 100 | #define elif_stmt_type 1029 |
| 101 | #define else_block_type 1030 |
| 102 | #define while_stmt_type 1031 |
| 103 | #define for_stmt_type 1032 |
| 104 | #define with_stmt_type 1033 |
| 105 | #define with_item_type 1034 |
| 106 | #define try_stmt_type 1035 |
| 107 | #define except_block_type 1036 |
| 108 | #define finally_block_type 1037 |
| 109 | #define return_stmt_type 1038 |
| 110 | #define raise_stmt_type 1039 |
| 111 | #define function_def_type 1040 |
| 112 | #define function_def_raw_type 1041 |
| 113 | #define func_type_comment_type 1042 |
| 114 | #define params_type 1043 |
| 115 | #define parameters_type 1044 |
| 116 | #define slash_no_default_type 1045 |
| 117 | #define slash_with_default_type 1046 |
| 118 | #define star_etc_type 1047 |
| 119 | #define kwds_type 1048 |
| 120 | #define param_no_default_type 1049 |
| 121 | #define param_with_default_type 1050 |
| 122 | #define param_maybe_default_type 1051 |
| 123 | #define param_type 1052 |
| 124 | #define annotation_type 1053 |
| 125 | #define default_type 1054 |
| 126 | #define decorators_type 1055 |
| 127 | #define class_def_type 1056 |
| 128 | #define class_def_raw_type 1057 |
| 129 | #define block_type 1058 |
| 130 | #define expressions_list_type 1059 |
| 131 | #define star_expressions_type 1060 |
| 132 | #define star_expression_type 1061 |
| 133 | #define star_named_expressions_type 1062 |
| 134 | #define star_named_expression_type 1063 |
| 135 | #define named_expression_type 1064 |
| 136 | #define annotated_rhs_type 1065 |
| 137 | #define expressions_type 1066 |
| 138 | #define expression_type 1067 |
| 139 | #define lambdef_type 1068 |
| 140 | #define lambda_parameters_type 1069 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 141 | #define lambda_slash_no_default_type 1070 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 142 | #define lambda_slash_with_default_type 1071 |
| 143 | #define lambda_star_etc_type 1072 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 144 | #define lambda_kwds_type 1073 |
| 145 | #define lambda_param_no_default_type 1074 |
| 146 | #define lambda_param_with_default_type 1075 |
| 147 | #define lambda_param_maybe_default_type 1076 |
| 148 | #define lambda_param_type 1077 |
| 149 | #define disjunction_type 1078 |
| 150 | #define conjunction_type 1079 |
| 151 | #define inversion_type 1080 |
| 152 | #define comparison_type 1081 |
| 153 | #define compare_op_bitwise_or_pair_type 1082 |
| 154 | #define eq_bitwise_or_type 1083 |
| 155 | #define noteq_bitwise_or_type 1084 |
| 156 | #define lte_bitwise_or_type 1085 |
| 157 | #define lt_bitwise_or_type 1086 |
| 158 | #define gte_bitwise_or_type 1087 |
| 159 | #define gt_bitwise_or_type 1088 |
| 160 | #define notin_bitwise_or_type 1089 |
| 161 | #define in_bitwise_or_type 1090 |
| 162 | #define isnot_bitwise_or_type 1091 |
| 163 | #define is_bitwise_or_type 1092 |
| 164 | #define bitwise_or_type 1093 // Left-recursive |
| 165 | #define bitwise_xor_type 1094 // Left-recursive |
| 166 | #define bitwise_and_type 1095 // Left-recursive |
| 167 | #define shift_expr_type 1096 // Left-recursive |
| 168 | #define sum_type 1097 // Left-recursive |
| 169 | #define term_type 1098 // Left-recursive |
| 170 | #define factor_type 1099 |
| 171 | #define power_type 1100 |
| 172 | #define await_primary_type 1101 |
| 173 | #define primary_type 1102 // Left-recursive |
| 174 | #define slices_type 1103 |
| 175 | #define slice_type 1104 |
| 176 | #define atom_type 1105 |
| 177 | #define strings_type 1106 |
| 178 | #define list_type 1107 |
| 179 | #define listcomp_type 1108 |
| 180 | #define tuple_type 1109 |
| 181 | #define group_type 1110 |
| 182 | #define genexp_type 1111 |
| 183 | #define set_type 1112 |
| 184 | #define setcomp_type 1113 |
| 185 | #define dict_type 1114 |
| 186 | #define dictcomp_type 1115 |
| 187 | #define kvpairs_type 1116 |
| 188 | #define kvpair_type 1117 |
| 189 | #define for_if_clauses_type 1118 |
| 190 | #define for_if_clause_type 1119 |
| 191 | #define yield_expr_type 1120 |
| 192 | #define arguments_type 1121 |
| 193 | #define args_type 1122 |
| 194 | #define kwargs_type 1123 |
| 195 | #define starred_expression_type 1124 |
| 196 | #define kwarg_or_starred_type 1125 |
| 197 | #define kwarg_or_double_starred_type 1126 |
| 198 | #define star_targets_type 1127 |
| 199 | #define star_targets_seq_type 1128 |
| 200 | #define star_target_type 1129 |
| 201 | #define star_atom_type 1130 |
| 202 | #define inside_paren_ann_assign_target_type 1131 |
| 203 | #define ann_assign_subscript_attribute_target_type 1132 |
| 204 | #define del_targets_type 1133 |
| 205 | #define del_target_type 1134 |
| 206 | #define del_t_atom_type 1135 |
| 207 | #define targets_type 1136 |
| 208 | #define target_type 1137 |
| 209 | #define t_primary_type 1138 // Left-recursive |
| 210 | #define t_lookahead_type 1139 |
| 211 | #define t_atom_type 1140 |
| 212 | #define incorrect_arguments_type 1141 |
| 213 | #define invalid_named_expression_type 1142 |
| 214 | #define invalid_assignment_type 1143 |
| 215 | #define invalid_block_type 1144 |
| 216 | #define invalid_comprehension_type 1145 |
| 217 | #define invalid_parameters_type 1146 |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 218 | #define invalid_star_etc_type 1147 |
| 219 | #define invalid_lambda_star_etc_type 1148 |
| 220 | #define invalid_double_type_comments_type 1149 |
| 221 | #define _loop0_1_type 1150 |
| 222 | #define _loop0_2_type 1151 |
| 223 | #define _loop0_4_type 1152 |
| 224 | #define _gather_3_type 1153 |
| 225 | #define _loop0_6_type 1154 |
| 226 | #define _gather_5_type 1155 |
| 227 | #define _loop0_8_type 1156 |
| 228 | #define _gather_7_type 1157 |
| 229 | #define _loop0_10_type 1158 |
| 230 | #define _gather_9_type 1159 |
| 231 | #define _loop1_11_type 1160 |
| 232 | #define _loop0_13_type 1161 |
| 233 | #define _gather_12_type 1162 |
| 234 | #define _tmp_14_type 1163 |
| 235 | #define _tmp_15_type 1164 |
| 236 | #define _tmp_16_type 1165 |
| 237 | #define _tmp_17_type 1166 |
| 238 | #define _tmp_18_type 1167 |
| 239 | #define _tmp_19_type 1168 |
| 240 | #define _tmp_20_type 1169 |
| 241 | #define _tmp_21_type 1170 |
| 242 | #define _loop1_22_type 1171 |
| 243 | #define _tmp_23_type 1172 |
| 244 | #define _tmp_24_type 1173 |
| 245 | #define _loop0_26_type 1174 |
| 246 | #define _gather_25_type 1175 |
| 247 | #define _loop0_28_type 1176 |
| 248 | #define _gather_27_type 1177 |
| 249 | #define _tmp_29_type 1178 |
| 250 | #define _loop0_30_type 1179 |
| 251 | #define _loop1_31_type 1180 |
| 252 | #define _loop0_33_type 1181 |
| 253 | #define _gather_32_type 1182 |
| 254 | #define _tmp_34_type 1183 |
| 255 | #define _loop0_36_type 1184 |
| 256 | #define _gather_35_type 1185 |
| 257 | #define _tmp_37_type 1186 |
| 258 | #define _loop0_39_type 1187 |
| 259 | #define _gather_38_type 1188 |
| 260 | #define _loop0_41_type 1189 |
| 261 | #define _gather_40_type 1190 |
| 262 | #define _loop0_43_type 1191 |
| 263 | #define _gather_42_type 1192 |
| 264 | #define _loop0_45_type 1193 |
| 265 | #define _gather_44_type 1194 |
| 266 | #define _tmp_46_type 1195 |
| 267 | #define _loop1_47_type 1196 |
| 268 | #define _tmp_48_type 1197 |
| 269 | #define _tmp_49_type 1198 |
| 270 | #define _tmp_50_type 1199 |
| 271 | #define _tmp_51_type 1200 |
| 272 | #define _tmp_52_type 1201 |
| 273 | #define _loop0_53_type 1202 |
| 274 | #define _loop0_54_type 1203 |
| 275 | #define _loop0_55_type 1204 |
| 276 | #define _loop1_56_type 1205 |
| 277 | #define _loop0_57_type 1206 |
| 278 | #define _loop1_58_type 1207 |
| 279 | #define _loop1_59_type 1208 |
| 280 | #define _loop1_60_type 1209 |
| 281 | #define _loop0_61_type 1210 |
| 282 | #define _loop1_62_type 1211 |
| 283 | #define _loop0_63_type 1212 |
| 284 | #define _loop1_64_type 1213 |
| 285 | #define _loop0_65_type 1214 |
| 286 | #define _loop1_66_type 1215 |
| 287 | #define _loop1_67_type 1216 |
| 288 | #define _tmp_68_type 1217 |
| 289 | #define _loop0_70_type 1218 |
| 290 | #define _gather_69_type 1219 |
| 291 | #define _loop1_71_type 1220 |
| 292 | #define _loop0_73_type 1221 |
| 293 | #define _gather_72_type 1222 |
| 294 | #define _loop1_74_type 1223 |
| 295 | #define _loop0_75_type 1224 |
| 296 | #define _loop0_76_type 1225 |
| 297 | #define _loop0_77_type 1226 |
| 298 | #define _loop1_78_type 1227 |
| 299 | #define _loop0_79_type 1228 |
| 300 | #define _loop1_80_type 1229 |
| 301 | #define _loop1_81_type 1230 |
| 302 | #define _loop1_82_type 1231 |
| 303 | #define _loop0_83_type 1232 |
| 304 | #define _loop1_84_type 1233 |
| 305 | #define _loop0_85_type 1234 |
| 306 | #define _loop1_86_type 1235 |
| 307 | #define _loop0_87_type 1236 |
| 308 | #define _loop1_88_type 1237 |
| 309 | #define _loop1_89_type 1238 |
| 310 | #define _loop1_90_type 1239 |
| 311 | #define _loop1_91_type 1240 |
| 312 | #define _tmp_92_type 1241 |
| 313 | #define _loop0_94_type 1242 |
| 314 | #define _gather_93_type 1243 |
| 315 | #define _tmp_95_type 1244 |
| 316 | #define _tmp_96_type 1245 |
| 317 | #define _tmp_97_type 1246 |
| 318 | #define _tmp_98_type 1247 |
| 319 | #define _loop1_99_type 1248 |
| 320 | #define _tmp_100_type 1249 |
| 321 | #define _tmp_101_type 1250 |
| 322 | #define _loop0_103_type 1251 |
| 323 | #define _gather_102_type 1252 |
| 324 | #define _loop1_104_type 1253 |
| 325 | #define _loop0_105_type 1254 |
| 326 | #define _loop0_106_type 1255 |
| 327 | #define _tmp_107_type 1256 |
| 328 | #define _tmp_108_type 1257 |
| 329 | #define _loop0_110_type 1258 |
| 330 | #define _gather_109_type 1259 |
| 331 | #define _loop0_112_type 1260 |
| 332 | #define _gather_111_type 1261 |
| 333 | #define _loop0_114_type 1262 |
| 334 | #define _gather_113_type 1263 |
| 335 | #define _loop0_116_type 1264 |
| 336 | #define _gather_115_type 1265 |
| 337 | #define _loop0_117_type 1266 |
| 338 | #define _loop0_119_type 1267 |
| 339 | #define _gather_118_type 1268 |
| 340 | #define _tmp_120_type 1269 |
| 341 | #define _loop0_122_type 1270 |
| 342 | #define _gather_121_type 1271 |
| 343 | #define _loop0_124_type 1272 |
| 344 | #define _gather_123_type 1273 |
| 345 | #define _tmp_125_type 1274 |
| 346 | #define _tmp_126_type 1275 |
| 347 | #define _tmp_127_type 1276 |
| 348 | #define _tmp_128_type 1277 |
| 349 | #define _tmp_129_type 1278 |
| 350 | #define _loop0_130_type 1279 |
| 351 | #define _tmp_131_type 1280 |
| 352 | #define _tmp_132_type 1281 |
| 353 | #define _tmp_133_type 1282 |
| 354 | #define _tmp_134_type 1283 |
| 355 | #define _tmp_135_type 1284 |
| 356 | #define _tmp_136_type 1285 |
| 357 | #define _tmp_137_type 1286 |
| 358 | #define _tmp_138_type 1287 |
| 359 | #define _tmp_139_type 1288 |
| 360 | #define _tmp_140_type 1289 |
| 361 | #define _tmp_141_type 1290 |
| 362 | #define _tmp_142_type 1291 |
| 363 | #define _tmp_143_type 1292 |
| 364 | #define _tmp_144_type 1293 |
| 365 | #define _loop1_145_type 1294 |
| 366 | #define _tmp_146_type 1295 |
| 367 | #define _tmp_147_type 1296 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 368 | |
| 369 | static mod_ty file_rule(Parser *p); |
| 370 | static mod_ty interactive_rule(Parser *p); |
| 371 | static mod_ty eval_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 372 | static mod_ty func_type_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 373 | static expr_ty fstring_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 374 | static asdl_seq* type_expressions_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 375 | static asdl_seq* statements_rule(Parser *p); |
| 376 | static asdl_seq* statement_rule(Parser *p); |
| 377 | static asdl_seq* statement_newline_rule(Parser *p); |
| 378 | static asdl_seq* simple_stmt_rule(Parser *p); |
| 379 | static stmt_ty small_stmt_rule(Parser *p); |
| 380 | static stmt_ty compound_stmt_rule(Parser *p); |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 381 | static stmt_ty assignment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 382 | static AugOperator* augassign_rule(Parser *p); |
| 383 | static stmt_ty global_stmt_rule(Parser *p); |
| 384 | static stmt_ty nonlocal_stmt_rule(Parser *p); |
| 385 | static stmt_ty yield_stmt_rule(Parser *p); |
| 386 | static stmt_ty assert_stmt_rule(Parser *p); |
| 387 | static stmt_ty del_stmt_rule(Parser *p); |
| 388 | static stmt_ty import_stmt_rule(Parser *p); |
| 389 | static stmt_ty import_name_rule(Parser *p); |
| 390 | static stmt_ty import_from_rule(Parser *p); |
| 391 | static asdl_seq* import_from_targets_rule(Parser *p); |
| 392 | static asdl_seq* import_from_as_names_rule(Parser *p); |
| 393 | static alias_ty import_from_as_name_rule(Parser *p); |
| 394 | static asdl_seq* dotted_as_names_rule(Parser *p); |
| 395 | static alias_ty dotted_as_name_rule(Parser *p); |
| 396 | static expr_ty dotted_name_rule(Parser *p); |
| 397 | static stmt_ty if_stmt_rule(Parser *p); |
| 398 | static stmt_ty elif_stmt_rule(Parser *p); |
| 399 | static asdl_seq* else_block_rule(Parser *p); |
| 400 | static stmt_ty while_stmt_rule(Parser *p); |
| 401 | static stmt_ty for_stmt_rule(Parser *p); |
| 402 | static stmt_ty with_stmt_rule(Parser *p); |
| 403 | static withitem_ty with_item_rule(Parser *p); |
| 404 | static stmt_ty try_stmt_rule(Parser *p); |
| 405 | static excepthandler_ty except_block_rule(Parser *p); |
| 406 | static asdl_seq* finally_block_rule(Parser *p); |
| 407 | static stmt_ty return_stmt_rule(Parser *p); |
| 408 | static stmt_ty raise_stmt_rule(Parser *p); |
| 409 | static stmt_ty function_def_rule(Parser *p); |
| 410 | static stmt_ty function_def_raw_rule(Parser *p); |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 411 | static Token* func_type_comment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 412 | static arguments_ty params_rule(Parser *p); |
| 413 | static arguments_ty parameters_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 414 | static asdl_seq* slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 415 | static SlashWithDefault* slash_with_default_rule(Parser *p); |
| 416 | static StarEtc* star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 417 | static arg_ty kwds_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 418 | static arg_ty param_no_default_rule(Parser *p); |
| 419 | static NameDefaultPair* param_with_default_rule(Parser *p); |
| 420 | static NameDefaultPair* param_maybe_default_rule(Parser *p); |
| 421 | static arg_ty param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 422 | static expr_ty annotation_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 423 | static expr_ty default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 424 | static asdl_seq* decorators_rule(Parser *p); |
| 425 | static stmt_ty class_def_rule(Parser *p); |
| 426 | static stmt_ty class_def_raw_rule(Parser *p); |
| 427 | static asdl_seq* block_rule(Parser *p); |
| 428 | static asdl_seq* expressions_list_rule(Parser *p); |
| 429 | static expr_ty star_expressions_rule(Parser *p); |
| 430 | static expr_ty star_expression_rule(Parser *p); |
| 431 | static asdl_seq* star_named_expressions_rule(Parser *p); |
| 432 | static expr_ty star_named_expression_rule(Parser *p); |
| 433 | static expr_ty named_expression_rule(Parser *p); |
| 434 | static expr_ty annotated_rhs_rule(Parser *p); |
| 435 | static expr_ty expressions_rule(Parser *p); |
| 436 | static expr_ty expression_rule(Parser *p); |
| 437 | static expr_ty lambdef_rule(Parser *p); |
| 438 | static arguments_ty lambda_parameters_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 439 | static asdl_seq* lambda_slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 440 | static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); |
| 441 | static StarEtc* lambda_star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 442 | static arg_ty lambda_kwds_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 443 | static arg_ty lambda_param_no_default_rule(Parser *p); |
| 444 | static NameDefaultPair* lambda_param_with_default_rule(Parser *p); |
| 445 | static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); |
| 446 | static arg_ty lambda_param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 447 | static expr_ty disjunction_rule(Parser *p); |
| 448 | static expr_ty conjunction_rule(Parser *p); |
| 449 | static expr_ty inversion_rule(Parser *p); |
| 450 | static expr_ty comparison_rule(Parser *p); |
| 451 | static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); |
| 452 | static CmpopExprPair* eq_bitwise_or_rule(Parser *p); |
| 453 | static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); |
| 454 | static CmpopExprPair* lte_bitwise_or_rule(Parser *p); |
| 455 | static CmpopExprPair* lt_bitwise_or_rule(Parser *p); |
| 456 | static CmpopExprPair* gte_bitwise_or_rule(Parser *p); |
| 457 | static CmpopExprPair* gt_bitwise_or_rule(Parser *p); |
| 458 | static CmpopExprPair* notin_bitwise_or_rule(Parser *p); |
| 459 | static CmpopExprPair* in_bitwise_or_rule(Parser *p); |
| 460 | static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); |
| 461 | static CmpopExprPair* is_bitwise_or_rule(Parser *p); |
| 462 | static expr_ty bitwise_or_rule(Parser *p); |
| 463 | static expr_ty bitwise_xor_rule(Parser *p); |
| 464 | static expr_ty bitwise_and_rule(Parser *p); |
| 465 | static expr_ty shift_expr_rule(Parser *p); |
| 466 | static expr_ty sum_rule(Parser *p); |
| 467 | static expr_ty term_rule(Parser *p); |
| 468 | static expr_ty factor_rule(Parser *p); |
| 469 | static expr_ty power_rule(Parser *p); |
| 470 | static expr_ty await_primary_rule(Parser *p); |
| 471 | static expr_ty primary_rule(Parser *p); |
| 472 | static expr_ty slices_rule(Parser *p); |
| 473 | static expr_ty slice_rule(Parser *p); |
| 474 | static expr_ty atom_rule(Parser *p); |
| 475 | static expr_ty strings_rule(Parser *p); |
| 476 | static expr_ty list_rule(Parser *p); |
| 477 | static expr_ty listcomp_rule(Parser *p); |
| 478 | static expr_ty tuple_rule(Parser *p); |
| 479 | static expr_ty group_rule(Parser *p); |
| 480 | static expr_ty genexp_rule(Parser *p); |
| 481 | static expr_ty set_rule(Parser *p); |
| 482 | static expr_ty setcomp_rule(Parser *p); |
| 483 | static expr_ty dict_rule(Parser *p); |
| 484 | static expr_ty dictcomp_rule(Parser *p); |
| 485 | static asdl_seq* kvpairs_rule(Parser *p); |
| 486 | static KeyValuePair* kvpair_rule(Parser *p); |
| 487 | static asdl_seq* for_if_clauses_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 488 | static comprehension_ty for_if_clause_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 489 | static expr_ty yield_expr_rule(Parser *p); |
| 490 | static expr_ty arguments_rule(Parser *p); |
| 491 | static expr_ty args_rule(Parser *p); |
| 492 | static asdl_seq* kwargs_rule(Parser *p); |
| 493 | static expr_ty starred_expression_rule(Parser *p); |
| 494 | static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); |
| 495 | static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); |
| 496 | static expr_ty star_targets_rule(Parser *p); |
| 497 | static asdl_seq* star_targets_seq_rule(Parser *p); |
| 498 | static expr_ty star_target_rule(Parser *p); |
| 499 | static expr_ty star_atom_rule(Parser *p); |
| 500 | static expr_ty inside_paren_ann_assign_target_rule(Parser *p); |
| 501 | static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p); |
| 502 | static asdl_seq* del_targets_rule(Parser *p); |
| 503 | static expr_ty del_target_rule(Parser *p); |
| 504 | static expr_ty del_t_atom_rule(Parser *p); |
| 505 | static asdl_seq* targets_rule(Parser *p); |
| 506 | static expr_ty target_rule(Parser *p); |
| 507 | static expr_ty t_primary_rule(Parser *p); |
| 508 | static void *t_lookahead_rule(Parser *p); |
| 509 | static expr_ty t_atom_rule(Parser *p); |
| 510 | static void *incorrect_arguments_rule(Parser *p); |
| 511 | static void *invalid_named_expression_rule(Parser *p); |
| 512 | static void *invalid_assignment_rule(Parser *p); |
| 513 | static void *invalid_block_rule(Parser *p); |
| 514 | static void *invalid_comprehension_rule(Parser *p); |
| 515 | static void *invalid_parameters_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 516 | static void *invalid_star_etc_rule(Parser *p); |
| 517 | static void *invalid_lambda_star_etc_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 518 | static void *invalid_double_type_comments_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 519 | static asdl_seq *_loop0_1_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 520 | static asdl_seq *_loop0_2_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 521 | static asdl_seq *_loop0_4_rule(Parser *p); |
| 522 | static asdl_seq *_gather_3_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 523 | static asdl_seq *_loop0_6_rule(Parser *p); |
| 524 | static asdl_seq *_gather_5_rule(Parser *p); |
| 525 | static asdl_seq *_loop0_8_rule(Parser *p); |
| 526 | static asdl_seq *_gather_7_rule(Parser *p); |
| 527 | static asdl_seq *_loop0_10_rule(Parser *p); |
| 528 | static asdl_seq *_gather_9_rule(Parser *p); |
| 529 | static asdl_seq *_loop1_11_rule(Parser *p); |
| 530 | static asdl_seq *_loop0_13_rule(Parser *p); |
| 531 | static asdl_seq *_gather_12_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 532 | static void *_tmp_14_rule(Parser *p); |
| 533 | static void *_tmp_15_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 534 | static void *_tmp_16_rule(Parser *p); |
| 535 | static void *_tmp_17_rule(Parser *p); |
| 536 | static void *_tmp_18_rule(Parser *p); |
| 537 | static void *_tmp_19_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 538 | static void *_tmp_20_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 539 | static void *_tmp_21_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 540 | static asdl_seq *_loop1_22_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 541 | static void *_tmp_23_rule(Parser *p); |
| 542 | static void *_tmp_24_rule(Parser *p); |
| 543 | static asdl_seq *_loop0_26_rule(Parser *p); |
| 544 | static asdl_seq *_gather_25_rule(Parser *p); |
| 545 | static asdl_seq *_loop0_28_rule(Parser *p); |
| 546 | static asdl_seq *_gather_27_rule(Parser *p); |
| 547 | static void *_tmp_29_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 548 | static asdl_seq *_loop0_30_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 549 | static asdl_seq *_loop1_31_rule(Parser *p); |
| 550 | static asdl_seq *_loop0_33_rule(Parser *p); |
| 551 | static asdl_seq *_gather_32_rule(Parser *p); |
| 552 | static void *_tmp_34_rule(Parser *p); |
| 553 | static asdl_seq *_loop0_36_rule(Parser *p); |
| 554 | static asdl_seq *_gather_35_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 555 | static void *_tmp_37_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 556 | static asdl_seq *_loop0_39_rule(Parser *p); |
| 557 | static asdl_seq *_gather_38_rule(Parser *p); |
| 558 | static asdl_seq *_loop0_41_rule(Parser *p); |
| 559 | static asdl_seq *_gather_40_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 560 | static asdl_seq *_loop0_43_rule(Parser *p); |
| 561 | static asdl_seq *_gather_42_rule(Parser *p); |
| 562 | static asdl_seq *_loop0_45_rule(Parser *p); |
| 563 | static asdl_seq *_gather_44_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 564 | static void *_tmp_46_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 565 | static asdl_seq *_loop1_47_rule(Parser *p); |
| 566 | static void *_tmp_48_rule(Parser *p); |
| 567 | static void *_tmp_49_rule(Parser *p); |
| 568 | static void *_tmp_50_rule(Parser *p); |
| 569 | static void *_tmp_51_rule(Parser *p); |
| 570 | static void *_tmp_52_rule(Parser *p); |
| 571 | static asdl_seq *_loop0_53_rule(Parser *p); |
| 572 | static asdl_seq *_loop0_54_rule(Parser *p); |
| 573 | static asdl_seq *_loop0_55_rule(Parser *p); |
| 574 | static asdl_seq *_loop1_56_rule(Parser *p); |
| 575 | static asdl_seq *_loop0_57_rule(Parser *p); |
| 576 | static asdl_seq *_loop1_58_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 577 | static asdl_seq *_loop1_59_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 578 | static asdl_seq *_loop1_60_rule(Parser *p); |
| 579 | static asdl_seq *_loop0_61_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 580 | static asdl_seq *_loop1_62_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 581 | static asdl_seq *_loop0_63_rule(Parser *p); |
| 582 | static asdl_seq *_loop1_64_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 583 | static asdl_seq *_loop0_65_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 584 | static asdl_seq *_loop1_66_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 585 | static asdl_seq *_loop1_67_rule(Parser *p); |
| 586 | static void *_tmp_68_rule(Parser *p); |
| 587 | static asdl_seq *_loop0_70_rule(Parser *p); |
| 588 | static asdl_seq *_gather_69_rule(Parser *p); |
| 589 | static asdl_seq *_loop1_71_rule(Parser *p); |
| 590 | static asdl_seq *_loop0_73_rule(Parser *p); |
| 591 | static asdl_seq *_gather_72_rule(Parser *p); |
| 592 | static asdl_seq *_loop1_74_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 593 | static asdl_seq *_loop0_75_rule(Parser *p); |
| 594 | static asdl_seq *_loop0_76_rule(Parser *p); |
| 595 | static asdl_seq *_loop0_77_rule(Parser *p); |
| 596 | static asdl_seq *_loop1_78_rule(Parser *p); |
| 597 | static asdl_seq *_loop0_79_rule(Parser *p); |
| 598 | static asdl_seq *_loop1_80_rule(Parser *p); |
| 599 | static asdl_seq *_loop1_81_rule(Parser *p); |
| 600 | static asdl_seq *_loop1_82_rule(Parser *p); |
| 601 | static asdl_seq *_loop0_83_rule(Parser *p); |
| 602 | static asdl_seq *_loop1_84_rule(Parser *p); |
| 603 | static asdl_seq *_loop0_85_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 604 | static asdl_seq *_loop1_86_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 605 | static asdl_seq *_loop0_87_rule(Parser *p); |
| 606 | static asdl_seq *_loop1_88_rule(Parser *p); |
| 607 | static asdl_seq *_loop1_89_rule(Parser *p); |
| 608 | static asdl_seq *_loop1_90_rule(Parser *p); |
| 609 | static asdl_seq *_loop1_91_rule(Parser *p); |
| 610 | static void *_tmp_92_rule(Parser *p); |
| 611 | static asdl_seq *_loop0_94_rule(Parser *p); |
| 612 | static asdl_seq *_gather_93_rule(Parser *p); |
| 613 | static void *_tmp_95_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 614 | static void *_tmp_96_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 615 | static void *_tmp_97_rule(Parser *p); |
| 616 | static void *_tmp_98_rule(Parser *p); |
| 617 | static asdl_seq *_loop1_99_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 618 | static void *_tmp_100_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 619 | static void *_tmp_101_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 620 | static asdl_seq *_loop0_103_rule(Parser *p); |
| 621 | static asdl_seq *_gather_102_rule(Parser *p); |
| 622 | static asdl_seq *_loop1_104_rule(Parser *p); |
| 623 | static asdl_seq *_loop0_105_rule(Parser *p); |
| 624 | static asdl_seq *_loop0_106_rule(Parser *p); |
| 625 | static void *_tmp_107_rule(Parser *p); |
| 626 | static void *_tmp_108_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 627 | static asdl_seq *_loop0_110_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 628 | static asdl_seq *_gather_109_rule(Parser *p); |
| 629 | static asdl_seq *_loop0_112_rule(Parser *p); |
| 630 | static asdl_seq *_gather_111_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 631 | static asdl_seq *_loop0_114_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 632 | static asdl_seq *_gather_113_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 633 | static asdl_seq *_loop0_116_rule(Parser *p); |
| 634 | static asdl_seq *_gather_115_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 635 | static asdl_seq *_loop0_117_rule(Parser *p); |
| 636 | static asdl_seq *_loop0_119_rule(Parser *p); |
| 637 | static asdl_seq *_gather_118_rule(Parser *p); |
| 638 | static void *_tmp_120_rule(Parser *p); |
| 639 | static asdl_seq *_loop0_122_rule(Parser *p); |
| 640 | static asdl_seq *_gather_121_rule(Parser *p); |
| 641 | static asdl_seq *_loop0_124_rule(Parser *p); |
| 642 | static asdl_seq *_gather_123_rule(Parser *p); |
| 643 | static void *_tmp_125_rule(Parser *p); |
| 644 | static void *_tmp_126_rule(Parser *p); |
| 645 | static void *_tmp_127_rule(Parser *p); |
| 646 | static void *_tmp_128_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 647 | static void *_tmp_129_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 648 | static asdl_seq *_loop0_130_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 649 | static void *_tmp_131_rule(Parser *p); |
| 650 | static void *_tmp_132_rule(Parser *p); |
| 651 | static void *_tmp_133_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 652 | static void *_tmp_134_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 653 | static void *_tmp_135_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 654 | static void *_tmp_136_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 655 | static void *_tmp_137_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 656 | static void *_tmp_138_rule(Parser *p); |
| 657 | static void *_tmp_139_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 658 | static void *_tmp_140_rule(Parser *p); |
| 659 | static void *_tmp_141_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 660 | static void *_tmp_142_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 661 | static void *_tmp_143_rule(Parser *p); |
| 662 | static void *_tmp_144_rule(Parser *p); |
| 663 | static asdl_seq *_loop1_145_rule(Parser *p); |
| 664 | static void *_tmp_146_rule(Parser *p); |
| 665 | static void *_tmp_147_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 666 | |
| 667 | |
| 668 | // file: statements? $ |
| 669 | static mod_ty |
| 670 | file_rule(Parser *p) |
| 671 | { |
| 672 | if (p->error_indicator) { |
| 673 | return NULL; |
| 674 | } |
| 675 | mod_ty res = NULL; |
| 676 | int mark = p->mark; |
| 677 | { // statements? $ |
| 678 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 679 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 680 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 681 | (a = statements_rule(p), 1) // statements? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 682 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 683 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 684 | ) |
| 685 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 686 | res = _PyPegen_make_module ( p , a ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 687 | if (res == NULL && PyErr_Occurred()) { |
| 688 | p->error_indicator = 1; |
| 689 | return NULL; |
| 690 | } |
| 691 | goto done; |
| 692 | } |
| 693 | p->mark = mark; |
| 694 | } |
| 695 | res = NULL; |
| 696 | done: |
| 697 | return res; |
| 698 | } |
| 699 | |
| 700 | // interactive: statement_newline |
| 701 | static mod_ty |
| 702 | interactive_rule(Parser *p) |
| 703 | { |
| 704 | if (p->error_indicator) { |
| 705 | return NULL; |
| 706 | } |
| 707 | mod_ty res = NULL; |
| 708 | int mark = p->mark; |
| 709 | { // statement_newline |
| 710 | asdl_seq* a; |
| 711 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 712 | (a = statement_newline_rule(p)) // statement_newline |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 713 | ) |
| 714 | { |
| 715 | res = Interactive ( a , p -> arena ); |
| 716 | if (res == NULL && PyErr_Occurred()) { |
| 717 | p->error_indicator = 1; |
| 718 | return NULL; |
| 719 | } |
| 720 | goto done; |
| 721 | } |
| 722 | p->mark = mark; |
| 723 | } |
| 724 | res = NULL; |
| 725 | done: |
| 726 | return res; |
| 727 | } |
| 728 | |
| 729 | // eval: expressions NEWLINE* $ |
| 730 | static mod_ty |
| 731 | eval_rule(Parser *p) |
| 732 | { |
| 733 | if (p->error_indicator) { |
| 734 | return NULL; |
| 735 | } |
| 736 | mod_ty res = NULL; |
| 737 | int mark = p->mark; |
| 738 | { // expressions NEWLINE* $ |
| 739 | asdl_seq * _loop0_1_var; |
| 740 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 741 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 742 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 743 | (a = expressions_rule(p)) // expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 744 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 745 | (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 746 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 747 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 748 | ) |
| 749 | { |
| 750 | res = Expression ( a , p -> arena ); |
| 751 | if (res == NULL && PyErr_Occurred()) { |
| 752 | p->error_indicator = 1; |
| 753 | return NULL; |
| 754 | } |
| 755 | goto done; |
| 756 | } |
| 757 | p->mark = mark; |
| 758 | } |
| 759 | res = NULL; |
| 760 | done: |
| 761 | return res; |
| 762 | } |
| 763 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 764 | // func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 765 | static mod_ty |
| 766 | func_type_rule(Parser *p) |
| 767 | { |
| 768 | if (p->error_indicator) { |
| 769 | return NULL; |
| 770 | } |
| 771 | mod_ty res = NULL; |
| 772 | int mark = p->mark; |
| 773 | { // '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 774 | asdl_seq * _loop0_2_var; |
| 775 | void *a; |
| 776 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 777 | Token * endmarker_var; |
| 778 | Token * literal; |
| 779 | Token * literal_1; |
| 780 | Token * literal_2; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 781 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 782 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 783 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 784 | (a = type_expressions_rule(p), 1) // type_expressions? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 785 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 786 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 787 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 788 | (literal_2 = _PyPegen_expect_token(p, 51)) // token='->' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 789 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 790 | (b = expression_rule(p)) // expression |
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 | (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 793 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 794 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 795 | ) |
| 796 | { |
| 797 | res = FunctionType ( a , b , p -> arena ); |
| 798 | if (res == NULL && PyErr_Occurred()) { |
| 799 | p->error_indicator = 1; |
| 800 | return NULL; |
| 801 | } |
| 802 | goto done; |
| 803 | } |
| 804 | p->mark = mark; |
| 805 | } |
| 806 | res = NULL; |
| 807 | done: |
| 808 | return res; |
| 809 | } |
| 810 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 811 | // fstring: star_expressions |
| 812 | static expr_ty |
| 813 | fstring_rule(Parser *p) |
| 814 | { |
| 815 | if (p->error_indicator) { |
| 816 | return NULL; |
| 817 | } |
| 818 | expr_ty res = NULL; |
| 819 | int mark = p->mark; |
| 820 | { // star_expressions |
| 821 | expr_ty star_expressions_var; |
| 822 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 823 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 824 | ) |
| 825 | { |
| 826 | res = star_expressions_var; |
| 827 | goto done; |
| 828 | } |
| 829 | p->mark = mark; |
| 830 | } |
| 831 | res = NULL; |
| 832 | done: |
| 833 | return res; |
| 834 | } |
| 835 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 836 | // type_expressions: |
| 837 | // | ','.expression+ ',' '*' expression ',' '**' expression |
| 838 | // | ','.expression+ ',' '*' expression |
| 839 | // | ','.expression+ ',' '**' expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 840 | // | '*' expression ',' '**' expression |
| 841 | // | '*' expression |
| 842 | // | '**' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 843 | // | ','.expression+ |
| 844 | static asdl_seq* |
| 845 | type_expressions_rule(Parser *p) |
| 846 | { |
| 847 | if (p->error_indicator) { |
| 848 | return NULL; |
| 849 | } |
| 850 | asdl_seq* res = NULL; |
| 851 | int mark = p->mark; |
| 852 | { // ','.expression+ ',' '*' expression ',' '**' expression |
| 853 | asdl_seq * a; |
| 854 | expr_ty b; |
| 855 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 856 | Token * literal; |
| 857 | Token * literal_1; |
| 858 | Token * literal_2; |
| 859 | Token * literal_3; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 860 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 861 | (a = _gather_3_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 862 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 863 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 864 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 865 | (literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 866 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 867 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 868 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 869 | (literal_2 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 870 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 871 | (literal_3 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 872 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 873 | (c = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 874 | ) |
| 875 | { |
| 876 | res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); |
| 877 | if (res == NULL && PyErr_Occurred()) { |
| 878 | p->error_indicator = 1; |
| 879 | return NULL; |
| 880 | } |
| 881 | goto done; |
| 882 | } |
| 883 | p->mark = mark; |
| 884 | } |
| 885 | { // ','.expression+ ',' '*' expression |
| 886 | asdl_seq * a; |
| 887 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 888 | Token * literal; |
| 889 | Token * literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 890 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 891 | (a = _gather_5_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 892 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 893 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 894 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 895 | (literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 896 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 897 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 898 | ) |
| 899 | { |
| 900 | res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 901 | if (res == NULL && PyErr_Occurred()) { |
| 902 | p->error_indicator = 1; |
| 903 | return NULL; |
| 904 | } |
| 905 | goto done; |
| 906 | } |
| 907 | p->mark = mark; |
| 908 | } |
| 909 | { // ','.expression+ ',' '**' expression |
| 910 | asdl_seq * a; |
| 911 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 912 | Token * literal; |
| 913 | Token * literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 914 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 915 | (a = _gather_7_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 916 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 917 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 918 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 919 | (literal_1 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 920 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 921 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 922 | ) |
| 923 | { |
| 924 | res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 925 | if (res == NULL && PyErr_Occurred()) { |
| 926 | p->error_indicator = 1; |
| 927 | return NULL; |
| 928 | } |
| 929 | goto done; |
| 930 | } |
| 931 | p->mark = mark; |
| 932 | } |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 933 | { // '*' expression ',' '**' expression |
| 934 | expr_ty a; |
| 935 | expr_ty b; |
| 936 | Token * literal; |
| 937 | Token * literal_1; |
| 938 | Token * literal_2; |
| 939 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 940 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 941 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 942 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 943 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 944 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 945 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 946 | (literal_2 = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 947 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 948 | (b = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 949 | ) |
| 950 | { |
| 951 | res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b ); |
| 952 | if (res == NULL && PyErr_Occurred()) { |
| 953 | p->error_indicator = 1; |
| 954 | return NULL; |
| 955 | } |
| 956 | goto done; |
| 957 | } |
| 958 | p->mark = mark; |
| 959 | } |
| 960 | { // '*' expression |
| 961 | expr_ty a; |
| 962 | Token * literal; |
| 963 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 964 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 965 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 966 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 967 | ) |
| 968 | { |
| 969 | res = _PyPegen_singleton_seq ( p , a ); |
| 970 | if (res == NULL && PyErr_Occurred()) { |
| 971 | p->error_indicator = 1; |
| 972 | return NULL; |
| 973 | } |
| 974 | goto done; |
| 975 | } |
| 976 | p->mark = mark; |
| 977 | } |
| 978 | { // '**' expression |
| 979 | expr_ty a; |
| 980 | Token * literal; |
| 981 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 982 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 983 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 984 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 985 | ) |
| 986 | { |
| 987 | res = _PyPegen_singleton_seq ( p , a ); |
| 988 | if (res == NULL && PyErr_Occurred()) { |
| 989 | p->error_indicator = 1; |
| 990 | return NULL; |
| 991 | } |
| 992 | goto done; |
| 993 | } |
| 994 | p->mark = mark; |
| 995 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 996 | { // ','.expression+ |
| 997 | asdl_seq * _gather_9_var; |
| 998 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 999 | (_gather_9_var = _gather_9_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1000 | ) |
| 1001 | { |
| 1002 | res = _gather_9_var; |
| 1003 | goto done; |
| 1004 | } |
| 1005 | p->mark = mark; |
| 1006 | } |
| 1007 | res = NULL; |
| 1008 | done: |
| 1009 | return res; |
| 1010 | } |
| 1011 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1012 | // statements: statement+ |
| 1013 | static asdl_seq* |
| 1014 | statements_rule(Parser *p) |
| 1015 | { |
| 1016 | if (p->error_indicator) { |
| 1017 | return NULL; |
| 1018 | } |
| 1019 | asdl_seq* res = NULL; |
| 1020 | int mark = p->mark; |
| 1021 | { // statement+ |
| 1022 | asdl_seq * a; |
| 1023 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1024 | (a = _loop1_11_rule(p)) // statement+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1025 | ) |
| 1026 | { |
| 1027 | res = _PyPegen_seq_flatten ( p , a ); |
| 1028 | if (res == NULL && PyErr_Occurred()) { |
| 1029 | p->error_indicator = 1; |
| 1030 | return NULL; |
| 1031 | } |
| 1032 | goto done; |
| 1033 | } |
| 1034 | p->mark = mark; |
| 1035 | } |
| 1036 | res = NULL; |
| 1037 | done: |
| 1038 | return res; |
| 1039 | } |
| 1040 | |
| 1041 | // statement: compound_stmt | simple_stmt |
| 1042 | static asdl_seq* |
| 1043 | statement_rule(Parser *p) |
| 1044 | { |
| 1045 | if (p->error_indicator) { |
| 1046 | return NULL; |
| 1047 | } |
| 1048 | asdl_seq* res = NULL; |
| 1049 | int mark = p->mark; |
| 1050 | { // compound_stmt |
| 1051 | stmt_ty a; |
| 1052 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1053 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1054 | ) |
| 1055 | { |
| 1056 | res = _PyPegen_singleton_seq ( p , a ); |
| 1057 | if (res == NULL && PyErr_Occurred()) { |
| 1058 | p->error_indicator = 1; |
| 1059 | return NULL; |
| 1060 | } |
| 1061 | goto done; |
| 1062 | } |
| 1063 | p->mark = mark; |
| 1064 | } |
| 1065 | { // simple_stmt |
| 1066 | asdl_seq* simple_stmt_var; |
| 1067 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1068 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1069 | ) |
| 1070 | { |
| 1071 | res = simple_stmt_var; |
| 1072 | goto done; |
| 1073 | } |
| 1074 | p->mark = mark; |
| 1075 | } |
| 1076 | res = NULL; |
| 1077 | done: |
| 1078 | return res; |
| 1079 | } |
| 1080 | |
| 1081 | // statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $ |
| 1082 | static asdl_seq* |
| 1083 | statement_newline_rule(Parser *p) |
| 1084 | { |
| 1085 | if (p->error_indicator) { |
| 1086 | return NULL; |
| 1087 | } |
| 1088 | asdl_seq* res = NULL; |
| 1089 | int mark = p->mark; |
| 1090 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1091 | p->error_indicator = 1; |
| 1092 | return NULL; |
| 1093 | } |
| 1094 | int start_lineno = p->tokens[mark]->lineno; |
| 1095 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1096 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1097 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1098 | { // compound_stmt NEWLINE |
| 1099 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1100 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1101 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1102 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1103 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1104 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1105 | ) |
| 1106 | { |
| 1107 | res = _PyPegen_singleton_seq ( p , a ); |
| 1108 | if (res == NULL && PyErr_Occurred()) { |
| 1109 | p->error_indicator = 1; |
| 1110 | return NULL; |
| 1111 | } |
| 1112 | goto done; |
| 1113 | } |
| 1114 | p->mark = mark; |
| 1115 | } |
| 1116 | { // simple_stmt |
| 1117 | asdl_seq* simple_stmt_var; |
| 1118 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1119 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1120 | ) |
| 1121 | { |
| 1122 | res = simple_stmt_var; |
| 1123 | goto done; |
| 1124 | } |
| 1125 | p->mark = mark; |
| 1126 | } |
| 1127 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1128 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1129 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1130 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1131 | ) |
| 1132 | { |
| 1133 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1134 | if (token == NULL) { |
| 1135 | return NULL; |
| 1136 | } |
| 1137 | int end_lineno = token->end_lineno; |
| 1138 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1139 | int end_col_offset = token->end_col_offset; |
| 1140 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1141 | res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) ); |
| 1142 | if (res == NULL && PyErr_Occurred()) { |
| 1143 | p->error_indicator = 1; |
| 1144 | return NULL; |
| 1145 | } |
| 1146 | goto done; |
| 1147 | } |
| 1148 | p->mark = mark; |
| 1149 | } |
| 1150 | { // $ |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1151 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1152 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1153 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1154 | ) |
| 1155 | { |
| 1156 | res = _PyPegen_interactive_exit ( p ); |
| 1157 | if (res == NULL && PyErr_Occurred()) { |
| 1158 | p->error_indicator = 1; |
| 1159 | return NULL; |
| 1160 | } |
| 1161 | goto done; |
| 1162 | } |
| 1163 | p->mark = mark; |
| 1164 | } |
| 1165 | res = NULL; |
| 1166 | done: |
| 1167 | return res; |
| 1168 | } |
| 1169 | |
| 1170 | // simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE |
| 1171 | static asdl_seq* |
| 1172 | simple_stmt_rule(Parser *p) |
| 1173 | { |
| 1174 | if (p->error_indicator) { |
| 1175 | return NULL; |
| 1176 | } |
| 1177 | asdl_seq* res = NULL; |
| 1178 | int mark = p->mark; |
| 1179 | { // small_stmt !';' NEWLINE |
| 1180 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1181 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1182 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1183 | (a = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1184 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1185 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1186 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1187 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1188 | ) |
| 1189 | { |
| 1190 | res = _PyPegen_singleton_seq ( p , a ); |
| 1191 | if (res == NULL && PyErr_Occurred()) { |
| 1192 | p->error_indicator = 1; |
| 1193 | return NULL; |
| 1194 | } |
| 1195 | goto done; |
| 1196 | } |
| 1197 | p->mark = mark; |
| 1198 | } |
| 1199 | { // ';'.small_stmt+ ';'? NEWLINE |
| 1200 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1201 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1202 | void *opt_var; |
| 1203 | UNUSED(opt_var); // Silence compiler warnings |
| 1204 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1205 | (a = _gather_12_rule(p)) // ';'.small_stmt+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1206 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1207 | (opt_var = _PyPegen_expect_token(p, 13), 1) // ';'? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1208 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1209 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1210 | ) |
| 1211 | { |
| 1212 | res = a; |
| 1213 | if (res == NULL && PyErr_Occurred()) { |
| 1214 | p->error_indicator = 1; |
| 1215 | return NULL; |
| 1216 | } |
| 1217 | goto done; |
| 1218 | } |
| 1219 | p->mark = mark; |
| 1220 | } |
| 1221 | res = NULL; |
| 1222 | done: |
| 1223 | return res; |
| 1224 | } |
| 1225 | |
| 1226 | // small_stmt: |
| 1227 | // | assignment |
| 1228 | // | star_expressions |
| 1229 | // | &'return' return_stmt |
| 1230 | // | &('import' | 'from') import_stmt |
| 1231 | // | &'raise' raise_stmt |
| 1232 | // | 'pass' |
| 1233 | // | &'del' del_stmt |
| 1234 | // | &'yield' yield_stmt |
| 1235 | // | &'assert' assert_stmt |
| 1236 | // | 'break' |
| 1237 | // | 'continue' |
| 1238 | // | &'global' global_stmt |
| 1239 | // | &'nonlocal' nonlocal_stmt |
| 1240 | static stmt_ty |
| 1241 | small_stmt_rule(Parser *p) |
| 1242 | { |
| 1243 | if (p->error_indicator) { |
| 1244 | return NULL; |
| 1245 | } |
| 1246 | stmt_ty res = NULL; |
| 1247 | if (_PyPegen_is_memoized(p, small_stmt_type, &res)) |
| 1248 | return res; |
| 1249 | int mark = p->mark; |
| 1250 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1251 | p->error_indicator = 1; |
| 1252 | return NULL; |
| 1253 | } |
| 1254 | int start_lineno = p->tokens[mark]->lineno; |
| 1255 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1256 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1257 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1258 | { // assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1259 | stmt_ty assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1260 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1261 | (assignment_var = assignment_rule(p)) // assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1262 | ) |
| 1263 | { |
| 1264 | res = assignment_var; |
| 1265 | goto done; |
| 1266 | } |
| 1267 | p->mark = mark; |
| 1268 | } |
| 1269 | { // star_expressions |
| 1270 | expr_ty e; |
| 1271 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1272 | (e = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1273 | ) |
| 1274 | { |
| 1275 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1276 | if (token == NULL) { |
| 1277 | return NULL; |
| 1278 | } |
| 1279 | int end_lineno = token->end_lineno; |
| 1280 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1281 | int end_col_offset = token->end_col_offset; |
| 1282 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1283 | res = _Py_Expr ( e , EXTRA ); |
| 1284 | if (res == NULL && PyErr_Occurred()) { |
| 1285 | p->error_indicator = 1; |
| 1286 | return NULL; |
| 1287 | } |
| 1288 | goto done; |
| 1289 | } |
| 1290 | p->mark = mark; |
| 1291 | } |
| 1292 | { // &'return' return_stmt |
| 1293 | stmt_ty return_stmt_var; |
| 1294 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1295 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1296 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1297 | (return_stmt_var = return_stmt_rule(p)) // return_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1298 | ) |
| 1299 | { |
| 1300 | res = return_stmt_var; |
| 1301 | goto done; |
| 1302 | } |
| 1303 | p->mark = mark; |
| 1304 | } |
| 1305 | { // &('import' | 'from') import_stmt |
| 1306 | stmt_ty import_stmt_var; |
| 1307 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1308 | _PyPegen_lookahead(1, _tmp_14_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1309 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1310 | (import_stmt_var = import_stmt_rule(p)) // import_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1311 | ) |
| 1312 | { |
| 1313 | res = import_stmt_var; |
| 1314 | goto done; |
| 1315 | } |
| 1316 | p->mark = mark; |
| 1317 | } |
| 1318 | { // &'raise' raise_stmt |
| 1319 | stmt_ty raise_stmt_var; |
| 1320 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1321 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1322 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1323 | (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1324 | ) |
| 1325 | { |
| 1326 | res = raise_stmt_var; |
| 1327 | goto done; |
| 1328 | } |
| 1329 | p->mark = mark; |
| 1330 | } |
| 1331 | { // 'pass' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1332 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1333 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1334 | (keyword = _PyPegen_expect_token(p, 502)) // token='pass' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1335 | ) |
| 1336 | { |
| 1337 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1338 | if (token == NULL) { |
| 1339 | return NULL; |
| 1340 | } |
| 1341 | int end_lineno = token->end_lineno; |
| 1342 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1343 | int end_col_offset = token->end_col_offset; |
| 1344 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1345 | res = _Py_Pass ( EXTRA ); |
| 1346 | if (res == NULL && PyErr_Occurred()) { |
| 1347 | p->error_indicator = 1; |
| 1348 | return NULL; |
| 1349 | } |
| 1350 | goto done; |
| 1351 | } |
| 1352 | p->mark = mark; |
| 1353 | } |
| 1354 | { // &'del' del_stmt |
| 1355 | stmt_ty del_stmt_var; |
| 1356 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1357 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1358 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1359 | (del_stmt_var = del_stmt_rule(p)) // del_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1360 | ) |
| 1361 | { |
| 1362 | res = del_stmt_var; |
| 1363 | goto done; |
| 1364 | } |
| 1365 | p->mark = mark; |
| 1366 | } |
| 1367 | { // &'yield' yield_stmt |
| 1368 | stmt_ty yield_stmt_var; |
| 1369 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1370 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1371 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1372 | (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1373 | ) |
| 1374 | { |
| 1375 | res = yield_stmt_var; |
| 1376 | goto done; |
| 1377 | } |
| 1378 | p->mark = mark; |
| 1379 | } |
| 1380 | { // &'assert' assert_stmt |
| 1381 | stmt_ty assert_stmt_var; |
| 1382 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1383 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1384 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1385 | (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1386 | ) |
| 1387 | { |
| 1388 | res = assert_stmt_var; |
| 1389 | goto done; |
| 1390 | } |
| 1391 | p->mark = mark; |
| 1392 | } |
| 1393 | { // 'break' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1394 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1395 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1396 | (keyword = _PyPegen_expect_token(p, 506)) // token='break' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1397 | ) |
| 1398 | { |
| 1399 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1400 | if (token == NULL) { |
| 1401 | return NULL; |
| 1402 | } |
| 1403 | int end_lineno = token->end_lineno; |
| 1404 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1405 | int end_col_offset = token->end_col_offset; |
| 1406 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1407 | res = _Py_Break ( EXTRA ); |
| 1408 | if (res == NULL && PyErr_Occurred()) { |
| 1409 | p->error_indicator = 1; |
| 1410 | return NULL; |
| 1411 | } |
| 1412 | goto done; |
| 1413 | } |
| 1414 | p->mark = mark; |
| 1415 | } |
| 1416 | { // 'continue' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1417 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1418 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1419 | (keyword = _PyPegen_expect_token(p, 507)) // token='continue' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1420 | ) |
| 1421 | { |
| 1422 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1423 | if (token == NULL) { |
| 1424 | return NULL; |
| 1425 | } |
| 1426 | int end_lineno = token->end_lineno; |
| 1427 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1428 | int end_col_offset = token->end_col_offset; |
| 1429 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1430 | res = _Py_Continue ( EXTRA ); |
| 1431 | if (res == NULL && PyErr_Occurred()) { |
| 1432 | p->error_indicator = 1; |
| 1433 | return NULL; |
| 1434 | } |
| 1435 | goto done; |
| 1436 | } |
| 1437 | p->mark = mark; |
| 1438 | } |
| 1439 | { // &'global' global_stmt |
| 1440 | stmt_ty global_stmt_var; |
| 1441 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1442 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1443 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1444 | (global_stmt_var = global_stmt_rule(p)) // global_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1445 | ) |
| 1446 | { |
| 1447 | res = global_stmt_var; |
| 1448 | goto done; |
| 1449 | } |
| 1450 | p->mark = mark; |
| 1451 | } |
| 1452 | { // &'nonlocal' nonlocal_stmt |
| 1453 | stmt_ty nonlocal_stmt_var; |
| 1454 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1455 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1456 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1457 | (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1458 | ) |
| 1459 | { |
| 1460 | res = nonlocal_stmt_var; |
| 1461 | goto done; |
| 1462 | } |
| 1463 | p->mark = mark; |
| 1464 | } |
| 1465 | res = NULL; |
| 1466 | done: |
| 1467 | _PyPegen_insert_memo(p, mark, small_stmt_type, res); |
| 1468 | return res; |
| 1469 | } |
| 1470 | |
| 1471 | // compound_stmt: |
| 1472 | // | &('def' | '@' | ASYNC) function_def |
| 1473 | // | &'if' if_stmt |
| 1474 | // | &('class' | '@') class_def |
| 1475 | // | &('with' | ASYNC) with_stmt |
| 1476 | // | &('for' | ASYNC) for_stmt |
| 1477 | // | &'try' try_stmt |
| 1478 | // | &'while' while_stmt |
| 1479 | static stmt_ty |
| 1480 | compound_stmt_rule(Parser *p) |
| 1481 | { |
| 1482 | if (p->error_indicator) { |
| 1483 | return NULL; |
| 1484 | } |
| 1485 | stmt_ty res = NULL; |
| 1486 | int mark = p->mark; |
| 1487 | { // &('def' | '@' | ASYNC) function_def |
| 1488 | stmt_ty function_def_var; |
| 1489 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1490 | _PyPegen_lookahead(1, _tmp_15_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1491 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1492 | (function_def_var = function_def_rule(p)) // function_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1493 | ) |
| 1494 | { |
| 1495 | res = function_def_var; |
| 1496 | goto done; |
| 1497 | } |
| 1498 | p->mark = mark; |
| 1499 | } |
| 1500 | { // &'if' if_stmt |
| 1501 | stmt_ty if_stmt_var; |
| 1502 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1503 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1504 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1505 | (if_stmt_var = if_stmt_rule(p)) // if_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1506 | ) |
| 1507 | { |
| 1508 | res = if_stmt_var; |
| 1509 | goto done; |
| 1510 | } |
| 1511 | p->mark = mark; |
| 1512 | } |
| 1513 | { // &('class' | '@') class_def |
| 1514 | stmt_ty class_def_var; |
| 1515 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1516 | _PyPegen_lookahead(1, _tmp_16_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1517 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1518 | (class_def_var = class_def_rule(p)) // class_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1519 | ) |
| 1520 | { |
| 1521 | res = class_def_var; |
| 1522 | goto done; |
| 1523 | } |
| 1524 | p->mark = mark; |
| 1525 | } |
| 1526 | { // &('with' | ASYNC) with_stmt |
| 1527 | stmt_ty with_stmt_var; |
| 1528 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1529 | _PyPegen_lookahead(1, _tmp_17_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1530 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1531 | (with_stmt_var = with_stmt_rule(p)) // with_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1532 | ) |
| 1533 | { |
| 1534 | res = with_stmt_var; |
| 1535 | goto done; |
| 1536 | } |
| 1537 | p->mark = mark; |
| 1538 | } |
| 1539 | { // &('for' | ASYNC) for_stmt |
| 1540 | stmt_ty for_stmt_var; |
| 1541 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1542 | _PyPegen_lookahead(1, _tmp_18_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1543 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1544 | (for_stmt_var = for_stmt_rule(p)) // for_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1545 | ) |
| 1546 | { |
| 1547 | res = for_stmt_var; |
| 1548 | goto done; |
| 1549 | } |
| 1550 | p->mark = mark; |
| 1551 | } |
| 1552 | { // &'try' try_stmt |
| 1553 | stmt_ty try_stmt_var; |
| 1554 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1555 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1556 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1557 | (try_stmt_var = try_stmt_rule(p)) // try_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1558 | ) |
| 1559 | { |
| 1560 | res = try_stmt_var; |
| 1561 | goto done; |
| 1562 | } |
| 1563 | p->mark = mark; |
| 1564 | } |
| 1565 | { // &'while' while_stmt |
| 1566 | stmt_ty while_stmt_var; |
| 1567 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1568 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1569 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1570 | (while_stmt_var = while_stmt_rule(p)) // while_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1571 | ) |
| 1572 | { |
| 1573 | res = while_stmt_var; |
| 1574 | goto done; |
| 1575 | } |
| 1576 | p->mark = mark; |
| 1577 | } |
| 1578 | res = NULL; |
| 1579 | done: |
| 1580 | return res; |
| 1581 | } |
| 1582 | |
| 1583 | // assignment: |
| 1584 | // | NAME ':' expression ['=' annotated_rhs] |
| 1585 | // | ('(' 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] | 1586 | // | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1587 | // | target augassign (yield_expr | star_expressions) |
| 1588 | // | invalid_assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1589 | static stmt_ty |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1590 | assignment_rule(Parser *p) |
| 1591 | { |
| 1592 | if (p->error_indicator) { |
| 1593 | return NULL; |
| 1594 | } |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1595 | stmt_ty res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1596 | int mark = p->mark; |
| 1597 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1598 | p->error_indicator = 1; |
| 1599 | return NULL; |
| 1600 | } |
| 1601 | int start_lineno = p->tokens[mark]->lineno; |
| 1602 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1603 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1604 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1605 | { // NAME ':' expression ['=' annotated_rhs] |
| 1606 | expr_ty a; |
| 1607 | expr_ty b; |
| 1608 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1609 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1610 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1611 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1612 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1613 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1614 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1615 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1616 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1617 | (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1618 | ) |
| 1619 | { |
| 1620 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1621 | if (token == NULL) { |
| 1622 | return NULL; |
| 1623 | } |
| 1624 | int end_lineno = token->end_lineno; |
| 1625 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1626 | int end_col_offset = token->end_col_offset; |
| 1627 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1628 | res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1629 | if (res == NULL && PyErr_Occurred()) { |
| 1630 | p->error_indicator = 1; |
| 1631 | return NULL; |
| 1632 | } |
| 1633 | goto done; |
| 1634 | } |
| 1635 | p->mark = mark; |
| 1636 | } |
| 1637 | { // ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
| 1638 | void *a; |
| 1639 | expr_ty b; |
| 1640 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1641 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1642 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1643 | (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] | 1644 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1645 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1646 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1647 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1648 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1649 | (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1650 | ) |
| 1651 | { |
| 1652 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1653 | if (token == NULL) { |
| 1654 | return NULL; |
| 1655 | } |
| 1656 | int end_lineno = token->end_lineno; |
| 1657 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1658 | int end_col_offset = token->end_col_offset; |
| 1659 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1660 | res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1661 | if (res == NULL && PyErr_Occurred()) { |
| 1662 | p->error_indicator = 1; |
| 1663 | return NULL; |
| 1664 | } |
| 1665 | goto done; |
| 1666 | } |
| 1667 | p->mark = mark; |
| 1668 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1669 | { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1670 | asdl_seq * a; |
| 1671 | void *b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1672 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1673 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1674 | (a = _loop1_22_rule(p)) // ((star_targets '='))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1675 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1676 | (b = _tmp_23_rule(p)) // yield_expr | star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1677 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1678 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1679 | ) |
| 1680 | { |
| 1681 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1682 | if (token == NULL) { |
| 1683 | return NULL; |
| 1684 | } |
| 1685 | int end_lineno = token->end_lineno; |
| 1686 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1687 | int end_col_offset = token->end_col_offset; |
| 1688 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1689 | res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1690 | if (res == NULL && PyErr_Occurred()) { |
| 1691 | p->error_indicator = 1; |
| 1692 | return NULL; |
| 1693 | } |
| 1694 | goto done; |
| 1695 | } |
| 1696 | p->mark = mark; |
| 1697 | } |
| 1698 | { // target augassign (yield_expr | star_expressions) |
| 1699 | expr_ty a; |
| 1700 | AugOperator* b; |
| 1701 | void *c; |
| 1702 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1703 | (a = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1704 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1705 | (b = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1706 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1707 | (c = _tmp_24_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1708 | ) |
| 1709 | { |
| 1710 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1711 | if (token == NULL) { |
| 1712 | return NULL; |
| 1713 | } |
| 1714 | int end_lineno = token->end_lineno; |
| 1715 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1716 | int end_col_offset = token->end_col_offset; |
| 1717 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1718 | res = _Py_AugAssign ( a , b -> kind , c , EXTRA ); |
| 1719 | if (res == NULL && PyErr_Occurred()) { |
| 1720 | p->error_indicator = 1; |
| 1721 | return NULL; |
| 1722 | } |
| 1723 | goto done; |
| 1724 | } |
| 1725 | p->mark = mark; |
| 1726 | } |
| 1727 | { // invalid_assignment |
| 1728 | void *invalid_assignment_var; |
| 1729 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1730 | (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1731 | ) |
| 1732 | { |
| 1733 | res = invalid_assignment_var; |
| 1734 | goto done; |
| 1735 | } |
| 1736 | p->mark = mark; |
| 1737 | } |
| 1738 | res = NULL; |
| 1739 | done: |
| 1740 | return res; |
| 1741 | } |
| 1742 | |
| 1743 | // augassign: |
| 1744 | // | '+=' |
| 1745 | // | '-=' |
| 1746 | // | '*=' |
| 1747 | // | '@=' |
| 1748 | // | '/=' |
| 1749 | // | '%=' |
| 1750 | // | '&=' |
| 1751 | // | '|=' |
| 1752 | // | '^=' |
| 1753 | // | '<<=' |
| 1754 | // | '>>=' |
| 1755 | // | '**=' |
| 1756 | // | '//=' |
| 1757 | static AugOperator* |
| 1758 | augassign_rule(Parser *p) |
| 1759 | { |
| 1760 | if (p->error_indicator) { |
| 1761 | return NULL; |
| 1762 | } |
| 1763 | AugOperator* res = NULL; |
| 1764 | int mark = p->mark; |
| 1765 | { // '+=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1766 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1767 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1768 | (literal = _PyPegen_expect_token(p, 36)) // token='+=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1769 | ) |
| 1770 | { |
| 1771 | res = _PyPegen_augoperator ( p , Add ); |
| 1772 | if (res == NULL && PyErr_Occurred()) { |
| 1773 | p->error_indicator = 1; |
| 1774 | return NULL; |
| 1775 | } |
| 1776 | goto done; |
| 1777 | } |
| 1778 | p->mark = mark; |
| 1779 | } |
| 1780 | { // '-=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1781 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1782 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1783 | (literal = _PyPegen_expect_token(p, 37)) // token='-=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1784 | ) |
| 1785 | { |
| 1786 | res = _PyPegen_augoperator ( p , Sub ); |
| 1787 | if (res == NULL && PyErr_Occurred()) { |
| 1788 | p->error_indicator = 1; |
| 1789 | return NULL; |
| 1790 | } |
| 1791 | goto done; |
| 1792 | } |
| 1793 | p->mark = mark; |
| 1794 | } |
| 1795 | { // '*=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1796 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1797 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1798 | (literal = _PyPegen_expect_token(p, 38)) // token='*=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1799 | ) |
| 1800 | { |
| 1801 | res = _PyPegen_augoperator ( p , Mult ); |
| 1802 | if (res == NULL && PyErr_Occurred()) { |
| 1803 | p->error_indicator = 1; |
| 1804 | return NULL; |
| 1805 | } |
| 1806 | goto done; |
| 1807 | } |
| 1808 | p->mark = mark; |
| 1809 | } |
| 1810 | { // '@=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1811 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1812 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1813 | (literal = _PyPegen_expect_token(p, 50)) // token='@=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1814 | ) |
| 1815 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1816 | res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1817 | if (res == NULL && PyErr_Occurred()) { |
| 1818 | p->error_indicator = 1; |
| 1819 | return NULL; |
| 1820 | } |
| 1821 | goto done; |
| 1822 | } |
| 1823 | p->mark = mark; |
| 1824 | } |
| 1825 | { // '/=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1826 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1827 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1828 | (literal = _PyPegen_expect_token(p, 39)) // token='/=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1829 | ) |
| 1830 | { |
| 1831 | res = _PyPegen_augoperator ( p , Div ); |
| 1832 | if (res == NULL && PyErr_Occurred()) { |
| 1833 | p->error_indicator = 1; |
| 1834 | return NULL; |
| 1835 | } |
| 1836 | goto done; |
| 1837 | } |
| 1838 | p->mark = mark; |
| 1839 | } |
| 1840 | { // '%=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1841 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1842 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1843 | (literal = _PyPegen_expect_token(p, 40)) // token='%=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1844 | ) |
| 1845 | { |
| 1846 | res = _PyPegen_augoperator ( p , Mod ); |
| 1847 | if (res == NULL && PyErr_Occurred()) { |
| 1848 | p->error_indicator = 1; |
| 1849 | return NULL; |
| 1850 | } |
| 1851 | goto done; |
| 1852 | } |
| 1853 | p->mark = mark; |
| 1854 | } |
| 1855 | { // '&=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1856 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1857 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1858 | (literal = _PyPegen_expect_token(p, 41)) // token='&=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1859 | ) |
| 1860 | { |
| 1861 | res = _PyPegen_augoperator ( p , BitAnd ); |
| 1862 | if (res == NULL && PyErr_Occurred()) { |
| 1863 | p->error_indicator = 1; |
| 1864 | return NULL; |
| 1865 | } |
| 1866 | goto done; |
| 1867 | } |
| 1868 | p->mark = mark; |
| 1869 | } |
| 1870 | { // '|=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1871 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1872 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1873 | (literal = _PyPegen_expect_token(p, 42)) // token='|=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1874 | ) |
| 1875 | { |
| 1876 | res = _PyPegen_augoperator ( p , BitOr ); |
| 1877 | if (res == NULL && PyErr_Occurred()) { |
| 1878 | p->error_indicator = 1; |
| 1879 | return NULL; |
| 1880 | } |
| 1881 | goto done; |
| 1882 | } |
| 1883 | p->mark = mark; |
| 1884 | } |
| 1885 | { // '^=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1886 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1887 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1888 | (literal = _PyPegen_expect_token(p, 43)) // token='^=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1889 | ) |
| 1890 | { |
| 1891 | res = _PyPegen_augoperator ( p , BitXor ); |
| 1892 | if (res == NULL && PyErr_Occurred()) { |
| 1893 | p->error_indicator = 1; |
| 1894 | return NULL; |
| 1895 | } |
| 1896 | goto done; |
| 1897 | } |
| 1898 | p->mark = mark; |
| 1899 | } |
| 1900 | { // '<<=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1901 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1902 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1903 | (literal = _PyPegen_expect_token(p, 44)) // token='<<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1904 | ) |
| 1905 | { |
| 1906 | res = _PyPegen_augoperator ( p , LShift ); |
| 1907 | if (res == NULL && PyErr_Occurred()) { |
| 1908 | p->error_indicator = 1; |
| 1909 | return NULL; |
| 1910 | } |
| 1911 | goto done; |
| 1912 | } |
| 1913 | p->mark = mark; |
| 1914 | } |
| 1915 | { // '>>=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1916 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1917 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1918 | (literal = _PyPegen_expect_token(p, 45)) // token='>>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1919 | ) |
| 1920 | { |
| 1921 | res = _PyPegen_augoperator ( p , RShift ); |
| 1922 | if (res == NULL && PyErr_Occurred()) { |
| 1923 | p->error_indicator = 1; |
| 1924 | return NULL; |
| 1925 | } |
| 1926 | goto done; |
| 1927 | } |
| 1928 | p->mark = mark; |
| 1929 | } |
| 1930 | { // '**=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1931 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1932 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1933 | (literal = _PyPegen_expect_token(p, 46)) // token='**=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1934 | ) |
| 1935 | { |
| 1936 | res = _PyPegen_augoperator ( p , Pow ); |
| 1937 | if (res == NULL && PyErr_Occurred()) { |
| 1938 | p->error_indicator = 1; |
| 1939 | return NULL; |
| 1940 | } |
| 1941 | goto done; |
| 1942 | } |
| 1943 | p->mark = mark; |
| 1944 | } |
| 1945 | { // '//=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1946 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1947 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1948 | (literal = _PyPegen_expect_token(p, 48)) // token='//=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1949 | ) |
| 1950 | { |
| 1951 | res = _PyPegen_augoperator ( p , FloorDiv ); |
| 1952 | if (res == NULL && PyErr_Occurred()) { |
| 1953 | p->error_indicator = 1; |
| 1954 | return NULL; |
| 1955 | } |
| 1956 | goto done; |
| 1957 | } |
| 1958 | p->mark = mark; |
| 1959 | } |
| 1960 | res = NULL; |
| 1961 | done: |
| 1962 | return res; |
| 1963 | } |
| 1964 | |
| 1965 | // global_stmt: 'global' ','.NAME+ |
| 1966 | static stmt_ty |
| 1967 | global_stmt_rule(Parser *p) |
| 1968 | { |
| 1969 | if (p->error_indicator) { |
| 1970 | return NULL; |
| 1971 | } |
| 1972 | stmt_ty res = NULL; |
| 1973 | int mark = p->mark; |
| 1974 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1975 | p->error_indicator = 1; |
| 1976 | return NULL; |
| 1977 | } |
| 1978 | int start_lineno = p->tokens[mark]->lineno; |
| 1979 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1980 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1981 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1982 | { // 'global' ','.NAME+ |
| 1983 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1984 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1985 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1986 | (keyword = _PyPegen_expect_token(p, 508)) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1987 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 1988 | (a = _gather_25_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1989 | ) |
| 1990 | { |
| 1991 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1992 | if (token == NULL) { |
| 1993 | return NULL; |
| 1994 | } |
| 1995 | int end_lineno = token->end_lineno; |
| 1996 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1997 | int end_col_offset = token->end_col_offset; |
| 1998 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1999 | res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2000 | if (res == NULL && PyErr_Occurred()) { |
| 2001 | p->error_indicator = 1; |
| 2002 | return NULL; |
| 2003 | } |
| 2004 | goto done; |
| 2005 | } |
| 2006 | p->mark = mark; |
| 2007 | } |
| 2008 | res = NULL; |
| 2009 | done: |
| 2010 | return res; |
| 2011 | } |
| 2012 | |
| 2013 | // nonlocal_stmt: 'nonlocal' ','.NAME+ |
| 2014 | static stmt_ty |
| 2015 | nonlocal_stmt_rule(Parser *p) |
| 2016 | { |
| 2017 | if (p->error_indicator) { |
| 2018 | return NULL; |
| 2019 | } |
| 2020 | stmt_ty res = NULL; |
| 2021 | int mark = p->mark; |
| 2022 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2023 | p->error_indicator = 1; |
| 2024 | return NULL; |
| 2025 | } |
| 2026 | int start_lineno = p->tokens[mark]->lineno; |
| 2027 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2028 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2029 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2030 | { // 'nonlocal' ','.NAME+ |
| 2031 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2032 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2033 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2034 | (keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2035 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2036 | (a = _gather_27_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2037 | ) |
| 2038 | { |
| 2039 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2040 | if (token == NULL) { |
| 2041 | return NULL; |
| 2042 | } |
| 2043 | int end_lineno = token->end_lineno; |
| 2044 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2045 | int end_col_offset = token->end_col_offset; |
| 2046 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2047 | res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2048 | if (res == NULL && PyErr_Occurred()) { |
| 2049 | p->error_indicator = 1; |
| 2050 | return NULL; |
| 2051 | } |
| 2052 | goto done; |
| 2053 | } |
| 2054 | p->mark = mark; |
| 2055 | } |
| 2056 | res = NULL; |
| 2057 | done: |
| 2058 | return res; |
| 2059 | } |
| 2060 | |
| 2061 | // yield_stmt: yield_expr |
| 2062 | static stmt_ty |
| 2063 | yield_stmt_rule(Parser *p) |
| 2064 | { |
| 2065 | if (p->error_indicator) { |
| 2066 | return NULL; |
| 2067 | } |
| 2068 | stmt_ty res = NULL; |
| 2069 | int mark = p->mark; |
| 2070 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2071 | p->error_indicator = 1; |
| 2072 | return NULL; |
| 2073 | } |
| 2074 | int start_lineno = p->tokens[mark]->lineno; |
| 2075 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2076 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2077 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2078 | { // yield_expr |
| 2079 | expr_ty y; |
| 2080 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2081 | (y = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2082 | ) |
| 2083 | { |
| 2084 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2085 | if (token == NULL) { |
| 2086 | return NULL; |
| 2087 | } |
| 2088 | int end_lineno = token->end_lineno; |
| 2089 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2090 | int end_col_offset = token->end_col_offset; |
| 2091 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2092 | res = _Py_Expr ( y , EXTRA ); |
| 2093 | if (res == NULL && PyErr_Occurred()) { |
| 2094 | p->error_indicator = 1; |
| 2095 | return NULL; |
| 2096 | } |
| 2097 | goto done; |
| 2098 | } |
| 2099 | p->mark = mark; |
| 2100 | } |
| 2101 | res = NULL; |
| 2102 | done: |
| 2103 | return res; |
| 2104 | } |
| 2105 | |
| 2106 | // assert_stmt: 'assert' expression [',' expression] |
| 2107 | static stmt_ty |
| 2108 | assert_stmt_rule(Parser *p) |
| 2109 | { |
| 2110 | if (p->error_indicator) { |
| 2111 | return NULL; |
| 2112 | } |
| 2113 | stmt_ty res = NULL; |
| 2114 | int mark = p->mark; |
| 2115 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2116 | p->error_indicator = 1; |
| 2117 | return NULL; |
| 2118 | } |
| 2119 | int start_lineno = p->tokens[mark]->lineno; |
| 2120 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2121 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2122 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2123 | { // 'assert' expression [',' expression] |
| 2124 | expr_ty a; |
| 2125 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2126 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2127 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2128 | (keyword = _PyPegen_expect_token(p, 505)) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2129 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2130 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2131 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2132 | (b = _tmp_29_rule(p), 1) // [',' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2133 | ) |
| 2134 | { |
| 2135 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2136 | if (token == NULL) { |
| 2137 | return NULL; |
| 2138 | } |
| 2139 | int end_lineno = token->end_lineno; |
| 2140 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2141 | int end_col_offset = token->end_col_offset; |
| 2142 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2143 | res = _Py_Assert ( a , b , EXTRA ); |
| 2144 | if (res == NULL && PyErr_Occurred()) { |
| 2145 | p->error_indicator = 1; |
| 2146 | return NULL; |
| 2147 | } |
| 2148 | goto done; |
| 2149 | } |
| 2150 | p->mark = mark; |
| 2151 | } |
| 2152 | res = NULL; |
| 2153 | done: |
| 2154 | return res; |
| 2155 | } |
| 2156 | |
| 2157 | // del_stmt: 'del' del_targets |
| 2158 | static stmt_ty |
| 2159 | del_stmt_rule(Parser *p) |
| 2160 | { |
| 2161 | if (p->error_indicator) { |
| 2162 | return NULL; |
| 2163 | } |
| 2164 | stmt_ty res = NULL; |
| 2165 | int mark = p->mark; |
| 2166 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2167 | p->error_indicator = 1; |
| 2168 | return NULL; |
| 2169 | } |
| 2170 | int start_lineno = p->tokens[mark]->lineno; |
| 2171 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2172 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2173 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2174 | { // 'del' del_targets |
| 2175 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2176 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2177 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2178 | (keyword = _PyPegen_expect_token(p, 503)) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2179 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2180 | (a = del_targets_rule(p)) // del_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2181 | ) |
| 2182 | { |
| 2183 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2184 | if (token == NULL) { |
| 2185 | return NULL; |
| 2186 | } |
| 2187 | int end_lineno = token->end_lineno; |
| 2188 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2189 | int end_col_offset = token->end_col_offset; |
| 2190 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2191 | res = _Py_Delete ( a , EXTRA ); |
| 2192 | if (res == NULL && PyErr_Occurred()) { |
| 2193 | p->error_indicator = 1; |
| 2194 | return NULL; |
| 2195 | } |
| 2196 | goto done; |
| 2197 | } |
| 2198 | p->mark = mark; |
| 2199 | } |
| 2200 | res = NULL; |
| 2201 | done: |
| 2202 | return res; |
| 2203 | } |
| 2204 | |
| 2205 | // import_stmt: import_name | import_from |
| 2206 | static stmt_ty |
| 2207 | import_stmt_rule(Parser *p) |
| 2208 | { |
| 2209 | if (p->error_indicator) { |
| 2210 | return NULL; |
| 2211 | } |
| 2212 | stmt_ty res = NULL; |
| 2213 | int mark = p->mark; |
| 2214 | { // import_name |
| 2215 | stmt_ty import_name_var; |
| 2216 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2217 | (import_name_var = import_name_rule(p)) // import_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2218 | ) |
| 2219 | { |
| 2220 | res = import_name_var; |
| 2221 | goto done; |
| 2222 | } |
| 2223 | p->mark = mark; |
| 2224 | } |
| 2225 | { // import_from |
| 2226 | stmt_ty import_from_var; |
| 2227 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2228 | (import_from_var = import_from_rule(p)) // import_from |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2229 | ) |
| 2230 | { |
| 2231 | res = import_from_var; |
| 2232 | goto done; |
| 2233 | } |
| 2234 | p->mark = mark; |
| 2235 | } |
| 2236 | res = NULL; |
| 2237 | done: |
| 2238 | return res; |
| 2239 | } |
| 2240 | |
| 2241 | // import_name: 'import' dotted_as_names |
| 2242 | static stmt_ty |
| 2243 | import_name_rule(Parser *p) |
| 2244 | { |
| 2245 | if (p->error_indicator) { |
| 2246 | return NULL; |
| 2247 | } |
| 2248 | stmt_ty res = NULL; |
| 2249 | int mark = p->mark; |
| 2250 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2251 | p->error_indicator = 1; |
| 2252 | return NULL; |
| 2253 | } |
| 2254 | int start_lineno = p->tokens[mark]->lineno; |
| 2255 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2256 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2257 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2258 | { // 'import' dotted_as_names |
| 2259 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2260 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2261 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2262 | (keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2263 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2264 | (a = dotted_as_names_rule(p)) // dotted_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2265 | ) |
| 2266 | { |
| 2267 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2268 | if (token == NULL) { |
| 2269 | return NULL; |
| 2270 | } |
| 2271 | int end_lineno = token->end_lineno; |
| 2272 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2273 | int end_col_offset = token->end_col_offset; |
| 2274 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2275 | res = _Py_Import ( a , EXTRA ); |
| 2276 | if (res == NULL && PyErr_Occurred()) { |
| 2277 | p->error_indicator = 1; |
| 2278 | return NULL; |
| 2279 | } |
| 2280 | goto done; |
| 2281 | } |
| 2282 | p->mark = mark; |
| 2283 | } |
| 2284 | res = NULL; |
| 2285 | done: |
| 2286 | return res; |
| 2287 | } |
| 2288 | |
| 2289 | // import_from: |
| 2290 | // | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2291 | // | 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2292 | static stmt_ty |
| 2293 | import_from_rule(Parser *p) |
| 2294 | { |
| 2295 | if (p->error_indicator) { |
| 2296 | return NULL; |
| 2297 | } |
| 2298 | stmt_ty res = NULL; |
| 2299 | int mark = p->mark; |
| 2300 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2301 | p->error_indicator = 1; |
| 2302 | return NULL; |
| 2303 | } |
| 2304 | int start_lineno = p->tokens[mark]->lineno; |
| 2305 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2306 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2307 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2308 | { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2309 | asdl_seq * a; |
| 2310 | expr_ty b; |
| 2311 | asdl_seq* c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2312 | Token * keyword; |
| 2313 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2314 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2315 | (keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2316 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2317 | (a = _loop0_30_rule(p)) // (('.' | '...'))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2318 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2319 | (b = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2320 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2321 | (keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2322 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2323 | (c = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2324 | ) |
| 2325 | { |
| 2326 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2327 | if (token == NULL) { |
| 2328 | return NULL; |
| 2329 | } |
| 2330 | int end_lineno = token->end_lineno; |
| 2331 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2332 | int end_col_offset = token->end_col_offset; |
| 2333 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2334 | res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2335 | if (res == NULL && PyErr_Occurred()) { |
| 2336 | p->error_indicator = 1; |
| 2337 | return NULL; |
| 2338 | } |
| 2339 | goto done; |
| 2340 | } |
| 2341 | p->mark = mark; |
| 2342 | } |
| 2343 | { // 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2344 | asdl_seq * a; |
| 2345 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2346 | Token * keyword; |
| 2347 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2348 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2349 | (keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2350 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2351 | (a = _loop1_31_rule(p)) // (('.' | '...'))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2352 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2353 | (keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2354 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2355 | (b = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2356 | ) |
| 2357 | { |
| 2358 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2359 | if (token == NULL) { |
| 2360 | return NULL; |
| 2361 | } |
| 2362 | int end_lineno = token->end_lineno; |
| 2363 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2364 | int end_col_offset = token->end_col_offset; |
| 2365 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2366 | res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2367 | if (res == NULL && PyErr_Occurred()) { |
| 2368 | p->error_indicator = 1; |
| 2369 | return NULL; |
| 2370 | } |
| 2371 | goto done; |
| 2372 | } |
| 2373 | p->mark = mark; |
| 2374 | } |
| 2375 | res = NULL; |
| 2376 | done: |
| 2377 | return res; |
| 2378 | } |
| 2379 | |
| 2380 | // import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*' |
| 2381 | static asdl_seq* |
| 2382 | import_from_targets_rule(Parser *p) |
| 2383 | { |
| 2384 | if (p->error_indicator) { |
| 2385 | return NULL; |
| 2386 | } |
| 2387 | asdl_seq* res = NULL; |
| 2388 | int mark = p->mark; |
| 2389 | { // '(' import_from_as_names ','? ')' |
| 2390 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2391 | Token * literal; |
| 2392 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2393 | void *opt_var; |
| 2394 | UNUSED(opt_var); // Silence compiler warnings |
| 2395 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2396 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2397 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2398 | (a = import_from_as_names_rule(p)) // import_from_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2399 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2400 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2401 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2402 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2403 | ) |
| 2404 | { |
| 2405 | res = a; |
| 2406 | if (res == NULL && PyErr_Occurred()) { |
| 2407 | p->error_indicator = 1; |
| 2408 | return NULL; |
| 2409 | } |
| 2410 | goto done; |
| 2411 | } |
| 2412 | p->mark = mark; |
| 2413 | } |
| 2414 | { // import_from_as_names |
| 2415 | asdl_seq* import_from_as_names_var; |
| 2416 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2417 | (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] | 2418 | ) |
| 2419 | { |
| 2420 | res = import_from_as_names_var; |
| 2421 | goto done; |
| 2422 | } |
| 2423 | p->mark = mark; |
| 2424 | } |
| 2425 | { // '*' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2426 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2427 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2428 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2429 | ) |
| 2430 | { |
| 2431 | res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) ); |
| 2432 | if (res == NULL && PyErr_Occurred()) { |
| 2433 | p->error_indicator = 1; |
| 2434 | return NULL; |
| 2435 | } |
| 2436 | goto done; |
| 2437 | } |
| 2438 | p->mark = mark; |
| 2439 | } |
| 2440 | res = NULL; |
| 2441 | done: |
| 2442 | return res; |
| 2443 | } |
| 2444 | |
| 2445 | // import_from_as_names: ','.import_from_as_name+ |
| 2446 | static asdl_seq* |
| 2447 | import_from_as_names_rule(Parser *p) |
| 2448 | { |
| 2449 | if (p->error_indicator) { |
| 2450 | return NULL; |
| 2451 | } |
| 2452 | asdl_seq* res = NULL; |
| 2453 | int mark = p->mark; |
| 2454 | { // ','.import_from_as_name+ |
| 2455 | asdl_seq * a; |
| 2456 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2457 | (a = _gather_32_rule(p)) // ','.import_from_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2458 | ) |
| 2459 | { |
| 2460 | res = a; |
| 2461 | if (res == NULL && PyErr_Occurred()) { |
| 2462 | p->error_indicator = 1; |
| 2463 | return NULL; |
| 2464 | } |
| 2465 | goto done; |
| 2466 | } |
| 2467 | p->mark = mark; |
| 2468 | } |
| 2469 | res = NULL; |
| 2470 | done: |
| 2471 | return res; |
| 2472 | } |
| 2473 | |
| 2474 | // import_from_as_name: NAME ['as' NAME] |
| 2475 | static alias_ty |
| 2476 | import_from_as_name_rule(Parser *p) |
| 2477 | { |
| 2478 | if (p->error_indicator) { |
| 2479 | return NULL; |
| 2480 | } |
| 2481 | alias_ty res = NULL; |
| 2482 | int mark = p->mark; |
| 2483 | { // NAME ['as' NAME] |
| 2484 | expr_ty a; |
| 2485 | void *b; |
| 2486 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2487 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2488 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2489 | (b = _tmp_34_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2490 | ) |
| 2491 | { |
| 2492 | res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2493 | if (res == NULL && PyErr_Occurred()) { |
| 2494 | p->error_indicator = 1; |
| 2495 | return NULL; |
| 2496 | } |
| 2497 | goto done; |
| 2498 | } |
| 2499 | p->mark = mark; |
| 2500 | } |
| 2501 | res = NULL; |
| 2502 | done: |
| 2503 | return res; |
| 2504 | } |
| 2505 | |
| 2506 | // dotted_as_names: ','.dotted_as_name+ |
| 2507 | static asdl_seq* |
| 2508 | dotted_as_names_rule(Parser *p) |
| 2509 | { |
| 2510 | if (p->error_indicator) { |
| 2511 | return NULL; |
| 2512 | } |
| 2513 | asdl_seq* res = NULL; |
| 2514 | int mark = p->mark; |
| 2515 | { // ','.dotted_as_name+ |
| 2516 | asdl_seq * a; |
| 2517 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2518 | (a = _gather_35_rule(p)) // ','.dotted_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2519 | ) |
| 2520 | { |
| 2521 | res = a; |
| 2522 | if (res == NULL && PyErr_Occurred()) { |
| 2523 | p->error_indicator = 1; |
| 2524 | return NULL; |
| 2525 | } |
| 2526 | goto done; |
| 2527 | } |
| 2528 | p->mark = mark; |
| 2529 | } |
| 2530 | res = NULL; |
| 2531 | done: |
| 2532 | return res; |
| 2533 | } |
| 2534 | |
| 2535 | // dotted_as_name: dotted_name ['as' NAME] |
| 2536 | static alias_ty |
| 2537 | dotted_as_name_rule(Parser *p) |
| 2538 | { |
| 2539 | if (p->error_indicator) { |
| 2540 | return NULL; |
| 2541 | } |
| 2542 | alias_ty res = NULL; |
| 2543 | int mark = p->mark; |
| 2544 | { // dotted_name ['as' NAME] |
| 2545 | expr_ty a; |
| 2546 | void *b; |
| 2547 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2548 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2549 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2550 | (b = _tmp_37_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2551 | ) |
| 2552 | { |
| 2553 | res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2554 | if (res == NULL && PyErr_Occurred()) { |
| 2555 | p->error_indicator = 1; |
| 2556 | return NULL; |
| 2557 | } |
| 2558 | goto done; |
| 2559 | } |
| 2560 | p->mark = mark; |
| 2561 | } |
| 2562 | res = NULL; |
| 2563 | done: |
| 2564 | return res; |
| 2565 | } |
| 2566 | |
| 2567 | // Left-recursive |
| 2568 | // dotted_name: dotted_name '.' NAME | NAME |
| 2569 | static expr_ty dotted_name_raw(Parser *); |
| 2570 | static expr_ty |
| 2571 | dotted_name_rule(Parser *p) |
| 2572 | { |
| 2573 | expr_ty res = NULL; |
| 2574 | if (_PyPegen_is_memoized(p, dotted_name_type, &res)) |
| 2575 | return res; |
| 2576 | int mark = p->mark; |
| 2577 | int resmark = p->mark; |
| 2578 | while (1) { |
| 2579 | int tmpvar_0 = _PyPegen_update_memo(p, mark, dotted_name_type, res); |
| 2580 | if (tmpvar_0) { |
| 2581 | return res; |
| 2582 | } |
| 2583 | p->mark = mark; |
| 2584 | void *raw = dotted_name_raw(p); |
| 2585 | if (raw == NULL || p->mark <= resmark) |
| 2586 | break; |
| 2587 | resmark = p->mark; |
| 2588 | res = raw; |
| 2589 | } |
| 2590 | p->mark = resmark; |
| 2591 | return res; |
| 2592 | } |
| 2593 | static expr_ty |
| 2594 | dotted_name_raw(Parser *p) |
| 2595 | { |
| 2596 | if (p->error_indicator) { |
| 2597 | return NULL; |
| 2598 | } |
| 2599 | expr_ty res = NULL; |
| 2600 | int mark = p->mark; |
| 2601 | { // dotted_name '.' NAME |
| 2602 | expr_ty a; |
| 2603 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2604 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2605 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2606 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2607 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2608 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2609 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2610 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2611 | ) |
| 2612 | { |
| 2613 | res = _PyPegen_join_names_with_dot ( p , a , b ); |
| 2614 | if (res == NULL && PyErr_Occurred()) { |
| 2615 | p->error_indicator = 1; |
| 2616 | return NULL; |
| 2617 | } |
| 2618 | goto done; |
| 2619 | } |
| 2620 | p->mark = mark; |
| 2621 | } |
| 2622 | { // NAME |
| 2623 | expr_ty name_var; |
| 2624 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2625 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2626 | ) |
| 2627 | { |
| 2628 | res = name_var; |
| 2629 | goto done; |
| 2630 | } |
| 2631 | p->mark = mark; |
| 2632 | } |
| 2633 | res = NULL; |
| 2634 | done: |
| 2635 | return res; |
| 2636 | } |
| 2637 | |
| 2638 | // if_stmt: |
| 2639 | // | 'if' named_expression ':' block elif_stmt |
| 2640 | // | 'if' named_expression ':' block else_block? |
| 2641 | static stmt_ty |
| 2642 | if_stmt_rule(Parser *p) |
| 2643 | { |
| 2644 | if (p->error_indicator) { |
| 2645 | return NULL; |
| 2646 | } |
| 2647 | stmt_ty res = NULL; |
| 2648 | int mark = p->mark; |
| 2649 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2650 | p->error_indicator = 1; |
| 2651 | return NULL; |
| 2652 | } |
| 2653 | int start_lineno = p->tokens[mark]->lineno; |
| 2654 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2655 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2656 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2657 | { // 'if' named_expression ':' block elif_stmt |
| 2658 | expr_ty a; |
| 2659 | asdl_seq* b; |
| 2660 | stmt_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2661 | Token * keyword; |
| 2662 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2663 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2664 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2665 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2666 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2667 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2668 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2669 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2670 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2671 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2672 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2673 | ) |
| 2674 | { |
| 2675 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2676 | if (token == NULL) { |
| 2677 | return NULL; |
| 2678 | } |
| 2679 | int end_lineno = token->end_lineno; |
| 2680 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2681 | int end_col_offset = token->end_col_offset; |
| 2682 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2683 | res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2684 | if (res == NULL && PyErr_Occurred()) { |
| 2685 | p->error_indicator = 1; |
| 2686 | return NULL; |
| 2687 | } |
| 2688 | goto done; |
| 2689 | } |
| 2690 | p->mark = mark; |
| 2691 | } |
| 2692 | { // 'if' named_expression ':' block else_block? |
| 2693 | expr_ty a; |
| 2694 | asdl_seq* b; |
| 2695 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2696 | Token * keyword; |
| 2697 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2698 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2699 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2700 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2701 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2702 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2703 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2704 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2705 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2706 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2707 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2708 | ) |
| 2709 | { |
| 2710 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2711 | if (token == NULL) { |
| 2712 | return NULL; |
| 2713 | } |
| 2714 | int end_lineno = token->end_lineno; |
| 2715 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2716 | int end_col_offset = token->end_col_offset; |
| 2717 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2718 | res = _Py_If ( a , b , c , EXTRA ); |
| 2719 | if (res == NULL && PyErr_Occurred()) { |
| 2720 | p->error_indicator = 1; |
| 2721 | return NULL; |
| 2722 | } |
| 2723 | goto done; |
| 2724 | } |
| 2725 | p->mark = mark; |
| 2726 | } |
| 2727 | res = NULL; |
| 2728 | done: |
| 2729 | return res; |
| 2730 | } |
| 2731 | |
| 2732 | // elif_stmt: |
| 2733 | // | 'elif' named_expression ':' block elif_stmt |
| 2734 | // | 'elif' named_expression ':' block else_block? |
| 2735 | static stmt_ty |
| 2736 | elif_stmt_rule(Parser *p) |
| 2737 | { |
| 2738 | if (p->error_indicator) { |
| 2739 | return NULL; |
| 2740 | } |
| 2741 | stmt_ty res = NULL; |
| 2742 | int mark = p->mark; |
| 2743 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2744 | p->error_indicator = 1; |
| 2745 | return NULL; |
| 2746 | } |
| 2747 | int start_lineno = p->tokens[mark]->lineno; |
| 2748 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2749 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2750 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2751 | { // 'elif' named_expression ':' block elif_stmt |
| 2752 | expr_ty a; |
| 2753 | asdl_seq* b; |
| 2754 | stmt_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2755 | Token * keyword; |
| 2756 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2757 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2758 | (keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2759 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2760 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2761 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2762 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2763 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2764 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2765 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2766 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2767 | ) |
| 2768 | { |
| 2769 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2770 | if (token == NULL) { |
| 2771 | return NULL; |
| 2772 | } |
| 2773 | int end_lineno = token->end_lineno; |
| 2774 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2775 | int end_col_offset = token->end_col_offset; |
| 2776 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2777 | res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2778 | if (res == NULL && PyErr_Occurred()) { |
| 2779 | p->error_indicator = 1; |
| 2780 | return NULL; |
| 2781 | } |
| 2782 | goto done; |
| 2783 | } |
| 2784 | p->mark = mark; |
| 2785 | } |
| 2786 | { // 'elif' named_expression ':' block else_block? |
| 2787 | expr_ty a; |
| 2788 | asdl_seq* b; |
| 2789 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2790 | Token * keyword; |
| 2791 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2792 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2793 | (keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2794 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2795 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2796 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2797 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2798 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2799 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2800 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2801 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2802 | ) |
| 2803 | { |
| 2804 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2805 | if (token == NULL) { |
| 2806 | return NULL; |
| 2807 | } |
| 2808 | int end_lineno = token->end_lineno; |
| 2809 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2810 | int end_col_offset = token->end_col_offset; |
| 2811 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2812 | res = _Py_If ( a , b , c , EXTRA ); |
| 2813 | if (res == NULL && PyErr_Occurred()) { |
| 2814 | p->error_indicator = 1; |
| 2815 | return NULL; |
| 2816 | } |
| 2817 | goto done; |
| 2818 | } |
| 2819 | p->mark = mark; |
| 2820 | } |
| 2821 | res = NULL; |
| 2822 | done: |
| 2823 | return res; |
| 2824 | } |
| 2825 | |
| 2826 | // else_block: 'else' ':' block |
| 2827 | static asdl_seq* |
| 2828 | else_block_rule(Parser *p) |
| 2829 | { |
| 2830 | if (p->error_indicator) { |
| 2831 | return NULL; |
| 2832 | } |
| 2833 | asdl_seq* res = NULL; |
| 2834 | int mark = p->mark; |
| 2835 | { // 'else' ':' block |
| 2836 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2837 | Token * keyword; |
| 2838 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2839 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2840 | (keyword = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2841 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2842 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2843 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2844 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2845 | ) |
| 2846 | { |
| 2847 | res = b; |
| 2848 | if (res == NULL && PyErr_Occurred()) { |
| 2849 | p->error_indicator = 1; |
| 2850 | return NULL; |
| 2851 | } |
| 2852 | goto done; |
| 2853 | } |
| 2854 | p->mark = mark; |
| 2855 | } |
| 2856 | res = NULL; |
| 2857 | done: |
| 2858 | return res; |
| 2859 | } |
| 2860 | |
| 2861 | // while_stmt: 'while' named_expression ':' block else_block? |
| 2862 | static stmt_ty |
| 2863 | while_stmt_rule(Parser *p) |
| 2864 | { |
| 2865 | if (p->error_indicator) { |
| 2866 | return NULL; |
| 2867 | } |
| 2868 | stmt_ty res = NULL; |
| 2869 | int mark = p->mark; |
| 2870 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2871 | p->error_indicator = 1; |
| 2872 | return NULL; |
| 2873 | } |
| 2874 | int start_lineno = p->tokens[mark]->lineno; |
| 2875 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2876 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2877 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2878 | { // 'while' named_expression ':' block else_block? |
| 2879 | expr_ty a; |
| 2880 | asdl_seq* b; |
| 2881 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2882 | Token * keyword; |
| 2883 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2884 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2885 | (keyword = _PyPegen_expect_token(p, 512)) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2886 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2887 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2888 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2889 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2890 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2891 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2892 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2893 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2894 | ) |
| 2895 | { |
| 2896 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2897 | if (token == NULL) { |
| 2898 | return NULL; |
| 2899 | } |
| 2900 | int end_lineno = token->end_lineno; |
| 2901 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2902 | int end_col_offset = token->end_col_offset; |
| 2903 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2904 | res = _Py_While ( a , b , c , EXTRA ); |
| 2905 | if (res == NULL && PyErr_Occurred()) { |
| 2906 | p->error_indicator = 1; |
| 2907 | return NULL; |
| 2908 | } |
| 2909 | goto done; |
| 2910 | } |
| 2911 | p->mark = mark; |
| 2912 | } |
| 2913 | res = NULL; |
| 2914 | done: |
| 2915 | return res; |
| 2916 | } |
| 2917 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2918 | // for_stmt: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2919 | // | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
| 2920 | // | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2921 | static stmt_ty |
| 2922 | for_stmt_rule(Parser *p) |
| 2923 | { |
| 2924 | if (p->error_indicator) { |
| 2925 | return NULL; |
| 2926 | } |
| 2927 | stmt_ty res = NULL; |
| 2928 | int mark = p->mark; |
| 2929 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2930 | p->error_indicator = 1; |
| 2931 | return NULL; |
| 2932 | } |
| 2933 | int start_lineno = p->tokens[mark]->lineno; |
| 2934 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2935 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2936 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2937 | { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2938 | asdl_seq* b; |
| 2939 | void *el; |
| 2940 | expr_ty ex; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2941 | Token * keyword; |
| 2942 | Token * keyword_1; |
| 2943 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2944 | expr_ty t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2945 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2946 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2947 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2948 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2949 | (t = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2950 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2951 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2952 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2953 | (ex = star_expressions_rule(p)) // star_expressions |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2954 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2955 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2958 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2959 | (b = block_rule(p)) // block |
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 | (el = else_block_rule(p), 1) // else_block? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2962 | ) |
| 2963 | { |
| 2964 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2965 | if (token == NULL) { |
| 2966 | return NULL; |
| 2967 | } |
| 2968 | int end_lineno = token->end_lineno; |
| 2969 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2970 | int end_col_offset = token->end_col_offset; |
| 2971 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2972 | res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 2973 | if (res == NULL && PyErr_Occurred()) { |
| 2974 | p->error_indicator = 1; |
| 2975 | return NULL; |
| 2976 | } |
| 2977 | goto done; |
| 2978 | } |
| 2979 | p->mark = mark; |
| 2980 | } |
| 2981 | { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2982 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2983 | asdl_seq* b; |
| 2984 | void *el; |
| 2985 | expr_ty ex; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2986 | Token * keyword; |
| 2987 | Token * keyword_1; |
| 2988 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2989 | expr_ty t; |
| 2990 | void *tc; |
| 2991 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2992 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2993 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2994 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2995 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2996 | (t = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2997 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 2998 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2999 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3000 | (ex = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3001 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3002 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3005 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3006 | (b = block_rule(p)) // block |
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 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3009 | ) |
| 3010 | { |
| 3011 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3012 | if (token == NULL) { |
| 3013 | return NULL; |
| 3014 | } |
| 3015 | int end_lineno = token->end_lineno; |
| 3016 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3017 | int end_col_offset = token->end_col_offset; |
| 3018 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3019 | res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3020 | if (res == NULL && PyErr_Occurred()) { |
| 3021 | p->error_indicator = 1; |
| 3022 | return NULL; |
| 3023 | } |
| 3024 | goto done; |
| 3025 | } |
| 3026 | p->mark = mark; |
| 3027 | } |
| 3028 | res = NULL; |
| 3029 | done: |
| 3030 | return res; |
| 3031 | } |
| 3032 | |
| 3033 | // with_stmt: |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3034 | // | 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3035 | // | 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3036 | // | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3037 | // | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3038 | static stmt_ty |
| 3039 | with_stmt_rule(Parser *p) |
| 3040 | { |
| 3041 | if (p->error_indicator) { |
| 3042 | return NULL; |
| 3043 | } |
| 3044 | stmt_ty res = NULL; |
| 3045 | int mark = p->mark; |
| 3046 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3047 | p->error_indicator = 1; |
| 3048 | return NULL; |
| 3049 | } |
| 3050 | int start_lineno = p->tokens[mark]->lineno; |
| 3051 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3052 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3053 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3054 | { // 'with' '(' ','.with_item+ ','? ')' ':' block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3055 | asdl_seq * a; |
| 3056 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3057 | Token * keyword; |
| 3058 | Token * literal; |
| 3059 | Token * literal_1; |
| 3060 | Token * literal_2; |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3061 | void *opt_var; |
| 3062 | UNUSED(opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3063 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3064 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3065 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3066 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3067 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3068 | (a = _gather_38_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3069 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3070 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3071 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3072 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3073 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3074 | (literal_2 = _PyPegen_expect_token(p, 11)) // 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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3077 | ) |
| 3078 | { |
| 3079 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3080 | if (token == NULL) { |
| 3081 | return NULL; |
| 3082 | } |
| 3083 | int end_lineno = token->end_lineno; |
| 3084 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3085 | int end_col_offset = token->end_col_offset; |
| 3086 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3087 | res = _Py_With ( a , b , NULL , EXTRA ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3088 | if (res == NULL && PyErr_Occurred()) { |
| 3089 | p->error_indicator = 1; |
| 3090 | return NULL; |
| 3091 | } |
| 3092 | goto done; |
| 3093 | } |
| 3094 | p->mark = mark; |
| 3095 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3096 | { // 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3097 | asdl_seq * a; |
| 3098 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3099 | Token * keyword; |
| 3100 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3101 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3102 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3103 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3104 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3105 | (a = _gather_40_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3106 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3107 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3108 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3109 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3110 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3111 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3112 | ) |
| 3113 | { |
| 3114 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3115 | if (token == NULL) { |
| 3116 | return NULL; |
| 3117 | } |
| 3118 | int end_lineno = token->end_lineno; |
| 3119 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3120 | int end_col_offset = token->end_col_offset; |
| 3121 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3122 | res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3123 | if (res == NULL && PyErr_Occurred()) { |
| 3124 | p->error_indicator = 1; |
| 3125 | return NULL; |
| 3126 | } |
| 3127 | goto done; |
| 3128 | } |
| 3129 | p->mark = mark; |
| 3130 | } |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3131 | { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3132 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3133 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3134 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3135 | Token * keyword; |
| 3136 | Token * literal; |
| 3137 | Token * literal_1; |
| 3138 | Token * literal_2; |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3139 | void *opt_var; |
| 3140 | UNUSED(opt_var); // Silence compiler warnings |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3141 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3142 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3143 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3144 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3145 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3146 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3147 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3148 | (a = _gather_42_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3149 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3150 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3151 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3152 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3153 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3154 | (literal_2 = _PyPegen_expect_token(p, 11)) // 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 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3157 | ) |
| 3158 | { |
| 3159 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3160 | if (token == NULL) { |
| 3161 | return NULL; |
| 3162 | } |
| 3163 | int end_lineno = token->end_lineno; |
| 3164 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3165 | int end_col_offset = token->end_col_offset; |
| 3166 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3167 | res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) ); |
| 3168 | if (res == NULL && PyErr_Occurred()) { |
| 3169 | p->error_indicator = 1; |
| 3170 | return NULL; |
| 3171 | } |
| 3172 | goto done; |
| 3173 | } |
| 3174 | p->mark = mark; |
| 3175 | } |
| 3176 | { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
| 3177 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3178 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3179 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3180 | Token * keyword; |
| 3181 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3182 | void *tc; |
| 3183 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3184 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3185 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3186 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3187 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3188 | (a = _gather_44_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3189 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3190 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3191 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3192 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3193 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3194 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3195 | ) |
| 3196 | { |
| 3197 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3198 | if (token == NULL) { |
| 3199 | return NULL; |
| 3200 | } |
| 3201 | int end_lineno = token->end_lineno; |
| 3202 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3203 | int end_col_offset = token->end_col_offset; |
| 3204 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3205 | res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3206 | if (res == NULL && PyErr_Occurred()) { |
| 3207 | p->error_indicator = 1; |
| 3208 | return NULL; |
| 3209 | } |
| 3210 | goto done; |
| 3211 | } |
| 3212 | p->mark = mark; |
| 3213 | } |
| 3214 | res = NULL; |
| 3215 | done: |
| 3216 | return res; |
| 3217 | } |
| 3218 | |
| 3219 | // with_item: expression ['as' target] |
| 3220 | static withitem_ty |
| 3221 | with_item_rule(Parser *p) |
| 3222 | { |
| 3223 | if (p->error_indicator) { |
| 3224 | return NULL; |
| 3225 | } |
| 3226 | withitem_ty res = NULL; |
| 3227 | int mark = p->mark; |
| 3228 | { // expression ['as' target] |
| 3229 | expr_ty e; |
| 3230 | void *o; |
| 3231 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3232 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3233 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3234 | (o = _tmp_46_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3235 | ) |
| 3236 | { |
| 3237 | res = _Py_withitem ( e , o , p -> arena ); |
| 3238 | if (res == NULL && PyErr_Occurred()) { |
| 3239 | p->error_indicator = 1; |
| 3240 | return NULL; |
| 3241 | } |
| 3242 | goto done; |
| 3243 | } |
| 3244 | p->mark = mark; |
| 3245 | } |
| 3246 | res = NULL; |
| 3247 | done: |
| 3248 | return res; |
| 3249 | } |
| 3250 | |
| 3251 | // try_stmt: |
| 3252 | // | 'try' ':' block finally_block |
| 3253 | // | 'try' ':' block except_block+ else_block? finally_block? |
| 3254 | static stmt_ty |
| 3255 | try_stmt_rule(Parser *p) |
| 3256 | { |
| 3257 | if (p->error_indicator) { |
| 3258 | return NULL; |
| 3259 | } |
| 3260 | stmt_ty res = NULL; |
| 3261 | int mark = p->mark; |
| 3262 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3263 | p->error_indicator = 1; |
| 3264 | return NULL; |
| 3265 | } |
| 3266 | int start_lineno = p->tokens[mark]->lineno; |
| 3267 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3268 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3269 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3270 | { // 'try' ':' block finally_block |
| 3271 | asdl_seq* b; |
| 3272 | asdl_seq* f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3273 | Token * keyword; |
| 3274 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3275 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3276 | (keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3277 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3278 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3279 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3280 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3281 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3282 | (f = finally_block_rule(p)) // finally_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3283 | ) |
| 3284 | { |
| 3285 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3286 | if (token == NULL) { |
| 3287 | return NULL; |
| 3288 | } |
| 3289 | int end_lineno = token->end_lineno; |
| 3290 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3291 | int end_col_offset = token->end_col_offset; |
| 3292 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3293 | res = _Py_Try ( b , NULL , NULL , f , EXTRA ); |
| 3294 | if (res == NULL && PyErr_Occurred()) { |
| 3295 | p->error_indicator = 1; |
| 3296 | return NULL; |
| 3297 | } |
| 3298 | goto done; |
| 3299 | } |
| 3300 | p->mark = mark; |
| 3301 | } |
| 3302 | { // 'try' ':' block except_block+ else_block? finally_block? |
| 3303 | asdl_seq* b; |
| 3304 | void *el; |
| 3305 | asdl_seq * ex; |
| 3306 | void *f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3307 | Token * keyword; |
| 3308 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3309 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3310 | (keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3311 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3312 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3313 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3314 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3315 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3316 | (ex = _loop1_47_rule(p)) // except_block+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3317 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3318 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3319 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3320 | (f = finally_block_rule(p), 1) // finally_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3321 | ) |
| 3322 | { |
| 3323 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3324 | if (token == NULL) { |
| 3325 | return NULL; |
| 3326 | } |
| 3327 | int end_lineno = token->end_lineno; |
| 3328 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3329 | int end_col_offset = token->end_col_offset; |
| 3330 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3331 | res = _Py_Try ( b , ex , el , f , EXTRA ); |
| 3332 | if (res == NULL && PyErr_Occurred()) { |
| 3333 | p->error_indicator = 1; |
| 3334 | return NULL; |
| 3335 | } |
| 3336 | goto done; |
| 3337 | } |
| 3338 | p->mark = mark; |
| 3339 | } |
| 3340 | res = NULL; |
| 3341 | done: |
| 3342 | return res; |
| 3343 | } |
| 3344 | |
| 3345 | // except_block: 'except' expression ['as' target] ':' block | 'except' ':' block |
| 3346 | static excepthandler_ty |
| 3347 | except_block_rule(Parser *p) |
| 3348 | { |
| 3349 | if (p->error_indicator) { |
| 3350 | return NULL; |
| 3351 | } |
| 3352 | excepthandler_ty res = NULL; |
| 3353 | int mark = p->mark; |
| 3354 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3355 | p->error_indicator = 1; |
| 3356 | return NULL; |
| 3357 | } |
| 3358 | int start_lineno = p->tokens[mark]->lineno; |
| 3359 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3360 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3361 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3362 | { // 'except' expression ['as' target] ':' block |
| 3363 | asdl_seq* b; |
| 3364 | expr_ty e; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3365 | Token * keyword; |
| 3366 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3367 | void *t; |
| 3368 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3369 | (keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3370 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3371 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3372 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3373 | (t = _tmp_48_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3374 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3375 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3376 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3377 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3378 | ) |
| 3379 | { |
| 3380 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3381 | if (token == NULL) { |
| 3382 | return NULL; |
| 3383 | } |
| 3384 | int end_lineno = token->end_lineno; |
| 3385 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3386 | int end_col_offset = token->end_col_offset; |
| 3387 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3388 | res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA ); |
| 3389 | if (res == NULL && PyErr_Occurred()) { |
| 3390 | p->error_indicator = 1; |
| 3391 | return NULL; |
| 3392 | } |
| 3393 | goto done; |
| 3394 | } |
| 3395 | p->mark = mark; |
| 3396 | } |
| 3397 | { // 'except' ':' block |
| 3398 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3399 | Token * keyword; |
| 3400 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3401 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3402 | (keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3403 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3404 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3405 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3406 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3407 | ) |
| 3408 | { |
| 3409 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3410 | if (token == NULL) { |
| 3411 | return NULL; |
| 3412 | } |
| 3413 | int end_lineno = token->end_lineno; |
| 3414 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3415 | int end_col_offset = token->end_col_offset; |
| 3416 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3417 | res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA ); |
| 3418 | if (res == NULL && PyErr_Occurred()) { |
| 3419 | p->error_indicator = 1; |
| 3420 | return NULL; |
| 3421 | } |
| 3422 | goto done; |
| 3423 | } |
| 3424 | p->mark = mark; |
| 3425 | } |
| 3426 | res = NULL; |
| 3427 | done: |
| 3428 | return res; |
| 3429 | } |
| 3430 | |
| 3431 | // finally_block: 'finally' ':' block |
| 3432 | static asdl_seq* |
| 3433 | finally_block_rule(Parser *p) |
| 3434 | { |
| 3435 | if (p->error_indicator) { |
| 3436 | return NULL; |
| 3437 | } |
| 3438 | asdl_seq* res = NULL; |
| 3439 | int mark = p->mark; |
| 3440 | { // 'finally' ':' block |
| 3441 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3442 | Token * keyword; |
| 3443 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3444 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3445 | (keyword = _PyPegen_expect_token(p, 521)) // token='finally' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3446 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3447 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3448 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3449 | (a = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3450 | ) |
| 3451 | { |
| 3452 | res = a; |
| 3453 | if (res == NULL && PyErr_Occurred()) { |
| 3454 | p->error_indicator = 1; |
| 3455 | return NULL; |
| 3456 | } |
| 3457 | goto done; |
| 3458 | } |
| 3459 | p->mark = mark; |
| 3460 | } |
| 3461 | res = NULL; |
| 3462 | done: |
| 3463 | return res; |
| 3464 | } |
| 3465 | |
| 3466 | // return_stmt: 'return' star_expressions? |
| 3467 | static stmt_ty |
| 3468 | return_stmt_rule(Parser *p) |
| 3469 | { |
| 3470 | if (p->error_indicator) { |
| 3471 | return NULL; |
| 3472 | } |
| 3473 | stmt_ty res = NULL; |
| 3474 | int mark = p->mark; |
| 3475 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3476 | p->error_indicator = 1; |
| 3477 | return NULL; |
| 3478 | } |
| 3479 | int start_lineno = p->tokens[mark]->lineno; |
| 3480 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3481 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3482 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3483 | { // 'return' star_expressions? |
| 3484 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3485 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3486 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3487 | (keyword = _PyPegen_expect_token(p, 500)) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3488 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3489 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3490 | ) |
| 3491 | { |
| 3492 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3493 | if (token == NULL) { |
| 3494 | return NULL; |
| 3495 | } |
| 3496 | int end_lineno = token->end_lineno; |
| 3497 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3498 | int end_col_offset = token->end_col_offset; |
| 3499 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3500 | res = _Py_Return ( a , EXTRA ); |
| 3501 | if (res == NULL && PyErr_Occurred()) { |
| 3502 | p->error_indicator = 1; |
| 3503 | return NULL; |
| 3504 | } |
| 3505 | goto done; |
| 3506 | } |
| 3507 | p->mark = mark; |
| 3508 | } |
| 3509 | res = NULL; |
| 3510 | done: |
| 3511 | return res; |
| 3512 | } |
| 3513 | |
| 3514 | // raise_stmt: 'raise' expression ['from' expression] | 'raise' |
| 3515 | static stmt_ty |
| 3516 | raise_stmt_rule(Parser *p) |
| 3517 | { |
| 3518 | if (p->error_indicator) { |
| 3519 | return NULL; |
| 3520 | } |
| 3521 | stmt_ty res = NULL; |
| 3522 | int mark = p->mark; |
| 3523 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3524 | p->error_indicator = 1; |
| 3525 | return NULL; |
| 3526 | } |
| 3527 | int start_lineno = p->tokens[mark]->lineno; |
| 3528 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3529 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3530 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3531 | { // 'raise' expression ['from' expression] |
| 3532 | expr_ty a; |
| 3533 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3534 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3535 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3536 | (keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3537 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3538 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3539 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3540 | (b = _tmp_49_rule(p), 1) // ['from' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3541 | ) |
| 3542 | { |
| 3543 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3544 | if (token == NULL) { |
| 3545 | return NULL; |
| 3546 | } |
| 3547 | int end_lineno = token->end_lineno; |
| 3548 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3549 | int end_col_offset = token->end_col_offset; |
| 3550 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3551 | res = _Py_Raise ( a , b , EXTRA ); |
| 3552 | if (res == NULL && PyErr_Occurred()) { |
| 3553 | p->error_indicator = 1; |
| 3554 | return NULL; |
| 3555 | } |
| 3556 | goto done; |
| 3557 | } |
| 3558 | p->mark = mark; |
| 3559 | } |
| 3560 | { // 'raise' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3561 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3562 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3563 | (keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3564 | ) |
| 3565 | { |
| 3566 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3567 | if (token == NULL) { |
| 3568 | return NULL; |
| 3569 | } |
| 3570 | int end_lineno = token->end_lineno; |
| 3571 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3572 | int end_col_offset = token->end_col_offset; |
| 3573 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3574 | res = _Py_Raise ( NULL , NULL , EXTRA ); |
| 3575 | if (res == NULL && PyErr_Occurred()) { |
| 3576 | p->error_indicator = 1; |
| 3577 | return NULL; |
| 3578 | } |
| 3579 | goto done; |
| 3580 | } |
| 3581 | p->mark = mark; |
| 3582 | } |
| 3583 | res = NULL; |
| 3584 | done: |
| 3585 | return res; |
| 3586 | } |
| 3587 | |
| 3588 | // function_def: decorators function_def_raw | function_def_raw |
| 3589 | static stmt_ty |
| 3590 | function_def_rule(Parser *p) |
| 3591 | { |
| 3592 | if (p->error_indicator) { |
| 3593 | return NULL; |
| 3594 | } |
| 3595 | stmt_ty res = NULL; |
| 3596 | int mark = p->mark; |
| 3597 | { // decorators function_def_raw |
| 3598 | asdl_seq* d; |
| 3599 | stmt_ty f; |
| 3600 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3601 | (d = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3602 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3603 | (f = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3604 | ) |
| 3605 | { |
| 3606 | res = _PyPegen_function_def_decorators ( p , d , f ); |
| 3607 | if (res == NULL && PyErr_Occurred()) { |
| 3608 | p->error_indicator = 1; |
| 3609 | return NULL; |
| 3610 | } |
| 3611 | goto done; |
| 3612 | } |
| 3613 | p->mark = mark; |
| 3614 | } |
| 3615 | { // function_def_raw |
| 3616 | stmt_ty function_def_raw_var; |
| 3617 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3618 | (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3619 | ) |
| 3620 | { |
| 3621 | res = function_def_raw_var; |
| 3622 | goto done; |
| 3623 | } |
| 3624 | p->mark = mark; |
| 3625 | } |
| 3626 | res = NULL; |
| 3627 | done: |
| 3628 | return res; |
| 3629 | } |
| 3630 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3631 | // function_def_raw: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3632 | // | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3633 | // | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3634 | static stmt_ty |
| 3635 | function_def_raw_rule(Parser *p) |
| 3636 | { |
| 3637 | if (p->error_indicator) { |
| 3638 | return NULL; |
| 3639 | } |
| 3640 | stmt_ty res = NULL; |
| 3641 | int mark = p->mark; |
| 3642 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3643 | p->error_indicator = 1; |
| 3644 | return NULL; |
| 3645 | } |
| 3646 | int start_lineno = p->tokens[mark]->lineno; |
| 3647 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3648 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3649 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3650 | { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3651 | void *a; |
| 3652 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3653 | Token * keyword; |
| 3654 | Token * literal; |
| 3655 | Token * literal_1; |
| 3656 | Token * literal_2; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3657 | expr_ty n; |
| 3658 | void *params; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3659 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3660 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3661 | (keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3662 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3663 | (n = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3664 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3665 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3666 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3667 | (params = params_rule(p), 1) // params? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3668 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3669 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
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 | (a = _tmp_50_rule(p), 1) // ['->' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3672 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3673 | (literal_2 = _PyPegen_expect_token(p, 11)) // 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 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3676 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3677 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3678 | ) |
| 3679 | { |
| 3680 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3681 | if (token == NULL) { |
| 3682 | return NULL; |
| 3683 | } |
| 3684 | int end_lineno = token->end_lineno; |
| 3685 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3686 | int end_col_offset = token->end_col_offset; |
| 3687 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3688 | res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3689 | if (res == NULL && PyErr_Occurred()) { |
| 3690 | p->error_indicator = 1; |
| 3691 | return NULL; |
| 3692 | } |
| 3693 | goto done; |
| 3694 | } |
| 3695 | p->mark = mark; |
| 3696 | } |
| 3697 | { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3698 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3699 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3700 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3701 | Token * keyword; |
| 3702 | Token * literal; |
| 3703 | Token * literal_1; |
| 3704 | Token * literal_2; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3705 | expr_ty n; |
| 3706 | void *params; |
| 3707 | void *tc; |
| 3708 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3709 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3710 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3711 | (keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3712 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3713 | (n = _PyPegen_name_token(p)) // NAME |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3714 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3715 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3716 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3717 | (params = params_rule(p), 1) // params? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3718 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3719 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
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 | (a = _tmp_51_rule(p), 1) // ['->' expression] |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3722 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3723 | (literal_2 = _PyPegen_expect_token(p, 11)) // 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 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3726 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3727 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3728 | ) |
| 3729 | { |
| 3730 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3731 | if (token == NULL) { |
| 3732 | return NULL; |
| 3733 | } |
| 3734 | int end_lineno = token->end_lineno; |
| 3735 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3736 | int end_col_offset = token->end_col_offset; |
| 3737 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3738 | res = CHECK_VERSION ( 5 , "Async functions are" , _Py_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3739 | if (res == NULL && PyErr_Occurred()) { |
| 3740 | p->error_indicator = 1; |
| 3741 | return NULL; |
| 3742 | } |
| 3743 | goto done; |
| 3744 | } |
| 3745 | p->mark = mark; |
| 3746 | } |
| 3747 | res = NULL; |
| 3748 | done: |
| 3749 | return res; |
| 3750 | } |
| 3751 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3752 | // func_type_comment: |
| 3753 | // | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 3754 | // | invalid_double_type_comments |
| 3755 | // | TYPE_COMMENT |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 3756 | static Token* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3757 | func_type_comment_rule(Parser *p) |
| 3758 | { |
| 3759 | if (p->error_indicator) { |
| 3760 | return NULL; |
| 3761 | } |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 3762 | Token* res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3763 | int mark = p->mark; |
| 3764 | { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3765 | Token * newline_var; |
| 3766 | Token * t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3767 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3768 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3769 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3770 | (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3771 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3772 | _PyPegen_lookahead(1, _tmp_52_rule, p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3773 | ) |
| 3774 | { |
| 3775 | res = t; |
| 3776 | if (res == NULL && PyErr_Occurred()) { |
| 3777 | p->error_indicator = 1; |
| 3778 | return NULL; |
| 3779 | } |
| 3780 | goto done; |
| 3781 | } |
| 3782 | p->mark = mark; |
| 3783 | } |
| 3784 | { // invalid_double_type_comments |
| 3785 | void *invalid_double_type_comments_var; |
| 3786 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3787 | (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] | 3788 | ) |
| 3789 | { |
| 3790 | res = invalid_double_type_comments_var; |
| 3791 | goto done; |
| 3792 | } |
| 3793 | p->mark = mark; |
| 3794 | } |
| 3795 | { // TYPE_COMMENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3796 | Token * type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3797 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3798 | (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] | 3799 | ) |
| 3800 | { |
| 3801 | res = type_comment_var; |
| 3802 | goto done; |
| 3803 | } |
| 3804 | p->mark = mark; |
| 3805 | } |
| 3806 | res = NULL; |
| 3807 | done: |
| 3808 | return res; |
| 3809 | } |
| 3810 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3811 | // params: invalid_parameters | parameters |
| 3812 | static arguments_ty |
| 3813 | params_rule(Parser *p) |
| 3814 | { |
| 3815 | if (p->error_indicator) { |
| 3816 | return NULL; |
| 3817 | } |
| 3818 | arguments_ty res = NULL; |
| 3819 | int mark = p->mark; |
| 3820 | { // invalid_parameters |
| 3821 | void *invalid_parameters_var; |
| 3822 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3823 | (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3824 | ) |
| 3825 | { |
| 3826 | res = invalid_parameters_var; |
| 3827 | goto done; |
| 3828 | } |
| 3829 | p->mark = mark; |
| 3830 | } |
| 3831 | { // parameters |
| 3832 | arguments_ty parameters_var; |
| 3833 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3834 | (parameters_var = parameters_rule(p)) // parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3835 | ) |
| 3836 | { |
| 3837 | res = parameters_var; |
| 3838 | goto done; |
| 3839 | } |
| 3840 | p->mark = mark; |
| 3841 | } |
| 3842 | res = NULL; |
| 3843 | done: |
| 3844 | return res; |
| 3845 | } |
| 3846 | |
| 3847 | // parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3848 | // | slash_no_default param_no_default* param_with_default* star_etc? |
| 3849 | // | slash_with_default param_with_default* star_etc? |
| 3850 | // | param_no_default+ param_with_default* star_etc? |
| 3851 | // | param_with_default+ star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3852 | // | star_etc |
| 3853 | static arguments_ty |
| 3854 | parameters_rule(Parser *p) |
| 3855 | { |
| 3856 | if (p->error_indicator) { |
| 3857 | return NULL; |
| 3858 | } |
| 3859 | arguments_ty res = NULL; |
| 3860 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3861 | { // slash_no_default param_no_default* param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3862 | asdl_seq* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3863 | asdl_seq * b; |
| 3864 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3865 | void *d; |
| 3866 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3867 | (a = slash_no_default_rule(p)) // slash_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3868 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3869 | (b = _loop0_53_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3870 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3871 | (c = _loop0_54_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3872 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3873 | (d = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3874 | ) |
| 3875 | { |
| 3876 | res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 3877 | if (res == NULL && PyErr_Occurred()) { |
| 3878 | p->error_indicator = 1; |
| 3879 | return NULL; |
| 3880 | } |
| 3881 | goto done; |
| 3882 | } |
| 3883 | p->mark = mark; |
| 3884 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3885 | { // slash_with_default param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3886 | SlashWithDefault* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3887 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3888 | void *c; |
| 3889 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3890 | (a = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3891 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3892 | (b = _loop0_55_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3893 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3894 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3895 | ) |
| 3896 | { |
| 3897 | res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 3898 | if (res == NULL && PyErr_Occurred()) { |
| 3899 | p->error_indicator = 1; |
| 3900 | return NULL; |
| 3901 | } |
| 3902 | goto done; |
| 3903 | } |
| 3904 | p->mark = mark; |
| 3905 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3906 | { // param_no_default+ param_with_default* star_etc? |
| 3907 | asdl_seq * a; |
| 3908 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3909 | void *c; |
| 3910 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3911 | (a = _loop1_56_rule(p)) // param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3912 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3913 | (b = _loop0_57_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3914 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3915 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3916 | ) |
| 3917 | { |
| 3918 | res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 3919 | if (res == NULL && PyErr_Occurred()) { |
| 3920 | p->error_indicator = 1; |
| 3921 | return NULL; |
| 3922 | } |
| 3923 | goto done; |
| 3924 | } |
| 3925 | p->mark = mark; |
| 3926 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3927 | { // param_with_default+ star_etc? |
| 3928 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3929 | void *b; |
| 3930 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3931 | (a = _loop1_58_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3932 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3933 | (b = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3934 | ) |
| 3935 | { |
| 3936 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 3937 | if (res == NULL && PyErr_Occurred()) { |
| 3938 | p->error_indicator = 1; |
| 3939 | return NULL; |
| 3940 | } |
| 3941 | goto done; |
| 3942 | } |
| 3943 | p->mark = mark; |
| 3944 | } |
| 3945 | { // star_etc |
| 3946 | StarEtc* a; |
| 3947 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3948 | (a = star_etc_rule(p)) // star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3949 | ) |
| 3950 | { |
| 3951 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 3952 | if (res == NULL && PyErr_Occurred()) { |
| 3953 | p->error_indicator = 1; |
| 3954 | return NULL; |
| 3955 | } |
| 3956 | goto done; |
| 3957 | } |
| 3958 | p->mark = mark; |
| 3959 | } |
| 3960 | res = NULL; |
| 3961 | done: |
| 3962 | return res; |
| 3963 | } |
| 3964 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3965 | // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3966 | static asdl_seq* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3967 | slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3968 | { |
| 3969 | if (p->error_indicator) { |
| 3970 | return NULL; |
| 3971 | } |
| 3972 | asdl_seq* res = NULL; |
| 3973 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3974 | { // param_no_default+ '/' ',' |
| 3975 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3976 | Token * literal; |
| 3977 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3978 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3979 | (a = _loop1_59_rule(p)) // param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3980 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3981 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3982 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3983 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3984 | ) |
| 3985 | { |
| 3986 | res = a; |
| 3987 | if (res == NULL && PyErr_Occurred()) { |
| 3988 | p->error_indicator = 1; |
| 3989 | return NULL; |
| 3990 | } |
| 3991 | goto done; |
| 3992 | } |
| 3993 | p->mark = mark; |
| 3994 | } |
| 3995 | { // param_no_default+ '/' &')' |
| 3996 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3997 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3998 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 3999 | (a = _loop1_60_rule(p)) // param_no_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4000 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4001 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4002 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4003 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4004 | ) |
| 4005 | { |
| 4006 | res = a; |
| 4007 | if (res == NULL && PyErr_Occurred()) { |
| 4008 | p->error_indicator = 1; |
| 4009 | return NULL; |
| 4010 | } |
| 4011 | goto done; |
| 4012 | } |
| 4013 | p->mark = mark; |
| 4014 | } |
| 4015 | res = NULL; |
| 4016 | done: |
| 4017 | return res; |
| 4018 | } |
| 4019 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4020 | // slash_with_default: |
| 4021 | // | param_no_default* param_with_default+ '/' ',' |
| 4022 | // | param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4023 | static SlashWithDefault* |
| 4024 | slash_with_default_rule(Parser *p) |
| 4025 | { |
| 4026 | if (p->error_indicator) { |
| 4027 | return NULL; |
| 4028 | } |
| 4029 | SlashWithDefault* res = NULL; |
| 4030 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4031 | { // param_no_default* param_with_default+ '/' ',' |
| 4032 | asdl_seq * a; |
| 4033 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4034 | Token * literal; |
| 4035 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4036 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4037 | (a = _loop0_61_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4038 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4039 | (b = _loop1_62_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4040 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4041 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4042 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4043 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4044 | ) |
| 4045 | { |
| 4046 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 4047 | if (res == NULL && PyErr_Occurred()) { |
| 4048 | p->error_indicator = 1; |
| 4049 | return NULL; |
| 4050 | } |
| 4051 | goto done; |
| 4052 | } |
| 4053 | p->mark = mark; |
| 4054 | } |
| 4055 | { // param_no_default* param_with_default+ '/' &')' |
| 4056 | asdl_seq * a; |
| 4057 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4058 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4059 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4060 | (a = _loop0_63_rule(p)) // param_no_default* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4061 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4062 | (b = _loop1_64_rule(p)) // param_with_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4063 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4064 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4065 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4066 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4067 | ) |
| 4068 | { |
| 4069 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 4070 | if (res == NULL && PyErr_Occurred()) { |
| 4071 | p->error_indicator = 1; |
| 4072 | return NULL; |
| 4073 | } |
| 4074 | goto done; |
| 4075 | } |
| 4076 | p->mark = mark; |
| 4077 | } |
| 4078 | res = NULL; |
| 4079 | done: |
| 4080 | return res; |
| 4081 | } |
| 4082 | |
| 4083 | // star_etc: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4084 | // | '*' param_no_default param_maybe_default* kwds? |
| 4085 | // | '*' ',' param_maybe_default+ kwds? |
| 4086 | // | kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4087 | // | invalid_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4088 | static StarEtc* |
| 4089 | star_etc_rule(Parser *p) |
| 4090 | { |
| 4091 | if (p->error_indicator) { |
| 4092 | return NULL; |
| 4093 | } |
| 4094 | StarEtc* res = NULL; |
| 4095 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4096 | { // '*' param_no_default param_maybe_default* kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4097 | arg_ty a; |
| 4098 | asdl_seq * b; |
| 4099 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4100 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4101 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4102 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4103 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4104 | (a = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4105 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4106 | (b = _loop0_65_rule(p)) // param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4107 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4108 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4109 | ) |
| 4110 | { |
| 4111 | res = _PyPegen_star_etc ( p , a , b , c ); |
| 4112 | if (res == NULL && PyErr_Occurred()) { |
| 4113 | p->error_indicator = 1; |
| 4114 | return NULL; |
| 4115 | } |
| 4116 | goto done; |
| 4117 | } |
| 4118 | p->mark = mark; |
| 4119 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4120 | { // '*' ',' param_maybe_default+ kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4121 | asdl_seq * b; |
| 4122 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4123 | Token * literal; |
| 4124 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4125 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4126 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4127 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4128 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4129 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4130 | (b = _loop1_66_rule(p)) // param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4131 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4132 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4133 | ) |
| 4134 | { |
| 4135 | res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 4136 | if (res == NULL && PyErr_Occurred()) { |
| 4137 | p->error_indicator = 1; |
| 4138 | return NULL; |
| 4139 | } |
| 4140 | goto done; |
| 4141 | } |
| 4142 | p->mark = mark; |
| 4143 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4144 | { // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4145 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4146 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4147 | (a = kwds_rule(p)) // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4148 | ) |
| 4149 | { |
| 4150 | res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 4151 | if (res == NULL && PyErr_Occurred()) { |
| 4152 | p->error_indicator = 1; |
| 4153 | return NULL; |
| 4154 | } |
| 4155 | goto done; |
| 4156 | } |
| 4157 | p->mark = mark; |
| 4158 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4159 | { // invalid_star_etc |
| 4160 | void *invalid_star_etc_var; |
| 4161 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4162 | (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4163 | ) |
| 4164 | { |
| 4165 | res = invalid_star_etc_var; |
| 4166 | goto done; |
| 4167 | } |
| 4168 | p->mark = mark; |
| 4169 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4170 | res = NULL; |
| 4171 | done: |
| 4172 | return res; |
| 4173 | } |
| 4174 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4175 | // kwds: '**' param_no_default |
| 4176 | static arg_ty |
| 4177 | kwds_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4178 | { |
| 4179 | if (p->error_indicator) { |
| 4180 | return NULL; |
| 4181 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4182 | arg_ty res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4183 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4184 | { // '**' param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4185 | arg_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4186 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4187 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4188 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4189 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4190 | (a = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4191 | ) |
| 4192 | { |
| 4193 | res = a; |
| 4194 | if (res == NULL && PyErr_Occurred()) { |
| 4195 | p->error_indicator = 1; |
| 4196 | return NULL; |
| 4197 | } |
| 4198 | goto done; |
| 4199 | } |
| 4200 | p->mark = mark; |
| 4201 | } |
| 4202 | res = NULL; |
| 4203 | done: |
| 4204 | return res; |
| 4205 | } |
| 4206 | |
| 4207 | // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' |
| 4208 | static arg_ty |
| 4209 | param_no_default_rule(Parser *p) |
| 4210 | { |
| 4211 | if (p->error_indicator) { |
| 4212 | return NULL; |
| 4213 | } |
| 4214 | arg_ty res = NULL; |
| 4215 | int mark = p->mark; |
| 4216 | { // param ',' TYPE_COMMENT? |
| 4217 | arg_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4218 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4219 | void *tc; |
| 4220 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4221 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4222 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4223 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4224 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4225 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4226 | ) |
| 4227 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4228 | res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4229 | if (res == NULL && PyErr_Occurred()) { |
| 4230 | p->error_indicator = 1; |
| 4231 | return NULL; |
| 4232 | } |
| 4233 | goto done; |
| 4234 | } |
| 4235 | p->mark = mark; |
| 4236 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4237 | { // param TYPE_COMMENT? &')' |
| 4238 | arg_ty a; |
| 4239 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4240 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4241 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4242 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4243 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4244 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4245 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4246 | ) |
| 4247 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4248 | res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4249 | if (res == NULL && PyErr_Occurred()) { |
| 4250 | p->error_indicator = 1; |
| 4251 | return NULL; |
| 4252 | } |
| 4253 | goto done; |
| 4254 | } |
| 4255 | p->mark = mark; |
| 4256 | } |
| 4257 | res = NULL; |
| 4258 | done: |
| 4259 | return res; |
| 4260 | } |
| 4261 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4262 | // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4263 | static NameDefaultPair* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4264 | param_with_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4265 | { |
| 4266 | if (p->error_indicator) { |
| 4267 | return NULL; |
| 4268 | } |
| 4269 | NameDefaultPair* res = NULL; |
| 4270 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4271 | { // param default ',' TYPE_COMMENT? |
| 4272 | arg_ty a; |
| 4273 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4274 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4275 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4276 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4277 | (a = param_rule(p)) // param |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4278 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4279 | (c = default_rule(p)) // default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4280 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4281 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4282 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4283 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4284 | ) |
| 4285 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4286 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4287 | if (res == NULL && PyErr_Occurred()) { |
| 4288 | p->error_indicator = 1; |
| 4289 | return NULL; |
| 4290 | } |
| 4291 | goto done; |
| 4292 | } |
| 4293 | p->mark = mark; |
| 4294 | } |
| 4295 | { // param default TYPE_COMMENT? &')' |
| 4296 | arg_ty a; |
| 4297 | expr_ty c; |
| 4298 | void *tc; |
| 4299 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4300 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4301 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4302 | (c = default_rule(p)) // default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4303 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4304 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4305 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4306 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4307 | ) |
| 4308 | { |
| 4309 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4310 | if (res == NULL && PyErr_Occurred()) { |
| 4311 | p->error_indicator = 1; |
| 4312 | return NULL; |
| 4313 | } |
| 4314 | goto done; |
| 4315 | } |
| 4316 | p->mark = mark; |
| 4317 | } |
| 4318 | res = NULL; |
| 4319 | done: |
| 4320 | return res; |
| 4321 | } |
| 4322 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4323 | // param_maybe_default: |
| 4324 | // | param default? ',' TYPE_COMMENT? |
| 4325 | // | param default? TYPE_COMMENT? &')' |
| 4326 | static NameDefaultPair* |
| 4327 | param_maybe_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4328 | { |
| 4329 | if (p->error_indicator) { |
| 4330 | return NULL; |
| 4331 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4332 | NameDefaultPair* res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4333 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4334 | { // param default? ',' TYPE_COMMENT? |
| 4335 | arg_ty a; |
| 4336 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4337 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4338 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4339 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4340 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4341 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4342 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4343 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4344 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4345 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4346 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4347 | ) |
| 4348 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4349 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4350 | if (res == NULL && PyErr_Occurred()) { |
| 4351 | p->error_indicator = 1; |
| 4352 | return NULL; |
| 4353 | } |
| 4354 | goto done; |
| 4355 | } |
| 4356 | p->mark = mark; |
| 4357 | } |
| 4358 | { // param default? TYPE_COMMENT? &')' |
| 4359 | arg_ty a; |
| 4360 | void *c; |
| 4361 | void *tc; |
| 4362 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4363 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4364 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4365 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4366 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4367 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4368 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4369 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4370 | ) |
| 4371 | { |
| 4372 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4373 | if (res == NULL && PyErr_Occurred()) { |
| 4374 | p->error_indicator = 1; |
| 4375 | return NULL; |
| 4376 | } |
| 4377 | goto done; |
| 4378 | } |
| 4379 | p->mark = mark; |
| 4380 | } |
| 4381 | res = NULL; |
| 4382 | done: |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4383 | return res; |
| 4384 | } |
| 4385 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4386 | // param: NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4387 | static arg_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4388 | param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4389 | { |
| 4390 | if (p->error_indicator) { |
| 4391 | return NULL; |
| 4392 | } |
| 4393 | arg_ty res = NULL; |
| 4394 | int mark = p->mark; |
| 4395 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4396 | p->error_indicator = 1; |
| 4397 | return NULL; |
| 4398 | } |
| 4399 | int start_lineno = p->tokens[mark]->lineno; |
| 4400 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4401 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4402 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4403 | { // NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4404 | expr_ty a; |
| 4405 | void *b; |
| 4406 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4407 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4408 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4409 | (b = annotation_rule(p), 1) // annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4410 | ) |
| 4411 | { |
| 4412 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4413 | if (token == NULL) { |
| 4414 | return NULL; |
| 4415 | } |
| 4416 | int end_lineno = token->end_lineno; |
| 4417 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4418 | int end_col_offset = token->end_col_offset; |
| 4419 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4420 | res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); |
| 4421 | if (res == NULL && PyErr_Occurred()) { |
| 4422 | p->error_indicator = 1; |
| 4423 | return NULL; |
| 4424 | } |
| 4425 | goto done; |
| 4426 | } |
| 4427 | p->mark = mark; |
| 4428 | } |
| 4429 | res = NULL; |
| 4430 | done: |
| 4431 | return res; |
| 4432 | } |
| 4433 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4434 | // annotation: ':' expression |
| 4435 | static expr_ty |
| 4436 | annotation_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4437 | { |
| 4438 | if (p->error_indicator) { |
| 4439 | return NULL; |
| 4440 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4441 | expr_ty res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4442 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4443 | { // ':' expression |
| 4444 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4445 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4446 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4447 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4448 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4449 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4450 | ) |
| 4451 | { |
| 4452 | res = a; |
| 4453 | if (res == NULL && PyErr_Occurred()) { |
| 4454 | p->error_indicator = 1; |
| 4455 | return NULL; |
| 4456 | } |
| 4457 | goto done; |
| 4458 | } |
| 4459 | p->mark = mark; |
| 4460 | } |
| 4461 | res = NULL; |
| 4462 | done: |
| 4463 | return res; |
| 4464 | } |
| 4465 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4466 | // default: '=' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4467 | static expr_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4468 | default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4469 | { |
| 4470 | if (p->error_indicator) { |
| 4471 | return NULL; |
| 4472 | } |
| 4473 | expr_ty res = NULL; |
| 4474 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4475 | { // '=' expression |
| 4476 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4477 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4478 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4479 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4480 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4481 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4482 | ) |
| 4483 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4484 | res = a; |
| 4485 | if (res == NULL && PyErr_Occurred()) { |
| 4486 | p->error_indicator = 1; |
| 4487 | return NULL; |
| 4488 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4489 | goto done; |
| 4490 | } |
| 4491 | p->mark = mark; |
| 4492 | } |
| 4493 | res = NULL; |
| 4494 | done: |
| 4495 | return res; |
| 4496 | } |
| 4497 | |
| 4498 | // decorators: (('@' named_expression NEWLINE))+ |
| 4499 | static asdl_seq* |
| 4500 | decorators_rule(Parser *p) |
| 4501 | { |
| 4502 | if (p->error_indicator) { |
| 4503 | return NULL; |
| 4504 | } |
| 4505 | asdl_seq* res = NULL; |
| 4506 | int mark = p->mark; |
| 4507 | { // (('@' named_expression NEWLINE))+ |
| 4508 | asdl_seq * a; |
| 4509 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4510 | (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4511 | ) |
| 4512 | { |
| 4513 | res = a; |
| 4514 | if (res == NULL && PyErr_Occurred()) { |
| 4515 | p->error_indicator = 1; |
| 4516 | return NULL; |
| 4517 | } |
| 4518 | goto done; |
| 4519 | } |
| 4520 | p->mark = mark; |
| 4521 | } |
| 4522 | res = NULL; |
| 4523 | done: |
| 4524 | return res; |
| 4525 | } |
| 4526 | |
| 4527 | // class_def: decorators class_def_raw | class_def_raw |
| 4528 | static stmt_ty |
| 4529 | class_def_rule(Parser *p) |
| 4530 | { |
| 4531 | if (p->error_indicator) { |
| 4532 | return NULL; |
| 4533 | } |
| 4534 | stmt_ty res = NULL; |
| 4535 | int mark = p->mark; |
| 4536 | { // decorators class_def_raw |
| 4537 | asdl_seq* a; |
| 4538 | stmt_ty b; |
| 4539 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4540 | (a = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4541 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4542 | (b = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4543 | ) |
| 4544 | { |
| 4545 | res = _PyPegen_class_def_decorators ( p , a , b ); |
| 4546 | if (res == NULL && PyErr_Occurred()) { |
| 4547 | p->error_indicator = 1; |
| 4548 | return NULL; |
| 4549 | } |
| 4550 | goto done; |
| 4551 | } |
| 4552 | p->mark = mark; |
| 4553 | } |
| 4554 | { // class_def_raw |
| 4555 | stmt_ty class_def_raw_var; |
| 4556 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4557 | (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4558 | ) |
| 4559 | { |
| 4560 | res = class_def_raw_var; |
| 4561 | goto done; |
| 4562 | } |
| 4563 | p->mark = mark; |
| 4564 | } |
| 4565 | res = NULL; |
| 4566 | done: |
| 4567 | return res; |
| 4568 | } |
| 4569 | |
| 4570 | // class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block |
| 4571 | static stmt_ty |
| 4572 | class_def_raw_rule(Parser *p) |
| 4573 | { |
| 4574 | if (p->error_indicator) { |
| 4575 | return NULL; |
| 4576 | } |
| 4577 | stmt_ty res = NULL; |
| 4578 | int mark = p->mark; |
| 4579 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4580 | p->error_indicator = 1; |
| 4581 | return NULL; |
| 4582 | } |
| 4583 | int start_lineno = p->tokens[mark]->lineno; |
| 4584 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4585 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4586 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4587 | { // 'class' NAME ['(' arguments? ')'] ':' block |
| 4588 | expr_ty a; |
| 4589 | void *b; |
| 4590 | asdl_seq* c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4591 | Token * keyword; |
| 4592 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4593 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4594 | (keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4595 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4596 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4597 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4598 | (b = _tmp_68_rule(p), 1) // ['(' arguments? ')'] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4599 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4600 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4601 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4602 | (c = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4603 | ) |
| 4604 | { |
| 4605 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4606 | if (token == NULL) { |
| 4607 | return NULL; |
| 4608 | } |
| 4609 | int end_lineno = token->end_lineno; |
| 4610 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4611 | int end_col_offset = token->end_col_offset; |
| 4612 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4613 | 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 ); |
| 4614 | if (res == NULL && PyErr_Occurred()) { |
| 4615 | p->error_indicator = 1; |
| 4616 | return NULL; |
| 4617 | } |
| 4618 | goto done; |
| 4619 | } |
| 4620 | p->mark = mark; |
| 4621 | } |
| 4622 | res = NULL; |
| 4623 | done: |
| 4624 | return res; |
| 4625 | } |
| 4626 | |
| 4627 | // block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block |
| 4628 | static asdl_seq* |
| 4629 | block_rule(Parser *p) |
| 4630 | { |
| 4631 | if (p->error_indicator) { |
| 4632 | return NULL; |
| 4633 | } |
| 4634 | asdl_seq* res = NULL; |
| 4635 | if (_PyPegen_is_memoized(p, block_type, &res)) |
| 4636 | return res; |
| 4637 | int mark = p->mark; |
| 4638 | { // NEWLINE INDENT statements DEDENT |
| 4639 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4640 | Token * dedent_var; |
| 4641 | Token * indent_var; |
| 4642 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4643 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4644 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4645 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4646 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4647 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4648 | (a = statements_rule(p)) // statements |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4649 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4650 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4651 | ) |
| 4652 | { |
| 4653 | res = a; |
| 4654 | if (res == NULL && PyErr_Occurred()) { |
| 4655 | p->error_indicator = 1; |
| 4656 | return NULL; |
| 4657 | } |
| 4658 | goto done; |
| 4659 | } |
| 4660 | p->mark = mark; |
| 4661 | } |
| 4662 | { // simple_stmt |
| 4663 | asdl_seq* simple_stmt_var; |
| 4664 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4665 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4666 | ) |
| 4667 | { |
| 4668 | res = simple_stmt_var; |
| 4669 | goto done; |
| 4670 | } |
| 4671 | p->mark = mark; |
| 4672 | } |
| 4673 | { // invalid_block |
| 4674 | void *invalid_block_var; |
| 4675 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4676 | (invalid_block_var = invalid_block_rule(p)) // invalid_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4677 | ) |
| 4678 | { |
| 4679 | res = invalid_block_var; |
| 4680 | goto done; |
| 4681 | } |
| 4682 | p->mark = mark; |
| 4683 | } |
| 4684 | res = NULL; |
| 4685 | done: |
| 4686 | _PyPegen_insert_memo(p, mark, block_type, res); |
| 4687 | return res; |
| 4688 | } |
| 4689 | |
| 4690 | // expressions_list: ','.star_expression+ ','? |
| 4691 | static asdl_seq* |
| 4692 | expressions_list_rule(Parser *p) |
| 4693 | { |
| 4694 | if (p->error_indicator) { |
| 4695 | return NULL; |
| 4696 | } |
| 4697 | asdl_seq* res = NULL; |
| 4698 | int mark = p->mark; |
| 4699 | { // ','.star_expression+ ','? |
| 4700 | asdl_seq * a; |
| 4701 | void *opt_var; |
| 4702 | UNUSED(opt_var); // Silence compiler warnings |
| 4703 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4704 | (a = _gather_69_rule(p)) // ','.star_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4705 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4706 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4707 | ) |
| 4708 | { |
| 4709 | res = a; |
| 4710 | if (res == NULL && PyErr_Occurred()) { |
| 4711 | p->error_indicator = 1; |
| 4712 | return NULL; |
| 4713 | } |
| 4714 | goto done; |
| 4715 | } |
| 4716 | p->mark = mark; |
| 4717 | } |
| 4718 | res = NULL; |
| 4719 | done: |
| 4720 | return res; |
| 4721 | } |
| 4722 | |
| 4723 | // star_expressions: |
| 4724 | // | star_expression ((',' star_expression))+ ','? |
| 4725 | // | star_expression ',' |
| 4726 | // | star_expression |
| 4727 | static expr_ty |
| 4728 | star_expressions_rule(Parser *p) |
| 4729 | { |
| 4730 | if (p->error_indicator) { |
| 4731 | return NULL; |
| 4732 | } |
| 4733 | expr_ty res = NULL; |
| 4734 | int mark = p->mark; |
| 4735 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4736 | p->error_indicator = 1; |
| 4737 | return NULL; |
| 4738 | } |
| 4739 | int start_lineno = p->tokens[mark]->lineno; |
| 4740 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4741 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4742 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4743 | { // star_expression ((',' star_expression))+ ','? |
| 4744 | expr_ty a; |
| 4745 | asdl_seq * b; |
| 4746 | void *opt_var; |
| 4747 | UNUSED(opt_var); // Silence compiler warnings |
| 4748 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4749 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4750 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4751 | (b = _loop1_71_rule(p)) // ((',' star_expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4752 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4753 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4754 | ) |
| 4755 | { |
| 4756 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4757 | if (token == NULL) { |
| 4758 | return NULL; |
| 4759 | } |
| 4760 | int end_lineno = token->end_lineno; |
| 4761 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4762 | int end_col_offset = token->end_col_offset; |
| 4763 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4764 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 4765 | if (res == NULL && PyErr_Occurred()) { |
| 4766 | p->error_indicator = 1; |
| 4767 | return NULL; |
| 4768 | } |
| 4769 | goto done; |
| 4770 | } |
| 4771 | p->mark = mark; |
| 4772 | } |
| 4773 | { // star_expression ',' |
| 4774 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4775 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4776 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4777 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4778 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4779 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4780 | ) |
| 4781 | { |
| 4782 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4783 | if (token == NULL) { |
| 4784 | return NULL; |
| 4785 | } |
| 4786 | int end_lineno = token->end_lineno; |
| 4787 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4788 | int end_col_offset = token->end_col_offset; |
| 4789 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4790 | res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 4791 | if (res == NULL && PyErr_Occurred()) { |
| 4792 | p->error_indicator = 1; |
| 4793 | return NULL; |
| 4794 | } |
| 4795 | goto done; |
| 4796 | } |
| 4797 | p->mark = mark; |
| 4798 | } |
| 4799 | { // star_expression |
| 4800 | expr_ty star_expression_var; |
| 4801 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4802 | (star_expression_var = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4803 | ) |
| 4804 | { |
| 4805 | res = star_expression_var; |
| 4806 | goto done; |
| 4807 | } |
| 4808 | p->mark = mark; |
| 4809 | } |
| 4810 | res = NULL; |
| 4811 | done: |
| 4812 | return res; |
| 4813 | } |
| 4814 | |
| 4815 | // star_expression: '*' bitwise_or | expression |
| 4816 | static expr_ty |
| 4817 | star_expression_rule(Parser *p) |
| 4818 | { |
| 4819 | if (p->error_indicator) { |
| 4820 | return NULL; |
| 4821 | } |
| 4822 | expr_ty res = NULL; |
| 4823 | if (_PyPegen_is_memoized(p, star_expression_type, &res)) |
| 4824 | return res; |
| 4825 | int mark = p->mark; |
| 4826 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4827 | p->error_indicator = 1; |
| 4828 | return NULL; |
| 4829 | } |
| 4830 | int start_lineno = p->tokens[mark]->lineno; |
| 4831 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4832 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4833 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4834 | { // '*' bitwise_or |
| 4835 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4836 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4837 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4838 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4839 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4840 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4841 | ) |
| 4842 | { |
| 4843 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4844 | if (token == NULL) { |
| 4845 | return NULL; |
| 4846 | } |
| 4847 | int end_lineno = token->end_lineno; |
| 4848 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4849 | int end_col_offset = token->end_col_offset; |
| 4850 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4851 | res = _Py_Starred ( a , Load , EXTRA ); |
| 4852 | if (res == NULL && PyErr_Occurred()) { |
| 4853 | p->error_indicator = 1; |
| 4854 | return NULL; |
| 4855 | } |
| 4856 | goto done; |
| 4857 | } |
| 4858 | p->mark = mark; |
| 4859 | } |
| 4860 | { // expression |
| 4861 | expr_ty expression_var; |
| 4862 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4863 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4864 | ) |
| 4865 | { |
| 4866 | res = expression_var; |
| 4867 | goto done; |
| 4868 | } |
| 4869 | p->mark = mark; |
| 4870 | } |
| 4871 | res = NULL; |
| 4872 | done: |
| 4873 | _PyPegen_insert_memo(p, mark, star_expression_type, res); |
| 4874 | return res; |
| 4875 | } |
| 4876 | |
| 4877 | // star_named_expressions: ','.star_named_expression+ ','? |
| 4878 | static asdl_seq* |
| 4879 | star_named_expressions_rule(Parser *p) |
| 4880 | { |
| 4881 | if (p->error_indicator) { |
| 4882 | return NULL; |
| 4883 | } |
| 4884 | asdl_seq* res = NULL; |
| 4885 | int mark = p->mark; |
| 4886 | { // ','.star_named_expression+ ','? |
| 4887 | asdl_seq * a; |
| 4888 | void *opt_var; |
| 4889 | UNUSED(opt_var); // Silence compiler warnings |
| 4890 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4891 | (a = _gather_72_rule(p)) // ','.star_named_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4892 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4893 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4894 | ) |
| 4895 | { |
| 4896 | res = a; |
| 4897 | if (res == NULL && PyErr_Occurred()) { |
| 4898 | p->error_indicator = 1; |
| 4899 | return NULL; |
| 4900 | } |
| 4901 | goto done; |
| 4902 | } |
| 4903 | p->mark = mark; |
| 4904 | } |
| 4905 | res = NULL; |
| 4906 | done: |
| 4907 | return res; |
| 4908 | } |
| 4909 | |
| 4910 | // star_named_expression: '*' bitwise_or | named_expression |
| 4911 | static expr_ty |
| 4912 | star_named_expression_rule(Parser *p) |
| 4913 | { |
| 4914 | if (p->error_indicator) { |
| 4915 | return NULL; |
| 4916 | } |
| 4917 | expr_ty res = NULL; |
| 4918 | int mark = p->mark; |
| 4919 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4920 | p->error_indicator = 1; |
| 4921 | return NULL; |
| 4922 | } |
| 4923 | int start_lineno = p->tokens[mark]->lineno; |
| 4924 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4925 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4926 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4927 | { // '*' bitwise_or |
| 4928 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4929 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4930 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4931 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4932 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4933 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4934 | ) |
| 4935 | { |
| 4936 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4937 | if (token == NULL) { |
| 4938 | return NULL; |
| 4939 | } |
| 4940 | int end_lineno = token->end_lineno; |
| 4941 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4942 | int end_col_offset = token->end_col_offset; |
| 4943 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4944 | res = _Py_Starred ( a , Load , EXTRA ); |
| 4945 | if (res == NULL && PyErr_Occurred()) { |
| 4946 | p->error_indicator = 1; |
| 4947 | return NULL; |
| 4948 | } |
| 4949 | goto done; |
| 4950 | } |
| 4951 | p->mark = mark; |
| 4952 | } |
| 4953 | { // named_expression |
| 4954 | expr_ty named_expression_var; |
| 4955 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4956 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4957 | ) |
| 4958 | { |
| 4959 | res = named_expression_var; |
| 4960 | goto done; |
| 4961 | } |
| 4962 | p->mark = mark; |
| 4963 | } |
| 4964 | res = NULL; |
| 4965 | done: |
| 4966 | return res; |
| 4967 | } |
| 4968 | |
| 4969 | // named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression |
| 4970 | static expr_ty |
| 4971 | named_expression_rule(Parser *p) |
| 4972 | { |
| 4973 | if (p->error_indicator) { |
| 4974 | return NULL; |
| 4975 | } |
| 4976 | expr_ty res = NULL; |
| 4977 | int mark = p->mark; |
| 4978 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4979 | p->error_indicator = 1; |
| 4980 | return NULL; |
| 4981 | } |
| 4982 | int start_lineno = p->tokens[mark]->lineno; |
| 4983 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4984 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4985 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4986 | { // NAME ':=' expression |
| 4987 | expr_ty a; |
| 4988 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4989 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4990 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4991 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4992 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4993 | (literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4994 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 4995 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4996 | ) |
| 4997 | { |
| 4998 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4999 | if (token == NULL) { |
| 5000 | return NULL; |
| 5001 | } |
| 5002 | int end_lineno = token->end_lineno; |
| 5003 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5004 | int end_col_offset = token->end_col_offset; |
| 5005 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5006 | res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); |
| 5007 | if (res == NULL && PyErr_Occurred()) { |
| 5008 | p->error_indicator = 1; |
| 5009 | return NULL; |
| 5010 | } |
| 5011 | goto done; |
| 5012 | } |
| 5013 | p->mark = mark; |
| 5014 | } |
| 5015 | { // expression !':=' |
| 5016 | expr_ty expression_var; |
| 5017 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5018 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5019 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5020 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5021 | ) |
| 5022 | { |
| 5023 | res = expression_var; |
| 5024 | goto done; |
| 5025 | } |
| 5026 | p->mark = mark; |
| 5027 | } |
| 5028 | { // invalid_named_expression |
| 5029 | void *invalid_named_expression_var; |
| 5030 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5031 | (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5032 | ) |
| 5033 | { |
| 5034 | res = invalid_named_expression_var; |
| 5035 | goto done; |
| 5036 | } |
| 5037 | p->mark = mark; |
| 5038 | } |
| 5039 | res = NULL; |
| 5040 | done: |
| 5041 | return res; |
| 5042 | } |
| 5043 | |
| 5044 | // annotated_rhs: yield_expr | star_expressions |
| 5045 | static expr_ty |
| 5046 | annotated_rhs_rule(Parser *p) |
| 5047 | { |
| 5048 | if (p->error_indicator) { |
| 5049 | return NULL; |
| 5050 | } |
| 5051 | expr_ty res = NULL; |
| 5052 | int mark = p->mark; |
| 5053 | { // yield_expr |
| 5054 | expr_ty yield_expr_var; |
| 5055 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5056 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5057 | ) |
| 5058 | { |
| 5059 | res = yield_expr_var; |
| 5060 | goto done; |
| 5061 | } |
| 5062 | p->mark = mark; |
| 5063 | } |
| 5064 | { // star_expressions |
| 5065 | expr_ty star_expressions_var; |
| 5066 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5067 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5068 | ) |
| 5069 | { |
| 5070 | res = star_expressions_var; |
| 5071 | goto done; |
| 5072 | } |
| 5073 | p->mark = mark; |
| 5074 | } |
| 5075 | res = NULL; |
| 5076 | done: |
| 5077 | return res; |
| 5078 | } |
| 5079 | |
| 5080 | // expressions: expression ((',' expression))+ ','? | expression ',' | expression |
| 5081 | static expr_ty |
| 5082 | expressions_rule(Parser *p) |
| 5083 | { |
| 5084 | if (p->error_indicator) { |
| 5085 | return NULL; |
| 5086 | } |
| 5087 | expr_ty res = NULL; |
| 5088 | int mark = p->mark; |
| 5089 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5090 | p->error_indicator = 1; |
| 5091 | return NULL; |
| 5092 | } |
| 5093 | int start_lineno = p->tokens[mark]->lineno; |
| 5094 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5095 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5096 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5097 | { // expression ((',' expression))+ ','? |
| 5098 | expr_ty a; |
| 5099 | asdl_seq * b; |
| 5100 | void *opt_var; |
| 5101 | UNUSED(opt_var); // Silence compiler warnings |
| 5102 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5103 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5104 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5105 | (b = _loop1_74_rule(p)) // ((',' expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5106 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5107 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5108 | ) |
| 5109 | { |
| 5110 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5111 | if (token == NULL) { |
| 5112 | return NULL; |
| 5113 | } |
| 5114 | int end_lineno = token->end_lineno; |
| 5115 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5116 | int end_col_offset = token->end_col_offset; |
| 5117 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5118 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 5119 | if (res == NULL && PyErr_Occurred()) { |
| 5120 | p->error_indicator = 1; |
| 5121 | return NULL; |
| 5122 | } |
| 5123 | goto done; |
| 5124 | } |
| 5125 | p->mark = mark; |
| 5126 | } |
| 5127 | { // expression ',' |
| 5128 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5129 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5130 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5131 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5132 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5133 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5134 | ) |
| 5135 | { |
| 5136 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5137 | if (token == NULL) { |
| 5138 | return NULL; |
| 5139 | } |
| 5140 | int end_lineno = token->end_lineno; |
| 5141 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5142 | int end_col_offset = token->end_col_offset; |
| 5143 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5144 | res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 5145 | if (res == NULL && PyErr_Occurred()) { |
| 5146 | p->error_indicator = 1; |
| 5147 | return NULL; |
| 5148 | } |
| 5149 | goto done; |
| 5150 | } |
| 5151 | p->mark = mark; |
| 5152 | } |
| 5153 | { // expression |
| 5154 | expr_ty expression_var; |
| 5155 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5156 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5157 | ) |
| 5158 | { |
| 5159 | res = expression_var; |
| 5160 | goto done; |
| 5161 | } |
| 5162 | p->mark = mark; |
| 5163 | } |
| 5164 | res = NULL; |
| 5165 | done: |
| 5166 | return res; |
| 5167 | } |
| 5168 | |
| 5169 | // expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef |
| 5170 | static expr_ty |
| 5171 | expression_rule(Parser *p) |
| 5172 | { |
| 5173 | if (p->error_indicator) { |
| 5174 | return NULL; |
| 5175 | } |
| 5176 | expr_ty res = NULL; |
| 5177 | if (_PyPegen_is_memoized(p, expression_type, &res)) |
| 5178 | return res; |
| 5179 | int mark = p->mark; |
| 5180 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5181 | p->error_indicator = 1; |
| 5182 | return NULL; |
| 5183 | } |
| 5184 | int start_lineno = p->tokens[mark]->lineno; |
| 5185 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5186 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5187 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5188 | { // disjunction 'if' disjunction 'else' expression |
| 5189 | expr_ty a; |
| 5190 | expr_ty b; |
| 5191 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5192 | Token * keyword; |
| 5193 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5194 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5195 | (a = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5196 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5197 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5198 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5199 | (b = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5200 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5201 | (keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5202 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5203 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5204 | ) |
| 5205 | { |
| 5206 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5207 | if (token == NULL) { |
| 5208 | return NULL; |
| 5209 | } |
| 5210 | int end_lineno = token->end_lineno; |
| 5211 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5212 | int end_col_offset = token->end_col_offset; |
| 5213 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5214 | res = _Py_IfExp ( b , a , c , EXTRA ); |
| 5215 | if (res == NULL && PyErr_Occurred()) { |
| 5216 | p->error_indicator = 1; |
| 5217 | return NULL; |
| 5218 | } |
| 5219 | goto done; |
| 5220 | } |
| 5221 | p->mark = mark; |
| 5222 | } |
| 5223 | { // disjunction |
| 5224 | expr_ty disjunction_var; |
| 5225 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5226 | (disjunction_var = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5227 | ) |
| 5228 | { |
| 5229 | res = disjunction_var; |
| 5230 | goto done; |
| 5231 | } |
| 5232 | p->mark = mark; |
| 5233 | } |
| 5234 | { // lambdef |
| 5235 | expr_ty lambdef_var; |
| 5236 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5237 | (lambdef_var = lambdef_rule(p)) // lambdef |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5238 | ) |
| 5239 | { |
| 5240 | res = lambdef_var; |
| 5241 | goto done; |
| 5242 | } |
| 5243 | p->mark = mark; |
| 5244 | } |
| 5245 | res = NULL; |
| 5246 | done: |
| 5247 | _PyPegen_insert_memo(p, mark, expression_type, res); |
| 5248 | return res; |
| 5249 | } |
| 5250 | |
| 5251 | // lambdef: 'lambda' lambda_parameters? ':' expression |
| 5252 | static expr_ty |
| 5253 | lambdef_rule(Parser *p) |
| 5254 | { |
| 5255 | if (p->error_indicator) { |
| 5256 | return NULL; |
| 5257 | } |
| 5258 | expr_ty res = NULL; |
| 5259 | int mark = p->mark; |
| 5260 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5261 | p->error_indicator = 1; |
| 5262 | return NULL; |
| 5263 | } |
| 5264 | int start_lineno = p->tokens[mark]->lineno; |
| 5265 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5266 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5267 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5268 | { // 'lambda' lambda_parameters? ':' expression |
| 5269 | void *a; |
| 5270 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5271 | Token * keyword; |
| 5272 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5273 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5274 | (keyword = _PyPegen_expect_token(p, 524)) // token='lambda' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5275 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5276 | (a = lambda_parameters_rule(p), 1) // lambda_parameters? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5277 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5278 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5279 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5280 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5281 | ) |
| 5282 | { |
| 5283 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5284 | if (token == NULL) { |
| 5285 | return NULL; |
| 5286 | } |
| 5287 | int end_lineno = token->end_lineno; |
| 5288 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5289 | int end_col_offset = token->end_col_offset; |
| 5290 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5291 | res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); |
| 5292 | if (res == NULL && PyErr_Occurred()) { |
| 5293 | p->error_indicator = 1; |
| 5294 | return NULL; |
| 5295 | } |
| 5296 | goto done; |
| 5297 | } |
| 5298 | p->mark = mark; |
| 5299 | } |
| 5300 | res = NULL; |
| 5301 | done: |
| 5302 | return res; |
| 5303 | } |
| 5304 | |
| 5305 | // lambda_parameters: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5306 | // | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 5307 | // | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 5308 | // | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5309 | // | lambda_param_with_default+ lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5310 | // | lambda_star_etc |
| 5311 | static arguments_ty |
| 5312 | lambda_parameters_rule(Parser *p) |
| 5313 | { |
| 5314 | if (p->error_indicator) { |
| 5315 | return NULL; |
| 5316 | } |
| 5317 | arguments_ty res = NULL; |
| 5318 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5319 | { // 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] | 5320 | asdl_seq* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5321 | asdl_seq * b; |
| 5322 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5323 | void *d; |
| 5324 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5325 | (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5326 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5327 | (b = _loop0_75_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5328 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5329 | (c = _loop0_76_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5330 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5331 | (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5332 | ) |
| 5333 | { |
| 5334 | res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 5335 | if (res == NULL && PyErr_Occurred()) { |
| 5336 | p->error_indicator = 1; |
| 5337 | return NULL; |
| 5338 | } |
| 5339 | goto done; |
| 5340 | } |
| 5341 | p->mark = mark; |
| 5342 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5343 | { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5344 | SlashWithDefault* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5345 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5346 | void *c; |
| 5347 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5348 | (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5349 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5350 | (b = _loop0_77_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5351 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5352 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5353 | ) |
| 5354 | { |
| 5355 | res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 5356 | if (res == NULL && PyErr_Occurred()) { |
| 5357 | p->error_indicator = 1; |
| 5358 | return NULL; |
| 5359 | } |
| 5360 | goto done; |
| 5361 | } |
| 5362 | p->mark = mark; |
| 5363 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5364 | { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5365 | asdl_seq * a; |
| 5366 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5367 | void *c; |
| 5368 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5369 | (a = _loop1_78_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5370 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5371 | (b = _loop0_79_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5372 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5373 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5374 | ) |
| 5375 | { |
| 5376 | res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 5377 | if (res == NULL && PyErr_Occurred()) { |
| 5378 | p->error_indicator = 1; |
| 5379 | return NULL; |
| 5380 | } |
| 5381 | goto done; |
| 5382 | } |
| 5383 | p->mark = mark; |
| 5384 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5385 | { // lambda_param_with_default+ lambda_star_etc? |
| 5386 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5387 | void *b; |
| 5388 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5389 | (a = _loop1_80_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5390 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5391 | (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5392 | ) |
| 5393 | { |
| 5394 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 5395 | if (res == NULL && PyErr_Occurred()) { |
| 5396 | p->error_indicator = 1; |
| 5397 | return NULL; |
| 5398 | } |
| 5399 | goto done; |
| 5400 | } |
| 5401 | p->mark = mark; |
| 5402 | } |
| 5403 | { // lambda_star_etc |
| 5404 | StarEtc* a; |
| 5405 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5406 | (a = lambda_star_etc_rule(p)) // lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5407 | ) |
| 5408 | { |
| 5409 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 5410 | if (res == NULL && PyErr_Occurred()) { |
| 5411 | p->error_indicator = 1; |
| 5412 | return NULL; |
| 5413 | } |
| 5414 | goto done; |
| 5415 | } |
| 5416 | p->mark = mark; |
| 5417 | } |
| 5418 | res = NULL; |
| 5419 | done: |
| 5420 | return res; |
| 5421 | } |
| 5422 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5423 | // lambda_slash_no_default: |
| 5424 | // | lambda_param_no_default+ '/' ',' |
| 5425 | // | lambda_param_no_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5426 | static asdl_seq* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5427 | lambda_slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5428 | { |
| 5429 | if (p->error_indicator) { |
| 5430 | return NULL; |
| 5431 | } |
| 5432 | asdl_seq* res = NULL; |
| 5433 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5434 | { // lambda_param_no_default+ '/' ',' |
| 5435 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5436 | Token * literal; |
| 5437 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5438 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5439 | (a = _loop1_81_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5440 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5441 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5442 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5443 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5444 | ) |
| 5445 | { |
| 5446 | res = a; |
| 5447 | if (res == NULL && PyErr_Occurred()) { |
| 5448 | p->error_indicator = 1; |
| 5449 | return NULL; |
| 5450 | } |
| 5451 | goto done; |
| 5452 | } |
| 5453 | p->mark = mark; |
| 5454 | } |
| 5455 | { // lambda_param_no_default+ '/' &':' |
| 5456 | asdl_seq * a; |
| 5457 | Token * literal; |
| 5458 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5459 | (a = _loop1_82_rule(p)) // lambda_param_no_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5460 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5461 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5462 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5463 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5464 | ) |
| 5465 | { |
| 5466 | res = a; |
| 5467 | if (res == NULL && PyErr_Occurred()) { |
| 5468 | p->error_indicator = 1; |
| 5469 | return NULL; |
| 5470 | } |
| 5471 | goto done; |
| 5472 | } |
| 5473 | p->mark = mark; |
| 5474 | } |
| 5475 | res = NULL; |
| 5476 | done: |
| 5477 | return res; |
| 5478 | } |
| 5479 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5480 | // lambda_slash_with_default: |
| 5481 | // | lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 5482 | // | lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5483 | static SlashWithDefault* |
| 5484 | lambda_slash_with_default_rule(Parser *p) |
| 5485 | { |
| 5486 | if (p->error_indicator) { |
| 5487 | return NULL; |
| 5488 | } |
| 5489 | SlashWithDefault* res = NULL; |
| 5490 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5491 | { // lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 5492 | asdl_seq * a; |
| 5493 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5494 | Token * literal; |
| 5495 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5496 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5497 | (a = _loop0_83_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5498 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5499 | (b = _loop1_84_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5500 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5501 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5502 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5503 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5504 | ) |
| 5505 | { |
| 5506 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 5507 | if (res == NULL && PyErr_Occurred()) { |
| 5508 | p->error_indicator = 1; |
| 5509 | return NULL; |
| 5510 | } |
| 5511 | goto done; |
| 5512 | } |
| 5513 | p->mark = mark; |
| 5514 | } |
| 5515 | { // lambda_param_no_default* lambda_param_with_default+ '/' &':' |
| 5516 | asdl_seq * a; |
| 5517 | asdl_seq * b; |
| 5518 | Token * literal; |
| 5519 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5520 | (a = _loop0_85_rule(p)) // lambda_param_no_default* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5521 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5522 | (b = _loop1_86_rule(p)) // lambda_param_with_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5523 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5524 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5525 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5526 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5527 | ) |
| 5528 | { |
| 5529 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 5530 | if (res == NULL && PyErr_Occurred()) { |
| 5531 | p->error_indicator = 1; |
| 5532 | return NULL; |
| 5533 | } |
| 5534 | goto done; |
| 5535 | } |
| 5536 | p->mark = mark; |
| 5537 | } |
| 5538 | res = NULL; |
| 5539 | done: |
| 5540 | return res; |
| 5541 | } |
| 5542 | |
| 5543 | // lambda_star_etc: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5544 | // | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 5545 | // | '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 5546 | // | lambda_kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5547 | // | invalid_lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5548 | static StarEtc* |
| 5549 | lambda_star_etc_rule(Parser *p) |
| 5550 | { |
| 5551 | if (p->error_indicator) { |
| 5552 | return NULL; |
| 5553 | } |
| 5554 | StarEtc* res = NULL; |
| 5555 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5556 | { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5557 | arg_ty a; |
| 5558 | asdl_seq * b; |
| 5559 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5560 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5561 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5562 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5563 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5564 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5565 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5566 | (b = _loop0_87_rule(p)) // lambda_param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5567 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5568 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5569 | ) |
| 5570 | { |
| 5571 | res = _PyPegen_star_etc ( p , a , b , c ); |
| 5572 | if (res == NULL && PyErr_Occurred()) { |
| 5573 | p->error_indicator = 1; |
| 5574 | return NULL; |
| 5575 | } |
| 5576 | goto done; |
| 5577 | } |
| 5578 | p->mark = mark; |
| 5579 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5580 | { // '*' ',' lambda_param_maybe_default+ lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5581 | asdl_seq * b; |
| 5582 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5583 | Token * literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5584 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5585 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5586 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5587 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5588 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5589 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5590 | (b = _loop1_88_rule(p)) // lambda_param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5591 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5592 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5593 | ) |
| 5594 | { |
| 5595 | res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 5596 | if (res == NULL && PyErr_Occurred()) { |
| 5597 | p->error_indicator = 1; |
| 5598 | return NULL; |
| 5599 | } |
| 5600 | goto done; |
| 5601 | } |
| 5602 | p->mark = mark; |
| 5603 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5604 | { // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5605 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5606 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5607 | (a = lambda_kwds_rule(p)) // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5608 | ) |
| 5609 | { |
| 5610 | res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 5611 | if (res == NULL && PyErr_Occurred()) { |
| 5612 | p->error_indicator = 1; |
| 5613 | return NULL; |
| 5614 | } |
| 5615 | goto done; |
| 5616 | } |
| 5617 | p->mark = mark; |
| 5618 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5619 | { // invalid_lambda_star_etc |
| 5620 | void *invalid_lambda_star_etc_var; |
| 5621 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5622 | (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] | 5623 | ) |
| 5624 | { |
| 5625 | res = invalid_lambda_star_etc_var; |
| 5626 | goto done; |
| 5627 | } |
| 5628 | p->mark = mark; |
| 5629 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5630 | res = NULL; |
| 5631 | done: |
| 5632 | return res; |
| 5633 | } |
| 5634 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5635 | // lambda_kwds: '**' lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5636 | static arg_ty |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5637 | lambda_kwds_rule(Parser *p) |
| 5638 | { |
| 5639 | if (p->error_indicator) { |
| 5640 | return NULL; |
| 5641 | } |
| 5642 | arg_ty res = NULL; |
| 5643 | int mark = p->mark; |
| 5644 | { // '**' lambda_param_no_default |
| 5645 | arg_ty a; |
| 5646 | Token * literal; |
| 5647 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5648 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5649 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5650 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5651 | ) |
| 5652 | { |
| 5653 | res = a; |
| 5654 | if (res == NULL && PyErr_Occurred()) { |
| 5655 | p->error_indicator = 1; |
| 5656 | return NULL; |
| 5657 | } |
| 5658 | goto done; |
| 5659 | } |
| 5660 | p->mark = mark; |
| 5661 | } |
| 5662 | res = NULL; |
| 5663 | done: |
| 5664 | return res; |
| 5665 | } |
| 5666 | |
| 5667 | // lambda_param_no_default: lambda_param ',' | lambda_param &':' |
| 5668 | static arg_ty |
| 5669 | lambda_param_no_default_rule(Parser *p) |
| 5670 | { |
| 5671 | if (p->error_indicator) { |
| 5672 | return NULL; |
| 5673 | } |
| 5674 | arg_ty res = NULL; |
| 5675 | int mark = p->mark; |
| 5676 | { // lambda_param ',' |
| 5677 | arg_ty a; |
| 5678 | Token * literal; |
| 5679 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5680 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5681 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5682 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5683 | ) |
| 5684 | { |
| 5685 | res = a; |
| 5686 | if (res == NULL && PyErr_Occurred()) { |
| 5687 | p->error_indicator = 1; |
| 5688 | return NULL; |
| 5689 | } |
| 5690 | goto done; |
| 5691 | } |
| 5692 | p->mark = mark; |
| 5693 | } |
| 5694 | { // lambda_param &':' |
| 5695 | arg_ty a; |
| 5696 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5697 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5698 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5699 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5700 | ) |
| 5701 | { |
| 5702 | res = a; |
| 5703 | if (res == NULL && PyErr_Occurred()) { |
| 5704 | p->error_indicator = 1; |
| 5705 | return NULL; |
| 5706 | } |
| 5707 | goto done; |
| 5708 | } |
| 5709 | p->mark = mark; |
| 5710 | } |
| 5711 | res = NULL; |
| 5712 | done: |
| 5713 | return res; |
| 5714 | } |
| 5715 | |
| 5716 | // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' |
| 5717 | static NameDefaultPair* |
| 5718 | lambda_param_with_default_rule(Parser *p) |
| 5719 | { |
| 5720 | if (p->error_indicator) { |
| 5721 | return NULL; |
| 5722 | } |
| 5723 | NameDefaultPair* res = NULL; |
| 5724 | int mark = p->mark; |
| 5725 | { // lambda_param default ',' |
| 5726 | arg_ty a; |
| 5727 | expr_ty c; |
| 5728 | Token * literal; |
| 5729 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5730 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5731 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5732 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5733 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5734 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5735 | ) |
| 5736 | { |
| 5737 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5738 | if (res == NULL && PyErr_Occurred()) { |
| 5739 | p->error_indicator = 1; |
| 5740 | return NULL; |
| 5741 | } |
| 5742 | goto done; |
| 5743 | } |
| 5744 | p->mark = mark; |
| 5745 | } |
| 5746 | { // lambda_param default &':' |
| 5747 | arg_ty a; |
| 5748 | expr_ty c; |
| 5749 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5750 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5751 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5752 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5753 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5754 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5755 | ) |
| 5756 | { |
| 5757 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5758 | if (res == NULL && PyErr_Occurred()) { |
| 5759 | p->error_indicator = 1; |
| 5760 | return NULL; |
| 5761 | } |
| 5762 | goto done; |
| 5763 | } |
| 5764 | p->mark = mark; |
| 5765 | } |
| 5766 | res = NULL; |
| 5767 | done: |
| 5768 | return res; |
| 5769 | } |
| 5770 | |
| 5771 | // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' |
| 5772 | static NameDefaultPair* |
| 5773 | lambda_param_maybe_default_rule(Parser *p) |
| 5774 | { |
| 5775 | if (p->error_indicator) { |
| 5776 | return NULL; |
| 5777 | } |
| 5778 | NameDefaultPair* res = NULL; |
| 5779 | int mark = p->mark; |
| 5780 | { // lambda_param default? ',' |
| 5781 | arg_ty a; |
| 5782 | void *c; |
| 5783 | Token * literal; |
| 5784 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5785 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5786 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5787 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5788 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5789 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5790 | ) |
| 5791 | { |
| 5792 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5793 | if (res == NULL && PyErr_Occurred()) { |
| 5794 | p->error_indicator = 1; |
| 5795 | return NULL; |
| 5796 | } |
| 5797 | goto done; |
| 5798 | } |
| 5799 | p->mark = mark; |
| 5800 | } |
| 5801 | { // lambda_param default? &':' |
| 5802 | arg_ty a; |
| 5803 | void *c; |
| 5804 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5805 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5806 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5807 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5808 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5809 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5810 | ) |
| 5811 | { |
| 5812 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5813 | if (res == NULL && PyErr_Occurred()) { |
| 5814 | p->error_indicator = 1; |
| 5815 | return NULL; |
| 5816 | } |
| 5817 | goto done; |
| 5818 | } |
| 5819 | p->mark = mark; |
| 5820 | } |
| 5821 | res = NULL; |
| 5822 | done: |
| 5823 | return res; |
| 5824 | } |
| 5825 | |
| 5826 | // lambda_param: NAME |
| 5827 | static arg_ty |
| 5828 | lambda_param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5829 | { |
| 5830 | if (p->error_indicator) { |
| 5831 | return NULL; |
| 5832 | } |
| 5833 | arg_ty res = NULL; |
| 5834 | int mark = p->mark; |
| 5835 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5836 | p->error_indicator = 1; |
| 5837 | return NULL; |
| 5838 | } |
| 5839 | int start_lineno = p->tokens[mark]->lineno; |
| 5840 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5841 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5842 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5843 | { // NAME |
| 5844 | expr_ty a; |
| 5845 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5846 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5847 | ) |
| 5848 | { |
| 5849 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5850 | if (token == NULL) { |
| 5851 | return NULL; |
| 5852 | } |
| 5853 | int end_lineno = token->end_lineno; |
| 5854 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5855 | int end_col_offset = token->end_col_offset; |
| 5856 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5857 | res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); |
| 5858 | if (res == NULL && PyErr_Occurred()) { |
| 5859 | p->error_indicator = 1; |
| 5860 | return NULL; |
| 5861 | } |
| 5862 | goto done; |
| 5863 | } |
| 5864 | p->mark = mark; |
| 5865 | } |
| 5866 | res = NULL; |
| 5867 | done: |
| 5868 | return res; |
| 5869 | } |
| 5870 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5871 | // disjunction: conjunction (('or' conjunction))+ | conjunction |
| 5872 | static expr_ty |
| 5873 | disjunction_rule(Parser *p) |
| 5874 | { |
| 5875 | if (p->error_indicator) { |
| 5876 | return NULL; |
| 5877 | } |
| 5878 | expr_ty res = NULL; |
| 5879 | if (_PyPegen_is_memoized(p, disjunction_type, &res)) |
| 5880 | return res; |
| 5881 | int mark = p->mark; |
| 5882 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5883 | p->error_indicator = 1; |
| 5884 | return NULL; |
| 5885 | } |
| 5886 | int start_lineno = p->tokens[mark]->lineno; |
| 5887 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5888 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5889 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5890 | { // conjunction (('or' conjunction))+ |
| 5891 | expr_ty a; |
| 5892 | asdl_seq * b; |
| 5893 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5894 | (a = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5895 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5896 | (b = _loop1_89_rule(p)) // (('or' conjunction))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5897 | ) |
| 5898 | { |
| 5899 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5900 | if (token == NULL) { |
| 5901 | return NULL; |
| 5902 | } |
| 5903 | int end_lineno = token->end_lineno; |
| 5904 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5905 | int end_col_offset = token->end_col_offset; |
| 5906 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5907 | res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5908 | if (res == NULL && PyErr_Occurred()) { |
| 5909 | p->error_indicator = 1; |
| 5910 | return NULL; |
| 5911 | } |
| 5912 | goto done; |
| 5913 | } |
| 5914 | p->mark = mark; |
| 5915 | } |
| 5916 | { // conjunction |
| 5917 | expr_ty conjunction_var; |
| 5918 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5919 | (conjunction_var = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5920 | ) |
| 5921 | { |
| 5922 | res = conjunction_var; |
| 5923 | goto done; |
| 5924 | } |
| 5925 | p->mark = mark; |
| 5926 | } |
| 5927 | res = NULL; |
| 5928 | done: |
| 5929 | _PyPegen_insert_memo(p, mark, disjunction_type, res); |
| 5930 | return res; |
| 5931 | } |
| 5932 | |
| 5933 | // conjunction: inversion (('and' inversion))+ | inversion |
| 5934 | static expr_ty |
| 5935 | conjunction_rule(Parser *p) |
| 5936 | { |
| 5937 | if (p->error_indicator) { |
| 5938 | return NULL; |
| 5939 | } |
| 5940 | expr_ty res = NULL; |
| 5941 | if (_PyPegen_is_memoized(p, conjunction_type, &res)) |
| 5942 | return res; |
| 5943 | int mark = p->mark; |
| 5944 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5945 | p->error_indicator = 1; |
| 5946 | return NULL; |
| 5947 | } |
| 5948 | int start_lineno = p->tokens[mark]->lineno; |
| 5949 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5950 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5951 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5952 | { // inversion (('and' inversion))+ |
| 5953 | expr_ty a; |
| 5954 | asdl_seq * b; |
| 5955 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5956 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5957 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5958 | (b = _loop1_90_rule(p)) // (('and' inversion))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5959 | ) |
| 5960 | { |
| 5961 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5962 | if (token == NULL) { |
| 5963 | return NULL; |
| 5964 | } |
| 5965 | int end_lineno = token->end_lineno; |
| 5966 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5967 | int end_col_offset = token->end_col_offset; |
| 5968 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5969 | res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5970 | if (res == NULL && PyErr_Occurred()) { |
| 5971 | p->error_indicator = 1; |
| 5972 | return NULL; |
| 5973 | } |
| 5974 | goto done; |
| 5975 | } |
| 5976 | p->mark = mark; |
| 5977 | } |
| 5978 | { // inversion |
| 5979 | expr_ty inversion_var; |
| 5980 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 5981 | (inversion_var = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5982 | ) |
| 5983 | { |
| 5984 | res = inversion_var; |
| 5985 | goto done; |
| 5986 | } |
| 5987 | p->mark = mark; |
| 5988 | } |
| 5989 | res = NULL; |
| 5990 | done: |
| 5991 | _PyPegen_insert_memo(p, mark, conjunction_type, res); |
| 5992 | return res; |
| 5993 | } |
| 5994 | |
| 5995 | // inversion: 'not' inversion | comparison |
| 5996 | static expr_ty |
| 5997 | inversion_rule(Parser *p) |
| 5998 | { |
| 5999 | if (p->error_indicator) { |
| 6000 | return NULL; |
| 6001 | } |
| 6002 | expr_ty res = NULL; |
| 6003 | if (_PyPegen_is_memoized(p, inversion_type, &res)) |
| 6004 | return res; |
| 6005 | int mark = p->mark; |
| 6006 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6007 | p->error_indicator = 1; |
| 6008 | return NULL; |
| 6009 | } |
| 6010 | int start_lineno = p->tokens[mark]->lineno; |
| 6011 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6012 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6013 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6014 | { // 'not' inversion |
| 6015 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6016 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6017 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6018 | (keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6019 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6020 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6021 | ) |
| 6022 | { |
| 6023 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6024 | if (token == NULL) { |
| 6025 | return NULL; |
| 6026 | } |
| 6027 | int end_lineno = token->end_lineno; |
| 6028 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6029 | int end_col_offset = token->end_col_offset; |
| 6030 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6031 | res = _Py_UnaryOp ( Not , a , EXTRA ); |
| 6032 | if (res == NULL && PyErr_Occurred()) { |
| 6033 | p->error_indicator = 1; |
| 6034 | return NULL; |
| 6035 | } |
| 6036 | goto done; |
| 6037 | } |
| 6038 | p->mark = mark; |
| 6039 | } |
| 6040 | { // comparison |
| 6041 | expr_ty comparison_var; |
| 6042 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6043 | (comparison_var = comparison_rule(p)) // comparison |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6044 | ) |
| 6045 | { |
| 6046 | res = comparison_var; |
| 6047 | goto done; |
| 6048 | } |
| 6049 | p->mark = mark; |
| 6050 | } |
| 6051 | res = NULL; |
| 6052 | done: |
| 6053 | _PyPegen_insert_memo(p, mark, inversion_type, res); |
| 6054 | return res; |
| 6055 | } |
| 6056 | |
| 6057 | // comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or |
| 6058 | static expr_ty |
| 6059 | comparison_rule(Parser *p) |
| 6060 | { |
| 6061 | if (p->error_indicator) { |
| 6062 | return NULL; |
| 6063 | } |
| 6064 | expr_ty res = NULL; |
| 6065 | int mark = p->mark; |
| 6066 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6067 | p->error_indicator = 1; |
| 6068 | return NULL; |
| 6069 | } |
| 6070 | int start_lineno = p->tokens[mark]->lineno; |
| 6071 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6072 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6073 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6074 | { // bitwise_or compare_op_bitwise_or_pair+ |
| 6075 | expr_ty a; |
| 6076 | asdl_seq * b; |
| 6077 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6078 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6079 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6080 | (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6081 | ) |
| 6082 | { |
| 6083 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6084 | if (token == NULL) { |
| 6085 | return NULL; |
| 6086 | } |
| 6087 | int end_lineno = token->end_lineno; |
| 6088 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6089 | int end_col_offset = token->end_col_offset; |
| 6090 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6091 | res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); |
| 6092 | if (res == NULL && PyErr_Occurred()) { |
| 6093 | p->error_indicator = 1; |
| 6094 | return NULL; |
| 6095 | } |
| 6096 | goto done; |
| 6097 | } |
| 6098 | p->mark = mark; |
| 6099 | } |
| 6100 | { // bitwise_or |
| 6101 | expr_ty bitwise_or_var; |
| 6102 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6103 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6104 | ) |
| 6105 | { |
| 6106 | res = bitwise_or_var; |
| 6107 | goto done; |
| 6108 | } |
| 6109 | p->mark = mark; |
| 6110 | } |
| 6111 | res = NULL; |
| 6112 | done: |
| 6113 | return res; |
| 6114 | } |
| 6115 | |
| 6116 | // compare_op_bitwise_or_pair: |
| 6117 | // | eq_bitwise_or |
| 6118 | // | noteq_bitwise_or |
| 6119 | // | lte_bitwise_or |
| 6120 | // | lt_bitwise_or |
| 6121 | // | gte_bitwise_or |
| 6122 | // | gt_bitwise_or |
| 6123 | // | notin_bitwise_or |
| 6124 | // | in_bitwise_or |
| 6125 | // | isnot_bitwise_or |
| 6126 | // | is_bitwise_or |
| 6127 | static CmpopExprPair* |
| 6128 | compare_op_bitwise_or_pair_rule(Parser *p) |
| 6129 | { |
| 6130 | if (p->error_indicator) { |
| 6131 | return NULL; |
| 6132 | } |
| 6133 | CmpopExprPair* res = NULL; |
| 6134 | int mark = p->mark; |
| 6135 | { // eq_bitwise_or |
| 6136 | CmpopExprPair* eq_bitwise_or_var; |
| 6137 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6138 | (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6139 | ) |
| 6140 | { |
| 6141 | res = eq_bitwise_or_var; |
| 6142 | goto done; |
| 6143 | } |
| 6144 | p->mark = mark; |
| 6145 | } |
| 6146 | { // noteq_bitwise_or |
| 6147 | CmpopExprPair* noteq_bitwise_or_var; |
| 6148 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6149 | (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6150 | ) |
| 6151 | { |
| 6152 | res = noteq_bitwise_or_var; |
| 6153 | goto done; |
| 6154 | } |
| 6155 | p->mark = mark; |
| 6156 | } |
| 6157 | { // lte_bitwise_or |
| 6158 | CmpopExprPair* lte_bitwise_or_var; |
| 6159 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6160 | (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6161 | ) |
| 6162 | { |
| 6163 | res = lte_bitwise_or_var; |
| 6164 | goto done; |
| 6165 | } |
| 6166 | p->mark = mark; |
| 6167 | } |
| 6168 | { // lt_bitwise_or |
| 6169 | CmpopExprPair* lt_bitwise_or_var; |
| 6170 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6171 | (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6172 | ) |
| 6173 | { |
| 6174 | res = lt_bitwise_or_var; |
| 6175 | goto done; |
| 6176 | } |
| 6177 | p->mark = mark; |
| 6178 | } |
| 6179 | { // gte_bitwise_or |
| 6180 | CmpopExprPair* gte_bitwise_or_var; |
| 6181 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6182 | (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6183 | ) |
| 6184 | { |
| 6185 | res = gte_bitwise_or_var; |
| 6186 | goto done; |
| 6187 | } |
| 6188 | p->mark = mark; |
| 6189 | } |
| 6190 | { // gt_bitwise_or |
| 6191 | CmpopExprPair* gt_bitwise_or_var; |
| 6192 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6193 | (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6194 | ) |
| 6195 | { |
| 6196 | res = gt_bitwise_or_var; |
| 6197 | goto done; |
| 6198 | } |
| 6199 | p->mark = mark; |
| 6200 | } |
| 6201 | { // notin_bitwise_or |
| 6202 | CmpopExprPair* notin_bitwise_or_var; |
| 6203 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6204 | (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6205 | ) |
| 6206 | { |
| 6207 | res = notin_bitwise_or_var; |
| 6208 | goto done; |
| 6209 | } |
| 6210 | p->mark = mark; |
| 6211 | } |
| 6212 | { // in_bitwise_or |
| 6213 | CmpopExprPair* in_bitwise_or_var; |
| 6214 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6215 | (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6216 | ) |
| 6217 | { |
| 6218 | res = in_bitwise_or_var; |
| 6219 | goto done; |
| 6220 | } |
| 6221 | p->mark = mark; |
| 6222 | } |
| 6223 | { // isnot_bitwise_or |
| 6224 | CmpopExprPair* isnot_bitwise_or_var; |
| 6225 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6226 | (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6227 | ) |
| 6228 | { |
| 6229 | res = isnot_bitwise_or_var; |
| 6230 | goto done; |
| 6231 | } |
| 6232 | p->mark = mark; |
| 6233 | } |
| 6234 | { // is_bitwise_or |
| 6235 | CmpopExprPair* is_bitwise_or_var; |
| 6236 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6237 | (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6238 | ) |
| 6239 | { |
| 6240 | res = is_bitwise_or_var; |
| 6241 | goto done; |
| 6242 | } |
| 6243 | p->mark = mark; |
| 6244 | } |
| 6245 | res = NULL; |
| 6246 | done: |
| 6247 | return res; |
| 6248 | } |
| 6249 | |
| 6250 | // eq_bitwise_or: '==' bitwise_or |
| 6251 | static CmpopExprPair* |
| 6252 | eq_bitwise_or_rule(Parser *p) |
| 6253 | { |
| 6254 | if (p->error_indicator) { |
| 6255 | return NULL; |
| 6256 | } |
| 6257 | CmpopExprPair* res = NULL; |
| 6258 | int mark = p->mark; |
| 6259 | { // '==' bitwise_or |
| 6260 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6261 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6262 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6263 | (literal = _PyPegen_expect_token(p, 27)) // token='==' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6264 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6265 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6266 | ) |
| 6267 | { |
| 6268 | res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); |
| 6269 | if (res == NULL && PyErr_Occurred()) { |
| 6270 | p->error_indicator = 1; |
| 6271 | return NULL; |
| 6272 | } |
| 6273 | goto done; |
| 6274 | } |
| 6275 | p->mark = mark; |
| 6276 | } |
| 6277 | res = NULL; |
| 6278 | done: |
| 6279 | return res; |
| 6280 | } |
| 6281 | |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6282 | // noteq_bitwise_or: ('!=') bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6283 | static CmpopExprPair* |
| 6284 | noteq_bitwise_or_rule(Parser *p) |
| 6285 | { |
| 6286 | if (p->error_indicator) { |
| 6287 | return NULL; |
| 6288 | } |
| 6289 | CmpopExprPair* res = NULL; |
| 6290 | int mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6291 | { // ('!=') bitwise_or |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6292 | void *_tmp_92_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6293 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6294 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6295 | (_tmp_92_var = _tmp_92_rule(p)) // '!=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6296 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6297 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6298 | ) |
| 6299 | { |
| 6300 | res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); |
| 6301 | if (res == NULL && PyErr_Occurred()) { |
| 6302 | p->error_indicator = 1; |
| 6303 | return NULL; |
| 6304 | } |
| 6305 | goto done; |
| 6306 | } |
| 6307 | p->mark = mark; |
| 6308 | } |
| 6309 | res = NULL; |
| 6310 | done: |
| 6311 | return res; |
| 6312 | } |
| 6313 | |
| 6314 | // lte_bitwise_or: '<=' bitwise_or |
| 6315 | static CmpopExprPair* |
| 6316 | lte_bitwise_or_rule(Parser *p) |
| 6317 | { |
| 6318 | if (p->error_indicator) { |
| 6319 | return NULL; |
| 6320 | } |
| 6321 | CmpopExprPair* res = NULL; |
| 6322 | int mark = p->mark; |
| 6323 | { // '<=' bitwise_or |
| 6324 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6325 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6326 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6327 | (literal = _PyPegen_expect_token(p, 29)) // token='<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6328 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6329 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6330 | ) |
| 6331 | { |
| 6332 | res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); |
| 6333 | if (res == NULL && PyErr_Occurred()) { |
| 6334 | p->error_indicator = 1; |
| 6335 | return NULL; |
| 6336 | } |
| 6337 | goto done; |
| 6338 | } |
| 6339 | p->mark = mark; |
| 6340 | } |
| 6341 | res = NULL; |
| 6342 | done: |
| 6343 | return res; |
| 6344 | } |
| 6345 | |
| 6346 | // lt_bitwise_or: '<' bitwise_or |
| 6347 | static CmpopExprPair* |
| 6348 | lt_bitwise_or_rule(Parser *p) |
| 6349 | { |
| 6350 | if (p->error_indicator) { |
| 6351 | return NULL; |
| 6352 | } |
| 6353 | CmpopExprPair* res = NULL; |
| 6354 | int mark = p->mark; |
| 6355 | { // '<' bitwise_or |
| 6356 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6357 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6358 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6359 | (literal = _PyPegen_expect_token(p, 20)) // token='<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6360 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6361 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6362 | ) |
| 6363 | { |
| 6364 | res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); |
| 6365 | if (res == NULL && PyErr_Occurred()) { |
| 6366 | p->error_indicator = 1; |
| 6367 | return NULL; |
| 6368 | } |
| 6369 | goto done; |
| 6370 | } |
| 6371 | p->mark = mark; |
| 6372 | } |
| 6373 | res = NULL; |
| 6374 | done: |
| 6375 | return res; |
| 6376 | } |
| 6377 | |
| 6378 | // gte_bitwise_or: '>=' bitwise_or |
| 6379 | static CmpopExprPair* |
| 6380 | gte_bitwise_or_rule(Parser *p) |
| 6381 | { |
| 6382 | if (p->error_indicator) { |
| 6383 | return NULL; |
| 6384 | } |
| 6385 | CmpopExprPair* res = NULL; |
| 6386 | int mark = p->mark; |
| 6387 | { // '>=' bitwise_or |
| 6388 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6389 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6390 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6391 | (literal = _PyPegen_expect_token(p, 30)) // token='>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6392 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6393 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6394 | ) |
| 6395 | { |
| 6396 | res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); |
| 6397 | if (res == NULL && PyErr_Occurred()) { |
| 6398 | p->error_indicator = 1; |
| 6399 | return NULL; |
| 6400 | } |
| 6401 | goto done; |
| 6402 | } |
| 6403 | p->mark = mark; |
| 6404 | } |
| 6405 | res = NULL; |
| 6406 | done: |
| 6407 | return res; |
| 6408 | } |
| 6409 | |
| 6410 | // gt_bitwise_or: '>' bitwise_or |
| 6411 | static CmpopExprPair* |
| 6412 | gt_bitwise_or_rule(Parser *p) |
| 6413 | { |
| 6414 | if (p->error_indicator) { |
| 6415 | return NULL; |
| 6416 | } |
| 6417 | CmpopExprPair* res = NULL; |
| 6418 | int mark = p->mark; |
| 6419 | { // '>' bitwise_or |
| 6420 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6421 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6422 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6423 | (literal = _PyPegen_expect_token(p, 21)) // token='>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6424 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6425 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6426 | ) |
| 6427 | { |
| 6428 | res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); |
| 6429 | if (res == NULL && PyErr_Occurred()) { |
| 6430 | p->error_indicator = 1; |
| 6431 | return NULL; |
| 6432 | } |
| 6433 | goto done; |
| 6434 | } |
| 6435 | p->mark = mark; |
| 6436 | } |
| 6437 | res = NULL; |
| 6438 | done: |
| 6439 | return res; |
| 6440 | } |
| 6441 | |
| 6442 | // notin_bitwise_or: 'not' 'in' bitwise_or |
| 6443 | static CmpopExprPair* |
| 6444 | notin_bitwise_or_rule(Parser *p) |
| 6445 | { |
| 6446 | if (p->error_indicator) { |
| 6447 | return NULL; |
| 6448 | } |
| 6449 | CmpopExprPair* res = NULL; |
| 6450 | int mark = p->mark; |
| 6451 | { // 'not' 'in' bitwise_or |
| 6452 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6453 | Token * keyword; |
| 6454 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6455 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6456 | (keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6457 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6458 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6459 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6460 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6461 | ) |
| 6462 | { |
| 6463 | res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); |
| 6464 | if (res == NULL && PyErr_Occurred()) { |
| 6465 | p->error_indicator = 1; |
| 6466 | return NULL; |
| 6467 | } |
| 6468 | goto done; |
| 6469 | } |
| 6470 | p->mark = mark; |
| 6471 | } |
| 6472 | res = NULL; |
| 6473 | done: |
| 6474 | return res; |
| 6475 | } |
| 6476 | |
| 6477 | // in_bitwise_or: 'in' bitwise_or |
| 6478 | static CmpopExprPair* |
| 6479 | in_bitwise_or_rule(Parser *p) |
| 6480 | { |
| 6481 | if (p->error_indicator) { |
| 6482 | return NULL; |
| 6483 | } |
| 6484 | CmpopExprPair* res = NULL; |
| 6485 | int mark = p->mark; |
| 6486 | { // 'in' bitwise_or |
| 6487 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6488 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6489 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6490 | (keyword = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6491 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6492 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6493 | ) |
| 6494 | { |
| 6495 | res = _PyPegen_cmpop_expr_pair ( p , In , a ); |
| 6496 | if (res == NULL && PyErr_Occurred()) { |
| 6497 | p->error_indicator = 1; |
| 6498 | return NULL; |
| 6499 | } |
| 6500 | goto done; |
| 6501 | } |
| 6502 | p->mark = mark; |
| 6503 | } |
| 6504 | res = NULL; |
| 6505 | done: |
| 6506 | return res; |
| 6507 | } |
| 6508 | |
| 6509 | // isnot_bitwise_or: 'is' 'not' bitwise_or |
| 6510 | static CmpopExprPair* |
| 6511 | isnot_bitwise_or_rule(Parser *p) |
| 6512 | { |
| 6513 | if (p->error_indicator) { |
| 6514 | return NULL; |
| 6515 | } |
| 6516 | CmpopExprPair* res = NULL; |
| 6517 | int mark = p->mark; |
| 6518 | { // 'is' 'not' bitwise_or |
| 6519 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6520 | Token * keyword; |
| 6521 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6522 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6523 | (keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6524 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6525 | (keyword_1 = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6526 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6527 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6528 | ) |
| 6529 | { |
| 6530 | res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); |
| 6531 | if (res == NULL && PyErr_Occurred()) { |
| 6532 | p->error_indicator = 1; |
| 6533 | return NULL; |
| 6534 | } |
| 6535 | goto done; |
| 6536 | } |
| 6537 | p->mark = mark; |
| 6538 | } |
| 6539 | res = NULL; |
| 6540 | done: |
| 6541 | return res; |
| 6542 | } |
| 6543 | |
| 6544 | // is_bitwise_or: 'is' bitwise_or |
| 6545 | static CmpopExprPair* |
| 6546 | is_bitwise_or_rule(Parser *p) |
| 6547 | { |
| 6548 | if (p->error_indicator) { |
| 6549 | return NULL; |
| 6550 | } |
| 6551 | CmpopExprPair* res = NULL; |
| 6552 | int mark = p->mark; |
| 6553 | { // 'is' bitwise_or |
| 6554 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6555 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6556 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6557 | (keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6558 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6559 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6560 | ) |
| 6561 | { |
| 6562 | res = _PyPegen_cmpop_expr_pair ( p , Is , a ); |
| 6563 | if (res == NULL && PyErr_Occurred()) { |
| 6564 | p->error_indicator = 1; |
| 6565 | return NULL; |
| 6566 | } |
| 6567 | goto done; |
| 6568 | } |
| 6569 | p->mark = mark; |
| 6570 | } |
| 6571 | res = NULL; |
| 6572 | done: |
| 6573 | return res; |
| 6574 | } |
| 6575 | |
| 6576 | // Left-recursive |
| 6577 | // bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor |
| 6578 | static expr_ty bitwise_or_raw(Parser *); |
| 6579 | static expr_ty |
| 6580 | bitwise_or_rule(Parser *p) |
| 6581 | { |
| 6582 | expr_ty res = NULL; |
| 6583 | if (_PyPegen_is_memoized(p, bitwise_or_type, &res)) |
| 6584 | return res; |
| 6585 | int mark = p->mark; |
| 6586 | int resmark = p->mark; |
| 6587 | while (1) { |
| 6588 | int tmpvar_1 = _PyPegen_update_memo(p, mark, bitwise_or_type, res); |
| 6589 | if (tmpvar_1) { |
| 6590 | return res; |
| 6591 | } |
| 6592 | p->mark = mark; |
| 6593 | void *raw = bitwise_or_raw(p); |
| 6594 | if (raw == NULL || p->mark <= resmark) |
| 6595 | break; |
| 6596 | resmark = p->mark; |
| 6597 | res = raw; |
| 6598 | } |
| 6599 | p->mark = resmark; |
| 6600 | return res; |
| 6601 | } |
| 6602 | static expr_ty |
| 6603 | bitwise_or_raw(Parser *p) |
| 6604 | { |
| 6605 | if (p->error_indicator) { |
| 6606 | return NULL; |
| 6607 | } |
| 6608 | expr_ty res = NULL; |
| 6609 | int mark = p->mark; |
| 6610 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6611 | p->error_indicator = 1; |
| 6612 | return NULL; |
| 6613 | } |
| 6614 | int start_lineno = p->tokens[mark]->lineno; |
| 6615 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6616 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6617 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6618 | { // bitwise_or '|' bitwise_xor |
| 6619 | expr_ty a; |
| 6620 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6621 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6622 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6623 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6624 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6625 | (literal = _PyPegen_expect_token(p, 18)) // token='|' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6626 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6627 | (b = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6628 | ) |
| 6629 | { |
| 6630 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6631 | if (token == NULL) { |
| 6632 | return NULL; |
| 6633 | } |
| 6634 | int end_lineno = token->end_lineno; |
| 6635 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6636 | int end_col_offset = token->end_col_offset; |
| 6637 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6638 | res = _Py_BinOp ( a , BitOr , b , EXTRA ); |
| 6639 | if (res == NULL && PyErr_Occurred()) { |
| 6640 | p->error_indicator = 1; |
| 6641 | return NULL; |
| 6642 | } |
| 6643 | goto done; |
| 6644 | } |
| 6645 | p->mark = mark; |
| 6646 | } |
| 6647 | { // bitwise_xor |
| 6648 | expr_ty bitwise_xor_var; |
| 6649 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6650 | (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6651 | ) |
| 6652 | { |
| 6653 | res = bitwise_xor_var; |
| 6654 | goto done; |
| 6655 | } |
| 6656 | p->mark = mark; |
| 6657 | } |
| 6658 | res = NULL; |
| 6659 | done: |
| 6660 | return res; |
| 6661 | } |
| 6662 | |
| 6663 | // Left-recursive |
| 6664 | // bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and |
| 6665 | static expr_ty bitwise_xor_raw(Parser *); |
| 6666 | static expr_ty |
| 6667 | bitwise_xor_rule(Parser *p) |
| 6668 | { |
| 6669 | expr_ty res = NULL; |
| 6670 | if (_PyPegen_is_memoized(p, bitwise_xor_type, &res)) |
| 6671 | return res; |
| 6672 | int mark = p->mark; |
| 6673 | int resmark = p->mark; |
| 6674 | while (1) { |
| 6675 | int tmpvar_2 = _PyPegen_update_memo(p, mark, bitwise_xor_type, res); |
| 6676 | if (tmpvar_2) { |
| 6677 | return res; |
| 6678 | } |
| 6679 | p->mark = mark; |
| 6680 | void *raw = bitwise_xor_raw(p); |
| 6681 | if (raw == NULL || p->mark <= resmark) |
| 6682 | break; |
| 6683 | resmark = p->mark; |
| 6684 | res = raw; |
| 6685 | } |
| 6686 | p->mark = resmark; |
| 6687 | return res; |
| 6688 | } |
| 6689 | static expr_ty |
| 6690 | bitwise_xor_raw(Parser *p) |
| 6691 | { |
| 6692 | if (p->error_indicator) { |
| 6693 | return NULL; |
| 6694 | } |
| 6695 | expr_ty res = NULL; |
| 6696 | int mark = p->mark; |
| 6697 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6698 | p->error_indicator = 1; |
| 6699 | return NULL; |
| 6700 | } |
| 6701 | int start_lineno = p->tokens[mark]->lineno; |
| 6702 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6703 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6704 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6705 | { // bitwise_xor '^' bitwise_and |
| 6706 | expr_ty a; |
| 6707 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6708 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6709 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6710 | (a = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6711 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6712 | (literal = _PyPegen_expect_token(p, 32)) // token='^' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6713 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6714 | (b = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6715 | ) |
| 6716 | { |
| 6717 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6718 | if (token == NULL) { |
| 6719 | return NULL; |
| 6720 | } |
| 6721 | int end_lineno = token->end_lineno; |
| 6722 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6723 | int end_col_offset = token->end_col_offset; |
| 6724 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6725 | res = _Py_BinOp ( a , BitXor , b , EXTRA ); |
| 6726 | if (res == NULL && PyErr_Occurred()) { |
| 6727 | p->error_indicator = 1; |
| 6728 | return NULL; |
| 6729 | } |
| 6730 | goto done; |
| 6731 | } |
| 6732 | p->mark = mark; |
| 6733 | } |
| 6734 | { // bitwise_and |
| 6735 | expr_ty bitwise_and_var; |
| 6736 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6737 | (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6738 | ) |
| 6739 | { |
| 6740 | res = bitwise_and_var; |
| 6741 | goto done; |
| 6742 | } |
| 6743 | p->mark = mark; |
| 6744 | } |
| 6745 | res = NULL; |
| 6746 | done: |
| 6747 | return res; |
| 6748 | } |
| 6749 | |
| 6750 | // Left-recursive |
| 6751 | // bitwise_and: bitwise_and '&' shift_expr | shift_expr |
| 6752 | static expr_ty bitwise_and_raw(Parser *); |
| 6753 | static expr_ty |
| 6754 | bitwise_and_rule(Parser *p) |
| 6755 | { |
| 6756 | expr_ty res = NULL; |
| 6757 | if (_PyPegen_is_memoized(p, bitwise_and_type, &res)) |
| 6758 | return res; |
| 6759 | int mark = p->mark; |
| 6760 | int resmark = p->mark; |
| 6761 | while (1) { |
| 6762 | int tmpvar_3 = _PyPegen_update_memo(p, mark, bitwise_and_type, res); |
| 6763 | if (tmpvar_3) { |
| 6764 | return res; |
| 6765 | } |
| 6766 | p->mark = mark; |
| 6767 | void *raw = bitwise_and_raw(p); |
| 6768 | if (raw == NULL || p->mark <= resmark) |
| 6769 | break; |
| 6770 | resmark = p->mark; |
| 6771 | res = raw; |
| 6772 | } |
| 6773 | p->mark = resmark; |
| 6774 | return res; |
| 6775 | } |
| 6776 | static expr_ty |
| 6777 | bitwise_and_raw(Parser *p) |
| 6778 | { |
| 6779 | if (p->error_indicator) { |
| 6780 | return NULL; |
| 6781 | } |
| 6782 | expr_ty res = NULL; |
| 6783 | int mark = p->mark; |
| 6784 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6785 | p->error_indicator = 1; |
| 6786 | return NULL; |
| 6787 | } |
| 6788 | int start_lineno = p->tokens[mark]->lineno; |
| 6789 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6790 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6791 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6792 | { // bitwise_and '&' shift_expr |
| 6793 | expr_ty a; |
| 6794 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6795 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6796 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6797 | (a = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6798 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6799 | (literal = _PyPegen_expect_token(p, 19)) // token='&' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6800 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6801 | (b = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6802 | ) |
| 6803 | { |
| 6804 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6805 | if (token == NULL) { |
| 6806 | return NULL; |
| 6807 | } |
| 6808 | int end_lineno = token->end_lineno; |
| 6809 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6810 | int end_col_offset = token->end_col_offset; |
| 6811 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6812 | res = _Py_BinOp ( a , BitAnd , b , EXTRA ); |
| 6813 | if (res == NULL && PyErr_Occurred()) { |
| 6814 | p->error_indicator = 1; |
| 6815 | return NULL; |
| 6816 | } |
| 6817 | goto done; |
| 6818 | } |
| 6819 | p->mark = mark; |
| 6820 | } |
| 6821 | { // shift_expr |
| 6822 | expr_ty shift_expr_var; |
| 6823 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6824 | (shift_expr_var = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6825 | ) |
| 6826 | { |
| 6827 | res = shift_expr_var; |
| 6828 | goto done; |
| 6829 | } |
| 6830 | p->mark = mark; |
| 6831 | } |
| 6832 | res = NULL; |
| 6833 | done: |
| 6834 | return res; |
| 6835 | } |
| 6836 | |
| 6837 | // Left-recursive |
| 6838 | // shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum |
| 6839 | static expr_ty shift_expr_raw(Parser *); |
| 6840 | static expr_ty |
| 6841 | shift_expr_rule(Parser *p) |
| 6842 | { |
| 6843 | expr_ty res = NULL; |
| 6844 | if (_PyPegen_is_memoized(p, shift_expr_type, &res)) |
| 6845 | return res; |
| 6846 | int mark = p->mark; |
| 6847 | int resmark = p->mark; |
| 6848 | while (1) { |
| 6849 | int tmpvar_4 = _PyPegen_update_memo(p, mark, shift_expr_type, res); |
| 6850 | if (tmpvar_4) { |
| 6851 | return res; |
| 6852 | } |
| 6853 | p->mark = mark; |
| 6854 | void *raw = shift_expr_raw(p); |
| 6855 | if (raw == NULL || p->mark <= resmark) |
| 6856 | break; |
| 6857 | resmark = p->mark; |
| 6858 | res = raw; |
| 6859 | } |
| 6860 | p->mark = resmark; |
| 6861 | return res; |
| 6862 | } |
| 6863 | static expr_ty |
| 6864 | shift_expr_raw(Parser *p) |
| 6865 | { |
| 6866 | if (p->error_indicator) { |
| 6867 | return NULL; |
| 6868 | } |
| 6869 | expr_ty res = NULL; |
| 6870 | int mark = p->mark; |
| 6871 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6872 | p->error_indicator = 1; |
| 6873 | return NULL; |
| 6874 | } |
| 6875 | int start_lineno = p->tokens[mark]->lineno; |
| 6876 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6877 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6878 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6879 | { // shift_expr '<<' sum |
| 6880 | expr_ty a; |
| 6881 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6882 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6883 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6884 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6885 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6886 | (literal = _PyPegen_expect_token(p, 33)) // token='<<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6887 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6888 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6889 | ) |
| 6890 | { |
| 6891 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6892 | if (token == NULL) { |
| 6893 | return NULL; |
| 6894 | } |
| 6895 | int end_lineno = token->end_lineno; |
| 6896 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6897 | int end_col_offset = token->end_col_offset; |
| 6898 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6899 | res = _Py_BinOp ( a , LShift , b , EXTRA ); |
| 6900 | if (res == NULL && PyErr_Occurred()) { |
| 6901 | p->error_indicator = 1; |
| 6902 | return NULL; |
| 6903 | } |
| 6904 | goto done; |
| 6905 | } |
| 6906 | p->mark = mark; |
| 6907 | } |
| 6908 | { // shift_expr '>>' sum |
| 6909 | expr_ty a; |
| 6910 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6911 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6912 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6913 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6914 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6915 | (literal = _PyPegen_expect_token(p, 34)) // token='>>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6916 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6917 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6918 | ) |
| 6919 | { |
| 6920 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6921 | if (token == NULL) { |
| 6922 | return NULL; |
| 6923 | } |
| 6924 | int end_lineno = token->end_lineno; |
| 6925 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6926 | int end_col_offset = token->end_col_offset; |
| 6927 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6928 | res = _Py_BinOp ( a , RShift , b , EXTRA ); |
| 6929 | if (res == NULL && PyErr_Occurred()) { |
| 6930 | p->error_indicator = 1; |
| 6931 | return NULL; |
| 6932 | } |
| 6933 | goto done; |
| 6934 | } |
| 6935 | p->mark = mark; |
| 6936 | } |
| 6937 | { // sum |
| 6938 | expr_ty sum_var; |
| 6939 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 6940 | (sum_var = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6941 | ) |
| 6942 | { |
| 6943 | res = sum_var; |
| 6944 | goto done; |
| 6945 | } |
| 6946 | p->mark = mark; |
| 6947 | } |
| 6948 | res = NULL; |
| 6949 | done: |
| 6950 | return res; |
| 6951 | } |
| 6952 | |
| 6953 | // Left-recursive |
| 6954 | // sum: sum '+' term | sum '-' term | term |
| 6955 | static expr_ty sum_raw(Parser *); |
| 6956 | static expr_ty |
| 6957 | sum_rule(Parser *p) |
| 6958 | { |
| 6959 | expr_ty res = NULL; |
| 6960 | if (_PyPegen_is_memoized(p, sum_type, &res)) |
| 6961 | return res; |
| 6962 | int mark = p->mark; |
| 6963 | int resmark = p->mark; |
| 6964 | while (1) { |
| 6965 | int tmpvar_5 = _PyPegen_update_memo(p, mark, sum_type, res); |
| 6966 | if (tmpvar_5) { |
| 6967 | return res; |
| 6968 | } |
| 6969 | p->mark = mark; |
| 6970 | void *raw = sum_raw(p); |
| 6971 | if (raw == NULL || p->mark <= resmark) |
| 6972 | break; |
| 6973 | resmark = p->mark; |
| 6974 | res = raw; |
| 6975 | } |
| 6976 | p->mark = resmark; |
| 6977 | return res; |
| 6978 | } |
| 6979 | static expr_ty |
| 6980 | sum_raw(Parser *p) |
| 6981 | { |
| 6982 | if (p->error_indicator) { |
| 6983 | return NULL; |
| 6984 | } |
| 6985 | expr_ty res = NULL; |
| 6986 | int mark = p->mark; |
| 6987 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6988 | p->error_indicator = 1; |
| 6989 | return NULL; |
| 6990 | } |
| 6991 | int start_lineno = p->tokens[mark]->lineno; |
| 6992 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6993 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6994 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6995 | { // sum '+' term |
| 6996 | expr_ty a; |
| 6997 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6998 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6999 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7000 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7001 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7002 | (literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7003 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7004 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7005 | ) |
| 7006 | { |
| 7007 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7008 | if (token == NULL) { |
| 7009 | return NULL; |
| 7010 | } |
| 7011 | int end_lineno = token->end_lineno; |
| 7012 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7013 | int end_col_offset = token->end_col_offset; |
| 7014 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7015 | res = _Py_BinOp ( a , Add , b , EXTRA ); |
| 7016 | if (res == NULL && PyErr_Occurred()) { |
| 7017 | p->error_indicator = 1; |
| 7018 | return NULL; |
| 7019 | } |
| 7020 | goto done; |
| 7021 | } |
| 7022 | p->mark = mark; |
| 7023 | } |
| 7024 | { // sum '-' term |
| 7025 | expr_ty a; |
| 7026 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7027 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7028 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7029 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7030 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7031 | (literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7032 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7033 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7034 | ) |
| 7035 | { |
| 7036 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7037 | if (token == NULL) { |
| 7038 | return NULL; |
| 7039 | } |
| 7040 | int end_lineno = token->end_lineno; |
| 7041 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7042 | int end_col_offset = token->end_col_offset; |
| 7043 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7044 | res = _Py_BinOp ( a , Sub , b , EXTRA ); |
| 7045 | if (res == NULL && PyErr_Occurred()) { |
| 7046 | p->error_indicator = 1; |
| 7047 | return NULL; |
| 7048 | } |
| 7049 | goto done; |
| 7050 | } |
| 7051 | p->mark = mark; |
| 7052 | } |
| 7053 | { // term |
| 7054 | expr_ty term_var; |
| 7055 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7056 | (term_var = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7057 | ) |
| 7058 | { |
| 7059 | res = term_var; |
| 7060 | goto done; |
| 7061 | } |
| 7062 | p->mark = mark; |
| 7063 | } |
| 7064 | res = NULL; |
| 7065 | done: |
| 7066 | return res; |
| 7067 | } |
| 7068 | |
| 7069 | // Left-recursive |
| 7070 | // term: |
| 7071 | // | term '*' factor |
| 7072 | // | term '/' factor |
| 7073 | // | term '//' factor |
| 7074 | // | term '%' factor |
| 7075 | // | term '@' factor |
| 7076 | // | factor |
| 7077 | static expr_ty term_raw(Parser *); |
| 7078 | static expr_ty |
| 7079 | term_rule(Parser *p) |
| 7080 | { |
| 7081 | expr_ty res = NULL; |
| 7082 | if (_PyPegen_is_memoized(p, term_type, &res)) |
| 7083 | return res; |
| 7084 | int mark = p->mark; |
| 7085 | int resmark = p->mark; |
| 7086 | while (1) { |
| 7087 | int tmpvar_6 = _PyPegen_update_memo(p, mark, term_type, res); |
| 7088 | if (tmpvar_6) { |
| 7089 | return res; |
| 7090 | } |
| 7091 | p->mark = mark; |
| 7092 | void *raw = term_raw(p); |
| 7093 | if (raw == NULL || p->mark <= resmark) |
| 7094 | break; |
| 7095 | resmark = p->mark; |
| 7096 | res = raw; |
| 7097 | } |
| 7098 | p->mark = resmark; |
| 7099 | return res; |
| 7100 | } |
| 7101 | static expr_ty |
| 7102 | term_raw(Parser *p) |
| 7103 | { |
| 7104 | if (p->error_indicator) { |
| 7105 | return NULL; |
| 7106 | } |
| 7107 | expr_ty res = NULL; |
| 7108 | int mark = p->mark; |
| 7109 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7110 | p->error_indicator = 1; |
| 7111 | return NULL; |
| 7112 | } |
| 7113 | int start_lineno = p->tokens[mark]->lineno; |
| 7114 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7115 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7116 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7117 | { // term '*' factor |
| 7118 | expr_ty a; |
| 7119 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7120 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7121 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7122 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7123 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7124 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7125 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7126 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7127 | ) |
| 7128 | { |
| 7129 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7130 | if (token == NULL) { |
| 7131 | return NULL; |
| 7132 | } |
| 7133 | int end_lineno = token->end_lineno; |
| 7134 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7135 | int end_col_offset = token->end_col_offset; |
| 7136 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7137 | res = _Py_BinOp ( a , Mult , b , EXTRA ); |
| 7138 | if (res == NULL && PyErr_Occurred()) { |
| 7139 | p->error_indicator = 1; |
| 7140 | return NULL; |
| 7141 | } |
| 7142 | goto done; |
| 7143 | } |
| 7144 | p->mark = mark; |
| 7145 | } |
| 7146 | { // term '/' factor |
| 7147 | expr_ty a; |
| 7148 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7149 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7150 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7151 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7152 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7153 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7154 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7155 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7156 | ) |
| 7157 | { |
| 7158 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7159 | if (token == NULL) { |
| 7160 | return NULL; |
| 7161 | } |
| 7162 | int end_lineno = token->end_lineno; |
| 7163 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7164 | int end_col_offset = token->end_col_offset; |
| 7165 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7166 | res = _Py_BinOp ( a , Div , b , EXTRA ); |
| 7167 | if (res == NULL && PyErr_Occurred()) { |
| 7168 | p->error_indicator = 1; |
| 7169 | return NULL; |
| 7170 | } |
| 7171 | goto done; |
| 7172 | } |
| 7173 | p->mark = mark; |
| 7174 | } |
| 7175 | { // term '//' factor |
| 7176 | expr_ty a; |
| 7177 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7178 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7179 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7180 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7181 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7182 | (literal = _PyPegen_expect_token(p, 47)) // token='//' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7183 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7184 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7185 | ) |
| 7186 | { |
| 7187 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7188 | if (token == NULL) { |
| 7189 | return NULL; |
| 7190 | } |
| 7191 | int end_lineno = token->end_lineno; |
| 7192 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7193 | int end_col_offset = token->end_col_offset; |
| 7194 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7195 | res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); |
| 7196 | if (res == NULL && PyErr_Occurred()) { |
| 7197 | p->error_indicator = 1; |
| 7198 | return NULL; |
| 7199 | } |
| 7200 | goto done; |
| 7201 | } |
| 7202 | p->mark = mark; |
| 7203 | } |
| 7204 | { // term '%' factor |
| 7205 | expr_ty a; |
| 7206 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7207 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7208 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7209 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7210 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7211 | (literal = _PyPegen_expect_token(p, 24)) // token='%' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7212 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7213 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7214 | ) |
| 7215 | { |
| 7216 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7217 | if (token == NULL) { |
| 7218 | return NULL; |
| 7219 | } |
| 7220 | int end_lineno = token->end_lineno; |
| 7221 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7222 | int end_col_offset = token->end_col_offset; |
| 7223 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7224 | res = _Py_BinOp ( a , Mod , b , EXTRA ); |
| 7225 | if (res == NULL && PyErr_Occurred()) { |
| 7226 | p->error_indicator = 1; |
| 7227 | return NULL; |
| 7228 | } |
| 7229 | goto done; |
| 7230 | } |
| 7231 | p->mark = mark; |
| 7232 | } |
| 7233 | { // term '@' factor |
| 7234 | expr_ty a; |
| 7235 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7236 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7237 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7238 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7239 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7240 | (literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7241 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7242 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7243 | ) |
| 7244 | { |
| 7245 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7246 | if (token == NULL) { |
| 7247 | return NULL; |
| 7248 | } |
| 7249 | int end_lineno = token->end_lineno; |
| 7250 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7251 | int end_col_offset = token->end_col_offset; |
| 7252 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 7253 | res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7254 | if (res == NULL && PyErr_Occurred()) { |
| 7255 | p->error_indicator = 1; |
| 7256 | return NULL; |
| 7257 | } |
| 7258 | goto done; |
| 7259 | } |
| 7260 | p->mark = mark; |
| 7261 | } |
| 7262 | { // factor |
| 7263 | expr_ty factor_var; |
| 7264 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7265 | (factor_var = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7266 | ) |
| 7267 | { |
| 7268 | res = factor_var; |
| 7269 | goto done; |
| 7270 | } |
| 7271 | p->mark = mark; |
| 7272 | } |
| 7273 | res = NULL; |
| 7274 | done: |
| 7275 | return res; |
| 7276 | } |
| 7277 | |
| 7278 | // factor: '+' factor | '-' factor | '~' factor | power |
| 7279 | static expr_ty |
| 7280 | factor_rule(Parser *p) |
| 7281 | { |
| 7282 | if (p->error_indicator) { |
| 7283 | return NULL; |
| 7284 | } |
| 7285 | expr_ty res = NULL; |
| 7286 | if (_PyPegen_is_memoized(p, factor_type, &res)) |
| 7287 | return res; |
| 7288 | int mark = p->mark; |
| 7289 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7290 | p->error_indicator = 1; |
| 7291 | return NULL; |
| 7292 | } |
| 7293 | int start_lineno = p->tokens[mark]->lineno; |
| 7294 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7295 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7296 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7297 | { // '+' factor |
| 7298 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7299 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7300 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7301 | (literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7302 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7303 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7304 | ) |
| 7305 | { |
| 7306 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7307 | if (token == NULL) { |
| 7308 | return NULL; |
| 7309 | } |
| 7310 | int end_lineno = token->end_lineno; |
| 7311 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7312 | int end_col_offset = token->end_col_offset; |
| 7313 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7314 | res = _Py_UnaryOp ( UAdd , a , EXTRA ); |
| 7315 | if (res == NULL && PyErr_Occurred()) { |
| 7316 | p->error_indicator = 1; |
| 7317 | return NULL; |
| 7318 | } |
| 7319 | goto done; |
| 7320 | } |
| 7321 | p->mark = mark; |
| 7322 | } |
| 7323 | { // '-' factor |
| 7324 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7325 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7326 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7327 | (literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7328 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7329 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7330 | ) |
| 7331 | { |
| 7332 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7333 | if (token == NULL) { |
| 7334 | return NULL; |
| 7335 | } |
| 7336 | int end_lineno = token->end_lineno; |
| 7337 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7338 | int end_col_offset = token->end_col_offset; |
| 7339 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7340 | res = _Py_UnaryOp ( USub , a , EXTRA ); |
| 7341 | if (res == NULL && PyErr_Occurred()) { |
| 7342 | p->error_indicator = 1; |
| 7343 | return NULL; |
| 7344 | } |
| 7345 | goto done; |
| 7346 | } |
| 7347 | p->mark = mark; |
| 7348 | } |
| 7349 | { // '~' factor |
| 7350 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7351 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7352 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7353 | (literal = _PyPegen_expect_token(p, 31)) // token='~' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7354 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7355 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7356 | ) |
| 7357 | { |
| 7358 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7359 | if (token == NULL) { |
| 7360 | return NULL; |
| 7361 | } |
| 7362 | int end_lineno = token->end_lineno; |
| 7363 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7364 | int end_col_offset = token->end_col_offset; |
| 7365 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7366 | res = _Py_UnaryOp ( Invert , a , EXTRA ); |
| 7367 | if (res == NULL && PyErr_Occurred()) { |
| 7368 | p->error_indicator = 1; |
| 7369 | return NULL; |
| 7370 | } |
| 7371 | goto done; |
| 7372 | } |
| 7373 | p->mark = mark; |
| 7374 | } |
| 7375 | { // power |
| 7376 | expr_ty power_var; |
| 7377 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7378 | (power_var = power_rule(p)) // power |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7379 | ) |
| 7380 | { |
| 7381 | res = power_var; |
| 7382 | goto done; |
| 7383 | } |
| 7384 | p->mark = mark; |
| 7385 | } |
| 7386 | res = NULL; |
| 7387 | done: |
| 7388 | _PyPegen_insert_memo(p, mark, factor_type, res); |
| 7389 | return res; |
| 7390 | } |
| 7391 | |
| 7392 | // power: await_primary '**' factor | await_primary |
| 7393 | static expr_ty |
| 7394 | power_rule(Parser *p) |
| 7395 | { |
| 7396 | if (p->error_indicator) { |
| 7397 | return NULL; |
| 7398 | } |
| 7399 | expr_ty res = NULL; |
| 7400 | int mark = p->mark; |
| 7401 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7402 | p->error_indicator = 1; |
| 7403 | return NULL; |
| 7404 | } |
| 7405 | int start_lineno = p->tokens[mark]->lineno; |
| 7406 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7407 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7408 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7409 | { // await_primary '**' factor |
| 7410 | expr_ty a; |
| 7411 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7412 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7413 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7414 | (a = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7415 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7416 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7417 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7418 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7419 | ) |
| 7420 | { |
| 7421 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7422 | if (token == NULL) { |
| 7423 | return NULL; |
| 7424 | } |
| 7425 | int end_lineno = token->end_lineno; |
| 7426 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7427 | int end_col_offset = token->end_col_offset; |
| 7428 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7429 | res = _Py_BinOp ( a , Pow , b , EXTRA ); |
| 7430 | if (res == NULL && PyErr_Occurred()) { |
| 7431 | p->error_indicator = 1; |
| 7432 | return NULL; |
| 7433 | } |
| 7434 | goto done; |
| 7435 | } |
| 7436 | p->mark = mark; |
| 7437 | } |
| 7438 | { // await_primary |
| 7439 | expr_ty await_primary_var; |
| 7440 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7441 | (await_primary_var = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7442 | ) |
| 7443 | { |
| 7444 | res = await_primary_var; |
| 7445 | goto done; |
| 7446 | } |
| 7447 | p->mark = mark; |
| 7448 | } |
| 7449 | res = NULL; |
| 7450 | done: |
| 7451 | return res; |
| 7452 | } |
| 7453 | |
| 7454 | // await_primary: AWAIT primary | primary |
| 7455 | static expr_ty |
| 7456 | await_primary_rule(Parser *p) |
| 7457 | { |
| 7458 | if (p->error_indicator) { |
| 7459 | return NULL; |
| 7460 | } |
| 7461 | expr_ty res = NULL; |
| 7462 | if (_PyPegen_is_memoized(p, await_primary_type, &res)) |
| 7463 | return res; |
| 7464 | int mark = p->mark; |
| 7465 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7466 | p->error_indicator = 1; |
| 7467 | return NULL; |
| 7468 | } |
| 7469 | int start_lineno = p->tokens[mark]->lineno; |
| 7470 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7471 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7472 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7473 | { // AWAIT primary |
| 7474 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7475 | Token * await_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7476 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7477 | (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7478 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7479 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7480 | ) |
| 7481 | { |
| 7482 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7483 | if (token == NULL) { |
| 7484 | return NULL; |
| 7485 | } |
| 7486 | int end_lineno = token->end_lineno; |
| 7487 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7488 | int end_col_offset = token->end_col_offset; |
| 7489 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 7490 | res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7491 | if (res == NULL && PyErr_Occurred()) { |
| 7492 | p->error_indicator = 1; |
| 7493 | return NULL; |
| 7494 | } |
| 7495 | goto done; |
| 7496 | } |
| 7497 | p->mark = mark; |
| 7498 | } |
| 7499 | { // primary |
| 7500 | expr_ty primary_var; |
| 7501 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7502 | (primary_var = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7503 | ) |
| 7504 | { |
| 7505 | res = primary_var; |
| 7506 | goto done; |
| 7507 | } |
| 7508 | p->mark = mark; |
| 7509 | } |
| 7510 | res = NULL; |
| 7511 | done: |
| 7512 | _PyPegen_insert_memo(p, mark, await_primary_type, res); |
| 7513 | return res; |
| 7514 | } |
| 7515 | |
| 7516 | // Left-recursive |
| 7517 | // primary: |
| 7518 | // | primary '.' NAME |
| 7519 | // | primary genexp |
| 7520 | // | primary '(' arguments? ')' |
| 7521 | // | primary '[' slices ']' |
| 7522 | // | atom |
| 7523 | static expr_ty primary_raw(Parser *); |
| 7524 | static expr_ty |
| 7525 | primary_rule(Parser *p) |
| 7526 | { |
| 7527 | expr_ty res = NULL; |
| 7528 | if (_PyPegen_is_memoized(p, primary_type, &res)) |
| 7529 | return res; |
| 7530 | int mark = p->mark; |
| 7531 | int resmark = p->mark; |
| 7532 | while (1) { |
| 7533 | int tmpvar_7 = _PyPegen_update_memo(p, mark, primary_type, res); |
| 7534 | if (tmpvar_7) { |
| 7535 | return res; |
| 7536 | } |
| 7537 | p->mark = mark; |
| 7538 | void *raw = primary_raw(p); |
| 7539 | if (raw == NULL || p->mark <= resmark) |
| 7540 | break; |
| 7541 | resmark = p->mark; |
| 7542 | res = raw; |
| 7543 | } |
| 7544 | p->mark = resmark; |
| 7545 | return res; |
| 7546 | } |
| 7547 | static expr_ty |
| 7548 | primary_raw(Parser *p) |
| 7549 | { |
| 7550 | if (p->error_indicator) { |
| 7551 | return NULL; |
| 7552 | } |
| 7553 | expr_ty res = NULL; |
| 7554 | int mark = p->mark; |
| 7555 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7556 | p->error_indicator = 1; |
| 7557 | return NULL; |
| 7558 | } |
| 7559 | int start_lineno = p->tokens[mark]->lineno; |
| 7560 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7561 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7562 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7563 | { // primary '.' NAME |
| 7564 | expr_ty a; |
| 7565 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7566 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7567 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7568 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7569 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7570 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7571 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7572 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7573 | ) |
| 7574 | { |
| 7575 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7576 | if (token == NULL) { |
| 7577 | return NULL; |
| 7578 | } |
| 7579 | int end_lineno = token->end_lineno; |
| 7580 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7581 | int end_col_offset = token->end_col_offset; |
| 7582 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7583 | res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 7584 | if (res == NULL && PyErr_Occurred()) { |
| 7585 | p->error_indicator = 1; |
| 7586 | return NULL; |
| 7587 | } |
| 7588 | goto done; |
| 7589 | } |
| 7590 | p->mark = mark; |
| 7591 | } |
| 7592 | { // primary genexp |
| 7593 | expr_ty a; |
| 7594 | expr_ty b; |
| 7595 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7596 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7597 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7598 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7599 | ) |
| 7600 | { |
| 7601 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7602 | if (token == NULL) { |
| 7603 | return NULL; |
| 7604 | } |
| 7605 | int end_lineno = token->end_lineno; |
| 7606 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7607 | int end_col_offset = token->end_col_offset; |
| 7608 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7609 | res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 7610 | if (res == NULL && PyErr_Occurred()) { |
| 7611 | p->error_indicator = 1; |
| 7612 | return NULL; |
| 7613 | } |
| 7614 | goto done; |
| 7615 | } |
| 7616 | p->mark = mark; |
| 7617 | } |
| 7618 | { // primary '(' arguments? ')' |
| 7619 | expr_ty a; |
| 7620 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7621 | Token * literal; |
| 7622 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7623 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7624 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7625 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7626 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7627 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7628 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7629 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7630 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7631 | ) |
| 7632 | { |
| 7633 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7634 | if (token == NULL) { |
| 7635 | return NULL; |
| 7636 | } |
| 7637 | int end_lineno = token->end_lineno; |
| 7638 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7639 | int end_col_offset = token->end_col_offset; |
| 7640 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7641 | res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 7642 | if (res == NULL && PyErr_Occurred()) { |
| 7643 | p->error_indicator = 1; |
| 7644 | return NULL; |
| 7645 | } |
| 7646 | goto done; |
| 7647 | } |
| 7648 | p->mark = mark; |
| 7649 | } |
| 7650 | { // primary '[' slices ']' |
| 7651 | expr_ty a; |
| 7652 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7653 | Token * literal; |
| 7654 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7655 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7656 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7657 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7658 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7659 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7660 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7661 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7662 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7663 | ) |
| 7664 | { |
| 7665 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7666 | if (token == NULL) { |
| 7667 | return NULL; |
| 7668 | } |
| 7669 | int end_lineno = token->end_lineno; |
| 7670 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7671 | int end_col_offset = token->end_col_offset; |
| 7672 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7673 | res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 7674 | if (res == NULL && PyErr_Occurred()) { |
| 7675 | p->error_indicator = 1; |
| 7676 | return NULL; |
| 7677 | } |
| 7678 | goto done; |
| 7679 | } |
| 7680 | p->mark = mark; |
| 7681 | } |
| 7682 | { // atom |
| 7683 | expr_ty atom_var; |
| 7684 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7685 | (atom_var = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7686 | ) |
| 7687 | { |
| 7688 | res = atom_var; |
| 7689 | goto done; |
| 7690 | } |
| 7691 | p->mark = mark; |
| 7692 | } |
| 7693 | res = NULL; |
| 7694 | done: |
| 7695 | return res; |
| 7696 | } |
| 7697 | |
| 7698 | // slices: slice !',' | ','.slice+ ','? |
| 7699 | static expr_ty |
| 7700 | slices_rule(Parser *p) |
| 7701 | { |
| 7702 | if (p->error_indicator) { |
| 7703 | return NULL; |
| 7704 | } |
| 7705 | expr_ty res = NULL; |
| 7706 | int mark = p->mark; |
| 7707 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7708 | p->error_indicator = 1; |
| 7709 | return NULL; |
| 7710 | } |
| 7711 | int start_lineno = p->tokens[mark]->lineno; |
| 7712 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7713 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7714 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7715 | { // slice !',' |
| 7716 | expr_ty a; |
| 7717 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7718 | (a = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7719 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7720 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7721 | ) |
| 7722 | { |
| 7723 | res = a; |
| 7724 | if (res == NULL && PyErr_Occurred()) { |
| 7725 | p->error_indicator = 1; |
| 7726 | return NULL; |
| 7727 | } |
| 7728 | goto done; |
| 7729 | } |
| 7730 | p->mark = mark; |
| 7731 | } |
| 7732 | { // ','.slice+ ','? |
| 7733 | asdl_seq * a; |
| 7734 | void *opt_var; |
| 7735 | UNUSED(opt_var); // Silence compiler warnings |
| 7736 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7737 | (a = _gather_93_rule(p)) // ','.slice+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7738 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7739 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7740 | ) |
| 7741 | { |
| 7742 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7743 | if (token == NULL) { |
| 7744 | return NULL; |
| 7745 | } |
| 7746 | int end_lineno = token->end_lineno; |
| 7747 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7748 | int end_col_offset = token->end_col_offset; |
| 7749 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7750 | res = _Py_Tuple ( a , Load , EXTRA ); |
| 7751 | if (res == NULL && PyErr_Occurred()) { |
| 7752 | p->error_indicator = 1; |
| 7753 | return NULL; |
| 7754 | } |
| 7755 | goto done; |
| 7756 | } |
| 7757 | p->mark = mark; |
| 7758 | } |
| 7759 | res = NULL; |
| 7760 | done: |
| 7761 | return res; |
| 7762 | } |
| 7763 | |
| 7764 | // slice: expression? ':' expression? [':' expression?] | expression |
| 7765 | static expr_ty |
| 7766 | slice_rule(Parser *p) |
| 7767 | { |
| 7768 | if (p->error_indicator) { |
| 7769 | return NULL; |
| 7770 | } |
| 7771 | expr_ty res = NULL; |
| 7772 | int mark = p->mark; |
| 7773 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7774 | p->error_indicator = 1; |
| 7775 | return NULL; |
| 7776 | } |
| 7777 | int start_lineno = p->tokens[mark]->lineno; |
| 7778 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7779 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7780 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7781 | { // expression? ':' expression? [':' expression?] |
| 7782 | void *a; |
| 7783 | void *b; |
| 7784 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7785 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7786 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7787 | (a = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7788 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7789 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7790 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7791 | (b = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7792 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7793 | (c = _tmp_95_rule(p), 1) // [':' expression?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7794 | ) |
| 7795 | { |
| 7796 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7797 | if (token == NULL) { |
| 7798 | return NULL; |
| 7799 | } |
| 7800 | int end_lineno = token->end_lineno; |
| 7801 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7802 | int end_col_offset = token->end_col_offset; |
| 7803 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7804 | res = _Py_Slice ( a , b , c , EXTRA ); |
| 7805 | if (res == NULL && PyErr_Occurred()) { |
| 7806 | p->error_indicator = 1; |
| 7807 | return NULL; |
| 7808 | } |
| 7809 | goto done; |
| 7810 | } |
| 7811 | p->mark = mark; |
| 7812 | } |
| 7813 | { // expression |
| 7814 | expr_ty a; |
| 7815 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7816 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7817 | ) |
| 7818 | { |
| 7819 | res = a; |
| 7820 | if (res == NULL && PyErr_Occurred()) { |
| 7821 | p->error_indicator = 1; |
| 7822 | return NULL; |
| 7823 | } |
| 7824 | goto done; |
| 7825 | } |
| 7826 | p->mark = mark; |
| 7827 | } |
| 7828 | res = NULL; |
| 7829 | done: |
| 7830 | return res; |
| 7831 | } |
| 7832 | |
| 7833 | // atom: |
| 7834 | // | NAME |
| 7835 | // | 'True' |
| 7836 | // | 'False' |
| 7837 | // | 'None' |
| 7838 | // | '__new_parser__' |
| 7839 | // | &STRING strings |
| 7840 | // | NUMBER |
| 7841 | // | &'(' (tuple | group | genexp) |
| 7842 | // | &'[' (list | listcomp) |
| 7843 | // | &'{' (dict | set | dictcomp | setcomp) |
| 7844 | // | '...' |
| 7845 | static expr_ty |
| 7846 | atom_rule(Parser *p) |
| 7847 | { |
| 7848 | if (p->error_indicator) { |
| 7849 | return NULL; |
| 7850 | } |
| 7851 | expr_ty res = NULL; |
| 7852 | int mark = p->mark; |
| 7853 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7854 | p->error_indicator = 1; |
| 7855 | return NULL; |
| 7856 | } |
| 7857 | int start_lineno = p->tokens[mark]->lineno; |
| 7858 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7859 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7860 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7861 | { // NAME |
| 7862 | expr_ty name_var; |
| 7863 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7864 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7865 | ) |
| 7866 | { |
| 7867 | res = name_var; |
| 7868 | goto done; |
| 7869 | } |
| 7870 | p->mark = mark; |
| 7871 | } |
| 7872 | { // 'True' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7873 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7874 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7875 | (keyword = _PyPegen_expect_token(p, 527)) // token='True' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7876 | ) |
| 7877 | { |
| 7878 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7879 | if (token == NULL) { |
| 7880 | return NULL; |
| 7881 | } |
| 7882 | int end_lineno = token->end_lineno; |
| 7883 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7884 | int end_col_offset = token->end_col_offset; |
| 7885 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7886 | res = _Py_Constant ( Py_True , NULL , EXTRA ); |
| 7887 | if (res == NULL && PyErr_Occurred()) { |
| 7888 | p->error_indicator = 1; |
| 7889 | return NULL; |
| 7890 | } |
| 7891 | goto done; |
| 7892 | } |
| 7893 | p->mark = mark; |
| 7894 | } |
| 7895 | { // 'False' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7896 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7897 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7898 | (keyword = _PyPegen_expect_token(p, 528)) // token='False' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7899 | ) |
| 7900 | { |
| 7901 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7902 | if (token == NULL) { |
| 7903 | return NULL; |
| 7904 | } |
| 7905 | int end_lineno = token->end_lineno; |
| 7906 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7907 | int end_col_offset = token->end_col_offset; |
| 7908 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7909 | res = _Py_Constant ( Py_False , NULL , EXTRA ); |
| 7910 | if (res == NULL && PyErr_Occurred()) { |
| 7911 | p->error_indicator = 1; |
| 7912 | return NULL; |
| 7913 | } |
| 7914 | goto done; |
| 7915 | } |
| 7916 | p->mark = mark; |
| 7917 | } |
| 7918 | { // 'None' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7919 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7920 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7921 | (keyword = _PyPegen_expect_token(p, 529)) // token='None' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7922 | ) |
| 7923 | { |
| 7924 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7925 | if (token == NULL) { |
| 7926 | return NULL; |
| 7927 | } |
| 7928 | int end_lineno = token->end_lineno; |
| 7929 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7930 | int end_col_offset = token->end_col_offset; |
| 7931 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7932 | res = _Py_Constant ( Py_None , NULL , EXTRA ); |
| 7933 | if (res == NULL && PyErr_Occurred()) { |
| 7934 | p->error_indicator = 1; |
| 7935 | return NULL; |
| 7936 | } |
| 7937 | goto done; |
| 7938 | } |
| 7939 | p->mark = mark; |
| 7940 | } |
| 7941 | { // '__new_parser__' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7942 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7943 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7944 | (keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7945 | ) |
| 7946 | { |
| 7947 | res = RAISE_SYNTAX_ERROR ( "You found it!" ); |
| 7948 | if (res == NULL && PyErr_Occurred()) { |
| 7949 | p->error_indicator = 1; |
| 7950 | return NULL; |
| 7951 | } |
| 7952 | goto done; |
| 7953 | } |
| 7954 | p->mark = mark; |
| 7955 | } |
| 7956 | { // &STRING strings |
| 7957 | expr_ty strings_var; |
| 7958 | if ( |
| 7959 | _PyPegen_lookahead(1, _PyPegen_string_token, p) |
| 7960 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7961 | (strings_var = strings_rule(p)) // strings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7962 | ) |
| 7963 | { |
| 7964 | res = strings_var; |
| 7965 | goto done; |
| 7966 | } |
| 7967 | p->mark = mark; |
| 7968 | } |
| 7969 | { // NUMBER |
| 7970 | expr_ty number_var; |
| 7971 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7972 | (number_var = _PyPegen_number_token(p)) // NUMBER |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7973 | ) |
| 7974 | { |
| 7975 | res = number_var; |
| 7976 | goto done; |
| 7977 | } |
| 7978 | p->mark = mark; |
| 7979 | } |
| 7980 | { // &'(' (tuple | group | genexp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7981 | void *_tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7982 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7983 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7984 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7985 | (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7986 | ) |
| 7987 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7988 | res = _tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7989 | goto done; |
| 7990 | } |
| 7991 | p->mark = mark; |
| 7992 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7993 | { // &'[' (list | listcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7994 | void *_tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7995 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7996 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7997 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 7998 | (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7999 | ) |
| 8000 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8001 | res = _tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8002 | goto done; |
| 8003 | } |
| 8004 | p->mark = mark; |
| 8005 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8006 | { // &'{' (dict | set | dictcomp | setcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8007 | void *_tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8008 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8009 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8010 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8011 | (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8012 | ) |
| 8013 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8014 | res = _tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8015 | goto done; |
| 8016 | } |
| 8017 | p->mark = mark; |
| 8018 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8019 | { // '...' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8020 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8021 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8022 | (literal = _PyPegen_expect_token(p, 52)) // token='...' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8023 | ) |
| 8024 | { |
| 8025 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8026 | if (token == NULL) { |
| 8027 | return NULL; |
| 8028 | } |
| 8029 | int end_lineno = token->end_lineno; |
| 8030 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8031 | int end_col_offset = token->end_col_offset; |
| 8032 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8033 | res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); |
| 8034 | if (res == NULL && PyErr_Occurred()) { |
| 8035 | p->error_indicator = 1; |
| 8036 | return NULL; |
| 8037 | } |
| 8038 | goto done; |
| 8039 | } |
| 8040 | p->mark = mark; |
| 8041 | } |
| 8042 | res = NULL; |
| 8043 | done: |
| 8044 | return res; |
| 8045 | } |
| 8046 | |
| 8047 | // strings: STRING+ |
| 8048 | static expr_ty |
| 8049 | strings_rule(Parser *p) |
| 8050 | { |
| 8051 | if (p->error_indicator) { |
| 8052 | return NULL; |
| 8053 | } |
| 8054 | expr_ty res = NULL; |
| 8055 | if (_PyPegen_is_memoized(p, strings_type, &res)) |
| 8056 | return res; |
| 8057 | int mark = p->mark; |
| 8058 | { // STRING+ |
| 8059 | asdl_seq * a; |
| 8060 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8061 | (a = _loop1_99_rule(p)) // STRING+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8062 | ) |
| 8063 | { |
| 8064 | res = _PyPegen_concatenate_strings ( p , a ); |
| 8065 | if (res == NULL && PyErr_Occurred()) { |
| 8066 | p->error_indicator = 1; |
| 8067 | return NULL; |
| 8068 | } |
| 8069 | goto done; |
| 8070 | } |
| 8071 | p->mark = mark; |
| 8072 | } |
| 8073 | res = NULL; |
| 8074 | done: |
| 8075 | _PyPegen_insert_memo(p, mark, strings_type, res); |
| 8076 | return res; |
| 8077 | } |
| 8078 | |
| 8079 | // list: '[' star_named_expressions? ']' |
| 8080 | static expr_ty |
| 8081 | list_rule(Parser *p) |
| 8082 | { |
| 8083 | if (p->error_indicator) { |
| 8084 | return NULL; |
| 8085 | } |
| 8086 | expr_ty res = NULL; |
| 8087 | int mark = p->mark; |
| 8088 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8089 | p->error_indicator = 1; |
| 8090 | return NULL; |
| 8091 | } |
| 8092 | int start_lineno = p->tokens[mark]->lineno; |
| 8093 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8094 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8095 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8096 | { // '[' star_named_expressions? ']' |
| 8097 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8098 | Token * literal; |
| 8099 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8100 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8101 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8102 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8103 | (a = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8104 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8105 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8106 | ) |
| 8107 | { |
| 8108 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8109 | if (token == NULL) { |
| 8110 | return NULL; |
| 8111 | } |
| 8112 | int end_lineno = token->end_lineno; |
| 8113 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8114 | int end_col_offset = token->end_col_offset; |
| 8115 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8116 | res = _Py_List ( a , Load , EXTRA ); |
| 8117 | if (res == NULL && PyErr_Occurred()) { |
| 8118 | p->error_indicator = 1; |
| 8119 | return NULL; |
| 8120 | } |
| 8121 | goto done; |
| 8122 | } |
| 8123 | p->mark = mark; |
| 8124 | } |
| 8125 | res = NULL; |
| 8126 | done: |
| 8127 | return res; |
| 8128 | } |
| 8129 | |
| 8130 | // listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension |
| 8131 | static expr_ty |
| 8132 | listcomp_rule(Parser *p) |
| 8133 | { |
| 8134 | if (p->error_indicator) { |
| 8135 | return NULL; |
| 8136 | } |
| 8137 | expr_ty res = NULL; |
| 8138 | int mark = p->mark; |
| 8139 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8140 | p->error_indicator = 1; |
| 8141 | return NULL; |
| 8142 | } |
| 8143 | int start_lineno = p->tokens[mark]->lineno; |
| 8144 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8145 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8146 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8147 | { // '[' named_expression for_if_clauses ']' |
| 8148 | expr_ty a; |
| 8149 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8150 | Token * literal; |
| 8151 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8152 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8153 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8154 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8155 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8156 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8157 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8158 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8159 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8160 | ) |
| 8161 | { |
| 8162 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8163 | if (token == NULL) { |
| 8164 | return NULL; |
| 8165 | } |
| 8166 | int end_lineno = token->end_lineno; |
| 8167 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8168 | int end_col_offset = token->end_col_offset; |
| 8169 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8170 | res = _Py_ListComp ( a , b , EXTRA ); |
| 8171 | if (res == NULL && PyErr_Occurred()) { |
| 8172 | p->error_indicator = 1; |
| 8173 | return NULL; |
| 8174 | } |
| 8175 | goto done; |
| 8176 | } |
| 8177 | p->mark = mark; |
| 8178 | } |
| 8179 | { // invalid_comprehension |
| 8180 | void *invalid_comprehension_var; |
| 8181 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8182 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8183 | ) |
| 8184 | { |
| 8185 | res = invalid_comprehension_var; |
| 8186 | goto done; |
| 8187 | } |
| 8188 | p->mark = mark; |
| 8189 | } |
| 8190 | res = NULL; |
| 8191 | done: |
| 8192 | return res; |
| 8193 | } |
| 8194 | |
| 8195 | // tuple: '(' [star_named_expression ',' star_named_expressions?] ')' |
| 8196 | static expr_ty |
| 8197 | tuple_rule(Parser *p) |
| 8198 | { |
| 8199 | if (p->error_indicator) { |
| 8200 | return NULL; |
| 8201 | } |
| 8202 | expr_ty res = NULL; |
| 8203 | int mark = p->mark; |
| 8204 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8205 | p->error_indicator = 1; |
| 8206 | return NULL; |
| 8207 | } |
| 8208 | int start_lineno = p->tokens[mark]->lineno; |
| 8209 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8210 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8211 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8212 | { // '(' [star_named_expression ',' star_named_expressions?] ')' |
| 8213 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8214 | Token * literal; |
| 8215 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8216 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8217 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8218 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8219 | (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8220 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8221 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8222 | ) |
| 8223 | { |
| 8224 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8225 | if (token == NULL) { |
| 8226 | return NULL; |
| 8227 | } |
| 8228 | int end_lineno = token->end_lineno; |
| 8229 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8230 | int end_col_offset = token->end_col_offset; |
| 8231 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8232 | res = _Py_Tuple ( a , Load , EXTRA ); |
| 8233 | if (res == NULL && PyErr_Occurred()) { |
| 8234 | p->error_indicator = 1; |
| 8235 | return NULL; |
| 8236 | } |
| 8237 | goto done; |
| 8238 | } |
| 8239 | p->mark = mark; |
| 8240 | } |
| 8241 | res = NULL; |
| 8242 | done: |
| 8243 | return res; |
| 8244 | } |
| 8245 | |
| 8246 | // group: '(' (yield_expr | named_expression) ')' |
| 8247 | static expr_ty |
| 8248 | group_rule(Parser *p) |
| 8249 | { |
| 8250 | if (p->error_indicator) { |
| 8251 | return NULL; |
| 8252 | } |
| 8253 | expr_ty res = NULL; |
| 8254 | int mark = p->mark; |
| 8255 | { // '(' (yield_expr | named_expression) ')' |
| 8256 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8257 | Token * literal; |
| 8258 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8259 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8260 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8261 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8262 | (a = _tmp_101_rule(p)) // yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8263 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8264 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8265 | ) |
| 8266 | { |
| 8267 | res = a; |
| 8268 | if (res == NULL && PyErr_Occurred()) { |
| 8269 | p->error_indicator = 1; |
| 8270 | return NULL; |
| 8271 | } |
| 8272 | goto done; |
| 8273 | } |
| 8274 | p->mark = mark; |
| 8275 | } |
| 8276 | res = NULL; |
| 8277 | done: |
| 8278 | return res; |
| 8279 | } |
| 8280 | |
| 8281 | // genexp: '(' expression for_if_clauses ')' | invalid_comprehension |
| 8282 | static expr_ty |
| 8283 | genexp_rule(Parser *p) |
| 8284 | { |
| 8285 | if (p->error_indicator) { |
| 8286 | return NULL; |
| 8287 | } |
| 8288 | expr_ty res = NULL; |
| 8289 | int mark = p->mark; |
| 8290 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8291 | p->error_indicator = 1; |
| 8292 | return NULL; |
| 8293 | } |
| 8294 | int start_lineno = p->tokens[mark]->lineno; |
| 8295 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8296 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8297 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8298 | { // '(' expression for_if_clauses ')' |
| 8299 | expr_ty a; |
| 8300 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8301 | Token * literal; |
| 8302 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8303 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8304 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8305 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8306 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8307 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8308 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8309 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8310 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8311 | ) |
| 8312 | { |
| 8313 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8314 | if (token == NULL) { |
| 8315 | return NULL; |
| 8316 | } |
| 8317 | int end_lineno = token->end_lineno; |
| 8318 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8319 | int end_col_offset = token->end_col_offset; |
| 8320 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8321 | res = _Py_GeneratorExp ( a , b , EXTRA ); |
| 8322 | if (res == NULL && PyErr_Occurred()) { |
| 8323 | p->error_indicator = 1; |
| 8324 | return NULL; |
| 8325 | } |
| 8326 | goto done; |
| 8327 | } |
| 8328 | p->mark = mark; |
| 8329 | } |
| 8330 | { // invalid_comprehension |
| 8331 | void *invalid_comprehension_var; |
| 8332 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8333 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8334 | ) |
| 8335 | { |
| 8336 | res = invalid_comprehension_var; |
| 8337 | goto done; |
| 8338 | } |
| 8339 | p->mark = mark; |
| 8340 | } |
| 8341 | res = NULL; |
| 8342 | done: |
| 8343 | return res; |
| 8344 | } |
| 8345 | |
| 8346 | // set: '{' expressions_list '}' |
| 8347 | static expr_ty |
| 8348 | set_rule(Parser *p) |
| 8349 | { |
| 8350 | if (p->error_indicator) { |
| 8351 | return NULL; |
| 8352 | } |
| 8353 | expr_ty res = NULL; |
| 8354 | int mark = p->mark; |
| 8355 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8356 | p->error_indicator = 1; |
| 8357 | return NULL; |
| 8358 | } |
| 8359 | int start_lineno = p->tokens[mark]->lineno; |
| 8360 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8361 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8362 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8363 | { // '{' expressions_list '}' |
| 8364 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8365 | Token * literal; |
| 8366 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8367 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8368 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8369 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8370 | (a = expressions_list_rule(p)) // expressions_list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8371 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8372 | (literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8373 | ) |
| 8374 | { |
| 8375 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8376 | if (token == NULL) { |
| 8377 | return NULL; |
| 8378 | } |
| 8379 | int end_lineno = token->end_lineno; |
| 8380 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8381 | int end_col_offset = token->end_col_offset; |
| 8382 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8383 | res = _Py_Set ( a , EXTRA ); |
| 8384 | if (res == NULL && PyErr_Occurred()) { |
| 8385 | p->error_indicator = 1; |
| 8386 | return NULL; |
| 8387 | } |
| 8388 | goto done; |
| 8389 | } |
| 8390 | p->mark = mark; |
| 8391 | } |
| 8392 | res = NULL; |
| 8393 | done: |
| 8394 | return res; |
| 8395 | } |
| 8396 | |
| 8397 | // setcomp: '{' expression for_if_clauses '}' | invalid_comprehension |
| 8398 | static expr_ty |
| 8399 | setcomp_rule(Parser *p) |
| 8400 | { |
| 8401 | if (p->error_indicator) { |
| 8402 | return NULL; |
| 8403 | } |
| 8404 | expr_ty res = NULL; |
| 8405 | int mark = p->mark; |
| 8406 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8407 | p->error_indicator = 1; |
| 8408 | return NULL; |
| 8409 | } |
| 8410 | int start_lineno = p->tokens[mark]->lineno; |
| 8411 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8412 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8413 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8414 | { // '{' expression for_if_clauses '}' |
| 8415 | expr_ty a; |
| 8416 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8417 | Token * literal; |
| 8418 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8419 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8420 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8421 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8422 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8423 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8424 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8425 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8426 | (literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8427 | ) |
| 8428 | { |
| 8429 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8430 | if (token == NULL) { |
| 8431 | return NULL; |
| 8432 | } |
| 8433 | int end_lineno = token->end_lineno; |
| 8434 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8435 | int end_col_offset = token->end_col_offset; |
| 8436 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8437 | res = _Py_SetComp ( a , b , EXTRA ); |
| 8438 | if (res == NULL && PyErr_Occurred()) { |
| 8439 | p->error_indicator = 1; |
| 8440 | return NULL; |
| 8441 | } |
| 8442 | goto done; |
| 8443 | } |
| 8444 | p->mark = mark; |
| 8445 | } |
| 8446 | { // invalid_comprehension |
| 8447 | void *invalid_comprehension_var; |
| 8448 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8449 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8450 | ) |
| 8451 | { |
| 8452 | res = invalid_comprehension_var; |
| 8453 | goto done; |
| 8454 | } |
| 8455 | p->mark = mark; |
| 8456 | } |
| 8457 | res = NULL; |
| 8458 | done: |
| 8459 | return res; |
| 8460 | } |
| 8461 | |
| 8462 | // dict: '{' kvpairs? '}' |
| 8463 | static expr_ty |
| 8464 | dict_rule(Parser *p) |
| 8465 | { |
| 8466 | if (p->error_indicator) { |
| 8467 | return NULL; |
| 8468 | } |
| 8469 | expr_ty res = NULL; |
| 8470 | int mark = p->mark; |
| 8471 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8472 | p->error_indicator = 1; |
| 8473 | return NULL; |
| 8474 | } |
| 8475 | int start_lineno = p->tokens[mark]->lineno; |
| 8476 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8477 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8478 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8479 | { // '{' kvpairs? '}' |
| 8480 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8481 | Token * literal; |
| 8482 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8483 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8484 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8485 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8486 | (a = kvpairs_rule(p), 1) // kvpairs? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8487 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8488 | (literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8489 | ) |
| 8490 | { |
| 8491 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8492 | if (token == NULL) { |
| 8493 | return NULL; |
| 8494 | } |
| 8495 | int end_lineno = token->end_lineno; |
| 8496 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8497 | int end_col_offset = token->end_col_offset; |
| 8498 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8499 | res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); |
| 8500 | if (res == NULL && PyErr_Occurred()) { |
| 8501 | p->error_indicator = 1; |
| 8502 | return NULL; |
| 8503 | } |
| 8504 | goto done; |
| 8505 | } |
| 8506 | p->mark = mark; |
| 8507 | } |
| 8508 | res = NULL; |
| 8509 | done: |
| 8510 | return res; |
| 8511 | } |
| 8512 | |
| 8513 | // dictcomp: '{' kvpair for_if_clauses '}' |
| 8514 | static expr_ty |
| 8515 | dictcomp_rule(Parser *p) |
| 8516 | { |
| 8517 | if (p->error_indicator) { |
| 8518 | return NULL; |
| 8519 | } |
| 8520 | expr_ty res = NULL; |
| 8521 | int mark = p->mark; |
| 8522 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8523 | p->error_indicator = 1; |
| 8524 | return NULL; |
| 8525 | } |
| 8526 | int start_lineno = p->tokens[mark]->lineno; |
| 8527 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8528 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8529 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8530 | { // '{' kvpair for_if_clauses '}' |
| 8531 | KeyValuePair* a; |
| 8532 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8533 | Token * literal; |
| 8534 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8535 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8536 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8537 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8538 | (a = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8539 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8540 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8541 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8542 | (literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8543 | ) |
| 8544 | { |
| 8545 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8546 | if (token == NULL) { |
| 8547 | return NULL; |
| 8548 | } |
| 8549 | int end_lineno = token->end_lineno; |
| 8550 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8551 | int end_col_offset = token->end_col_offset; |
| 8552 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8553 | res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); |
| 8554 | if (res == NULL && PyErr_Occurred()) { |
| 8555 | p->error_indicator = 1; |
| 8556 | return NULL; |
| 8557 | } |
| 8558 | goto done; |
| 8559 | } |
| 8560 | p->mark = mark; |
| 8561 | } |
| 8562 | res = NULL; |
| 8563 | done: |
| 8564 | return res; |
| 8565 | } |
| 8566 | |
| 8567 | // kvpairs: ','.kvpair+ ','? |
| 8568 | static asdl_seq* |
| 8569 | kvpairs_rule(Parser *p) |
| 8570 | { |
| 8571 | if (p->error_indicator) { |
| 8572 | return NULL; |
| 8573 | } |
| 8574 | asdl_seq* res = NULL; |
| 8575 | int mark = p->mark; |
| 8576 | { // ','.kvpair+ ','? |
| 8577 | asdl_seq * a; |
| 8578 | void *opt_var; |
| 8579 | UNUSED(opt_var); // Silence compiler warnings |
| 8580 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8581 | (a = _gather_102_rule(p)) // ','.kvpair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8582 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8583 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8584 | ) |
| 8585 | { |
| 8586 | res = a; |
| 8587 | if (res == NULL && PyErr_Occurred()) { |
| 8588 | p->error_indicator = 1; |
| 8589 | return NULL; |
| 8590 | } |
| 8591 | goto done; |
| 8592 | } |
| 8593 | p->mark = mark; |
| 8594 | } |
| 8595 | res = NULL; |
| 8596 | done: |
| 8597 | return res; |
| 8598 | } |
| 8599 | |
| 8600 | // kvpair: '**' bitwise_or | expression ':' expression |
| 8601 | static KeyValuePair* |
| 8602 | kvpair_rule(Parser *p) |
| 8603 | { |
| 8604 | if (p->error_indicator) { |
| 8605 | return NULL; |
| 8606 | } |
| 8607 | KeyValuePair* res = NULL; |
| 8608 | int mark = p->mark; |
| 8609 | { // '**' bitwise_or |
| 8610 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8611 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8612 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8613 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8614 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8615 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8616 | ) |
| 8617 | { |
| 8618 | res = _PyPegen_key_value_pair ( p , NULL , a ); |
| 8619 | if (res == NULL && PyErr_Occurred()) { |
| 8620 | p->error_indicator = 1; |
| 8621 | return NULL; |
| 8622 | } |
| 8623 | goto done; |
| 8624 | } |
| 8625 | p->mark = mark; |
| 8626 | } |
| 8627 | { // expression ':' expression |
| 8628 | expr_ty a; |
| 8629 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8630 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8631 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8632 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8633 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8634 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8635 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8636 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8637 | ) |
| 8638 | { |
| 8639 | res = _PyPegen_key_value_pair ( p , a , b ); |
| 8640 | if (res == NULL && PyErr_Occurred()) { |
| 8641 | p->error_indicator = 1; |
| 8642 | return NULL; |
| 8643 | } |
| 8644 | goto done; |
| 8645 | } |
| 8646 | p->mark = mark; |
| 8647 | } |
| 8648 | res = NULL; |
| 8649 | done: |
| 8650 | return res; |
| 8651 | } |
| 8652 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8653 | // for_if_clauses: for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8654 | static asdl_seq* |
| 8655 | for_if_clauses_rule(Parser *p) |
| 8656 | { |
| 8657 | if (p->error_indicator) { |
| 8658 | return NULL; |
| 8659 | } |
| 8660 | asdl_seq* res = NULL; |
| 8661 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8662 | { // for_if_clause+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8663 | asdl_seq * _loop1_104_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8664 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8665 | (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8666 | ) |
| 8667 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8668 | res = _loop1_104_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8669 | goto done; |
| 8670 | } |
| 8671 | p->mark = mark; |
| 8672 | } |
| 8673 | res = NULL; |
| 8674 | done: |
| 8675 | return res; |
| 8676 | } |
| 8677 | |
| 8678 | // for_if_clause: |
| 8679 | // | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8680 | // | 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8681 | static comprehension_ty |
| 8682 | for_if_clause_rule(Parser *p) |
| 8683 | { |
| 8684 | if (p->error_indicator) { |
| 8685 | return NULL; |
| 8686 | } |
| 8687 | comprehension_ty res = NULL; |
| 8688 | int mark = p->mark; |
| 8689 | { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8690 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8691 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8692 | expr_ty b; |
| 8693 | asdl_seq * c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8694 | Token * keyword; |
| 8695 | Token * keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8696 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8697 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8698 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8699 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8700 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8701 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8702 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8703 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8704 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8705 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8706 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8707 | (c = _loop0_105_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8708 | ) |
| 8709 | { |
| 8710 | res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); |
| 8711 | if (res == NULL && PyErr_Occurred()) { |
| 8712 | p->error_indicator = 1; |
| 8713 | return NULL; |
| 8714 | } |
| 8715 | goto done; |
| 8716 | } |
| 8717 | p->mark = mark; |
| 8718 | } |
| 8719 | { // 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8720 | expr_ty a; |
| 8721 | expr_ty b; |
| 8722 | asdl_seq * c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8723 | Token * keyword; |
| 8724 | Token * keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8725 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8726 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8727 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8728 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8729 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8730 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8731 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8732 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8733 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8734 | (c = _loop0_106_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8735 | ) |
| 8736 | { |
| 8737 | res = _Py_comprehension ( a , b , c , 0 , p -> arena ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8738 | if (res == NULL && PyErr_Occurred()) { |
| 8739 | p->error_indicator = 1; |
| 8740 | return NULL; |
| 8741 | } |
| 8742 | goto done; |
| 8743 | } |
| 8744 | p->mark = mark; |
| 8745 | } |
| 8746 | res = NULL; |
| 8747 | done: |
| 8748 | return res; |
| 8749 | } |
| 8750 | |
| 8751 | // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? |
| 8752 | static expr_ty |
| 8753 | yield_expr_rule(Parser *p) |
| 8754 | { |
| 8755 | if (p->error_indicator) { |
| 8756 | return NULL; |
| 8757 | } |
| 8758 | expr_ty res = NULL; |
| 8759 | int mark = p->mark; |
| 8760 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8761 | p->error_indicator = 1; |
| 8762 | return NULL; |
| 8763 | } |
| 8764 | int start_lineno = p->tokens[mark]->lineno; |
| 8765 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8766 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8767 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8768 | { // 'yield' 'from' expression |
| 8769 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8770 | Token * keyword; |
| 8771 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8772 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8773 | (keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8774 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8775 | (keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8776 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8777 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8778 | ) |
| 8779 | { |
| 8780 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8781 | if (token == NULL) { |
| 8782 | return NULL; |
| 8783 | } |
| 8784 | int end_lineno = token->end_lineno; |
| 8785 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8786 | int end_col_offset = token->end_col_offset; |
| 8787 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8788 | res = _Py_YieldFrom ( a , EXTRA ); |
| 8789 | if (res == NULL && PyErr_Occurred()) { |
| 8790 | p->error_indicator = 1; |
| 8791 | return NULL; |
| 8792 | } |
| 8793 | goto done; |
| 8794 | } |
| 8795 | p->mark = mark; |
| 8796 | } |
| 8797 | { // 'yield' star_expressions? |
| 8798 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8799 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8800 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8801 | (keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8802 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8803 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8804 | ) |
| 8805 | { |
| 8806 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8807 | if (token == NULL) { |
| 8808 | return NULL; |
| 8809 | } |
| 8810 | int end_lineno = token->end_lineno; |
| 8811 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8812 | int end_col_offset = token->end_col_offset; |
| 8813 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8814 | res = _Py_Yield ( a , EXTRA ); |
| 8815 | if (res == NULL && PyErr_Occurred()) { |
| 8816 | p->error_indicator = 1; |
| 8817 | return NULL; |
| 8818 | } |
| 8819 | goto done; |
| 8820 | } |
| 8821 | p->mark = mark; |
| 8822 | } |
| 8823 | res = NULL; |
| 8824 | done: |
| 8825 | return res; |
| 8826 | } |
| 8827 | |
| 8828 | // arguments: args ','? &')' | incorrect_arguments |
| 8829 | static expr_ty |
| 8830 | arguments_rule(Parser *p) |
| 8831 | { |
| 8832 | if (p->error_indicator) { |
| 8833 | return NULL; |
| 8834 | } |
| 8835 | expr_ty res = NULL; |
| 8836 | if (_PyPegen_is_memoized(p, arguments_type, &res)) |
| 8837 | return res; |
| 8838 | int mark = p->mark; |
| 8839 | { // args ','? &')' |
| 8840 | expr_ty a; |
| 8841 | void *opt_var; |
| 8842 | UNUSED(opt_var); // Silence compiler warnings |
| 8843 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8844 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8845 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8846 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8847 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8848 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8849 | ) |
| 8850 | { |
| 8851 | res = a; |
| 8852 | if (res == NULL && PyErr_Occurred()) { |
| 8853 | p->error_indicator = 1; |
| 8854 | return NULL; |
| 8855 | } |
| 8856 | goto done; |
| 8857 | } |
| 8858 | p->mark = mark; |
| 8859 | } |
| 8860 | { // incorrect_arguments |
| 8861 | void *incorrect_arguments_var; |
| 8862 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8863 | (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8864 | ) |
| 8865 | { |
| 8866 | res = incorrect_arguments_var; |
| 8867 | goto done; |
| 8868 | } |
| 8869 | p->mark = mark; |
| 8870 | } |
| 8871 | res = NULL; |
| 8872 | done: |
| 8873 | _PyPegen_insert_memo(p, mark, arguments_type, res); |
| 8874 | return res; |
| 8875 | } |
| 8876 | |
| 8877 | // args: starred_expression [',' args] | kwargs | named_expression [',' args] |
| 8878 | static expr_ty |
| 8879 | args_rule(Parser *p) |
| 8880 | { |
| 8881 | if (p->error_indicator) { |
| 8882 | return NULL; |
| 8883 | } |
| 8884 | expr_ty res = NULL; |
| 8885 | int mark = p->mark; |
| 8886 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8887 | p->error_indicator = 1; |
| 8888 | return NULL; |
| 8889 | } |
| 8890 | int start_lineno = p->tokens[mark]->lineno; |
| 8891 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8892 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8893 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8894 | { // starred_expression [',' args] |
| 8895 | expr_ty a; |
| 8896 | void *b; |
| 8897 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8898 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8899 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8900 | (b = _tmp_107_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8901 | ) |
| 8902 | { |
| 8903 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8904 | if (token == NULL) { |
| 8905 | return NULL; |
| 8906 | } |
| 8907 | int end_lineno = token->end_lineno; |
| 8908 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8909 | int end_col_offset = token->end_col_offset; |
| 8910 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8911 | 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 ); |
| 8912 | if (res == NULL && PyErr_Occurred()) { |
| 8913 | p->error_indicator = 1; |
| 8914 | return NULL; |
| 8915 | } |
| 8916 | goto done; |
| 8917 | } |
| 8918 | p->mark = mark; |
| 8919 | } |
| 8920 | { // kwargs |
| 8921 | asdl_seq* a; |
| 8922 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8923 | (a = kwargs_rule(p)) // kwargs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8924 | ) |
| 8925 | { |
| 8926 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8927 | if (token == NULL) { |
| 8928 | return NULL; |
| 8929 | } |
| 8930 | int end_lineno = token->end_lineno; |
| 8931 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8932 | int end_col_offset = token->end_col_offset; |
| 8933 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8934 | 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 ); |
| 8935 | if (res == NULL && PyErr_Occurred()) { |
| 8936 | p->error_indicator = 1; |
| 8937 | return NULL; |
| 8938 | } |
| 8939 | goto done; |
| 8940 | } |
| 8941 | p->mark = mark; |
| 8942 | } |
| 8943 | { // named_expression [',' args] |
| 8944 | expr_ty a; |
| 8945 | void *b; |
| 8946 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8947 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8948 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8949 | (b = _tmp_108_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8950 | ) |
| 8951 | { |
| 8952 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8953 | if (token == NULL) { |
| 8954 | return NULL; |
| 8955 | } |
| 8956 | int end_lineno = token->end_lineno; |
| 8957 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8958 | int end_col_offset = token->end_col_offset; |
| 8959 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8960 | 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 ); |
| 8961 | if (res == NULL && PyErr_Occurred()) { |
| 8962 | p->error_indicator = 1; |
| 8963 | return NULL; |
| 8964 | } |
| 8965 | goto done; |
| 8966 | } |
| 8967 | p->mark = mark; |
| 8968 | } |
| 8969 | res = NULL; |
| 8970 | done: |
| 8971 | return res; |
| 8972 | } |
| 8973 | |
| 8974 | // kwargs: |
| 8975 | // | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 8976 | // | ','.kwarg_or_starred+ |
| 8977 | // | ','.kwarg_or_double_starred+ |
| 8978 | static asdl_seq* |
| 8979 | kwargs_rule(Parser *p) |
| 8980 | { |
| 8981 | if (p->error_indicator) { |
| 8982 | return NULL; |
| 8983 | } |
| 8984 | asdl_seq* res = NULL; |
| 8985 | int mark = p->mark; |
| 8986 | { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 8987 | asdl_seq * a; |
| 8988 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8989 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8990 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8991 | (a = _gather_109_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8992 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8993 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8994 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 8995 | (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8996 | ) |
| 8997 | { |
| 8998 | res = _PyPegen_join_sequences ( p , a , b ); |
| 8999 | if (res == NULL && PyErr_Occurred()) { |
| 9000 | p->error_indicator = 1; |
| 9001 | return NULL; |
| 9002 | } |
| 9003 | goto done; |
| 9004 | } |
| 9005 | p->mark = mark; |
| 9006 | } |
| 9007 | { // ','.kwarg_or_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9008 | asdl_seq * _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9009 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9010 | (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9011 | ) |
| 9012 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9013 | res = _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9014 | goto done; |
| 9015 | } |
| 9016 | p->mark = mark; |
| 9017 | } |
| 9018 | { // ','.kwarg_or_double_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9019 | asdl_seq * _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9020 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9021 | (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9022 | ) |
| 9023 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9024 | res = _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9025 | goto done; |
| 9026 | } |
| 9027 | p->mark = mark; |
| 9028 | } |
| 9029 | res = NULL; |
| 9030 | done: |
| 9031 | return res; |
| 9032 | } |
| 9033 | |
| 9034 | // starred_expression: '*' expression |
| 9035 | static expr_ty |
| 9036 | starred_expression_rule(Parser *p) |
| 9037 | { |
| 9038 | if (p->error_indicator) { |
| 9039 | return NULL; |
| 9040 | } |
| 9041 | expr_ty res = NULL; |
| 9042 | int mark = p->mark; |
| 9043 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9044 | p->error_indicator = 1; |
| 9045 | return NULL; |
| 9046 | } |
| 9047 | int start_lineno = p->tokens[mark]->lineno; |
| 9048 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9049 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9050 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9051 | { // '*' expression |
| 9052 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9053 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9054 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9055 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9056 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9057 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9058 | ) |
| 9059 | { |
| 9060 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9061 | if (token == NULL) { |
| 9062 | return NULL; |
| 9063 | } |
| 9064 | int end_lineno = token->end_lineno; |
| 9065 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9066 | int end_col_offset = token->end_col_offset; |
| 9067 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9068 | res = _Py_Starred ( a , Load , EXTRA ); |
| 9069 | if (res == NULL && PyErr_Occurred()) { |
| 9070 | p->error_indicator = 1; |
| 9071 | return NULL; |
| 9072 | } |
| 9073 | goto done; |
| 9074 | } |
| 9075 | p->mark = mark; |
| 9076 | } |
| 9077 | res = NULL; |
| 9078 | done: |
| 9079 | return res; |
| 9080 | } |
| 9081 | |
| 9082 | // kwarg_or_starred: NAME '=' expression | starred_expression |
| 9083 | static KeywordOrStarred* |
| 9084 | kwarg_or_starred_rule(Parser *p) |
| 9085 | { |
| 9086 | if (p->error_indicator) { |
| 9087 | return NULL; |
| 9088 | } |
| 9089 | KeywordOrStarred* res = NULL; |
| 9090 | int mark = p->mark; |
| 9091 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9092 | p->error_indicator = 1; |
| 9093 | return NULL; |
| 9094 | } |
| 9095 | int start_lineno = p->tokens[mark]->lineno; |
| 9096 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9097 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9098 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9099 | { // NAME '=' expression |
| 9100 | expr_ty a; |
| 9101 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9102 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9103 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9104 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9105 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9106 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9107 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9108 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9109 | ) |
| 9110 | { |
| 9111 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9112 | if (token == NULL) { |
| 9113 | return NULL; |
| 9114 | } |
| 9115 | int end_lineno = token->end_lineno; |
| 9116 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9117 | int end_col_offset = token->end_col_offset; |
| 9118 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9119 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9120 | if (res == NULL && PyErr_Occurred()) { |
| 9121 | p->error_indicator = 1; |
| 9122 | return NULL; |
| 9123 | } |
| 9124 | goto done; |
| 9125 | } |
| 9126 | p->mark = mark; |
| 9127 | } |
| 9128 | { // starred_expression |
| 9129 | expr_ty a; |
| 9130 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9131 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9132 | ) |
| 9133 | { |
| 9134 | res = _PyPegen_keyword_or_starred ( p , a , 0 ); |
| 9135 | if (res == NULL && PyErr_Occurred()) { |
| 9136 | p->error_indicator = 1; |
| 9137 | return NULL; |
| 9138 | } |
| 9139 | goto done; |
| 9140 | } |
| 9141 | p->mark = mark; |
| 9142 | } |
| 9143 | res = NULL; |
| 9144 | done: |
| 9145 | return res; |
| 9146 | } |
| 9147 | |
| 9148 | // kwarg_or_double_starred: NAME '=' expression | '**' expression |
| 9149 | static KeywordOrStarred* |
| 9150 | kwarg_or_double_starred_rule(Parser *p) |
| 9151 | { |
| 9152 | if (p->error_indicator) { |
| 9153 | return NULL; |
| 9154 | } |
| 9155 | KeywordOrStarred* res = NULL; |
| 9156 | int mark = p->mark; |
| 9157 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9158 | p->error_indicator = 1; |
| 9159 | return NULL; |
| 9160 | } |
| 9161 | int start_lineno = p->tokens[mark]->lineno; |
| 9162 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9163 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9164 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9165 | { // NAME '=' expression |
| 9166 | expr_ty a; |
| 9167 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9168 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9169 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9170 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9171 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9172 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9173 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9174 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9175 | ) |
| 9176 | { |
| 9177 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9178 | if (token == NULL) { |
| 9179 | return NULL; |
| 9180 | } |
| 9181 | int end_lineno = token->end_lineno; |
| 9182 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9183 | int end_col_offset = token->end_col_offset; |
| 9184 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9185 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9186 | if (res == NULL && PyErr_Occurred()) { |
| 9187 | p->error_indicator = 1; |
| 9188 | return NULL; |
| 9189 | } |
| 9190 | goto done; |
| 9191 | } |
| 9192 | p->mark = mark; |
| 9193 | } |
| 9194 | { // '**' expression |
| 9195 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9196 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9197 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9198 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9199 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9200 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9201 | ) |
| 9202 | { |
| 9203 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9204 | if (token == NULL) { |
| 9205 | return NULL; |
| 9206 | } |
| 9207 | int end_lineno = token->end_lineno; |
| 9208 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9209 | int end_col_offset = token->end_col_offset; |
| 9210 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9211 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); |
| 9212 | if (res == NULL && PyErr_Occurred()) { |
| 9213 | p->error_indicator = 1; |
| 9214 | return NULL; |
| 9215 | } |
| 9216 | goto done; |
| 9217 | } |
| 9218 | p->mark = mark; |
| 9219 | } |
| 9220 | res = NULL; |
| 9221 | done: |
| 9222 | return res; |
| 9223 | } |
| 9224 | |
| 9225 | // star_targets: star_target !',' | star_target ((',' star_target))* ','? |
| 9226 | static expr_ty |
| 9227 | star_targets_rule(Parser *p) |
| 9228 | { |
| 9229 | if (p->error_indicator) { |
| 9230 | return NULL; |
| 9231 | } |
| 9232 | expr_ty res = NULL; |
| 9233 | int mark = p->mark; |
| 9234 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9235 | p->error_indicator = 1; |
| 9236 | return NULL; |
| 9237 | } |
| 9238 | int start_lineno = p->tokens[mark]->lineno; |
| 9239 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9240 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9241 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9242 | { // star_target !',' |
| 9243 | expr_ty a; |
| 9244 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9245 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9246 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9247 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9248 | ) |
| 9249 | { |
| 9250 | res = a; |
| 9251 | if (res == NULL && PyErr_Occurred()) { |
| 9252 | p->error_indicator = 1; |
| 9253 | return NULL; |
| 9254 | } |
| 9255 | goto done; |
| 9256 | } |
| 9257 | p->mark = mark; |
| 9258 | } |
| 9259 | { // star_target ((',' star_target))* ','? |
| 9260 | expr_ty a; |
| 9261 | asdl_seq * b; |
| 9262 | void *opt_var; |
| 9263 | UNUSED(opt_var); // Silence compiler warnings |
| 9264 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9265 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9266 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9267 | (b = _loop0_117_rule(p)) // ((',' star_target))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9268 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9269 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9270 | ) |
| 9271 | { |
| 9272 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9273 | if (token == NULL) { |
| 9274 | return NULL; |
| 9275 | } |
| 9276 | int end_lineno = token->end_lineno; |
| 9277 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9278 | int end_col_offset = token->end_col_offset; |
| 9279 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9280 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); |
| 9281 | if (res == NULL && PyErr_Occurred()) { |
| 9282 | p->error_indicator = 1; |
| 9283 | return NULL; |
| 9284 | } |
| 9285 | goto done; |
| 9286 | } |
| 9287 | p->mark = mark; |
| 9288 | } |
| 9289 | res = NULL; |
| 9290 | done: |
| 9291 | return res; |
| 9292 | } |
| 9293 | |
| 9294 | // star_targets_seq: ','.star_target+ ','? |
| 9295 | static asdl_seq* |
| 9296 | star_targets_seq_rule(Parser *p) |
| 9297 | { |
| 9298 | if (p->error_indicator) { |
| 9299 | return NULL; |
| 9300 | } |
| 9301 | asdl_seq* res = NULL; |
| 9302 | int mark = p->mark; |
| 9303 | { // ','.star_target+ ','? |
| 9304 | asdl_seq * a; |
| 9305 | void *opt_var; |
| 9306 | UNUSED(opt_var); // Silence compiler warnings |
| 9307 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9308 | (a = _gather_118_rule(p)) // ','.star_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9309 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9310 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9311 | ) |
| 9312 | { |
| 9313 | res = a; |
| 9314 | if (res == NULL && PyErr_Occurred()) { |
| 9315 | p->error_indicator = 1; |
| 9316 | return NULL; |
| 9317 | } |
| 9318 | goto done; |
| 9319 | } |
| 9320 | p->mark = mark; |
| 9321 | } |
| 9322 | res = NULL; |
| 9323 | done: |
| 9324 | return res; |
| 9325 | } |
| 9326 | |
| 9327 | // star_target: |
| 9328 | // | '*' (!'*' star_target) |
| 9329 | // | t_primary '.' NAME !t_lookahead |
| 9330 | // | t_primary '[' slices ']' !t_lookahead |
| 9331 | // | star_atom |
| 9332 | static expr_ty |
| 9333 | star_target_rule(Parser *p) |
| 9334 | { |
| 9335 | if (p->error_indicator) { |
| 9336 | return NULL; |
| 9337 | } |
| 9338 | expr_ty res = NULL; |
| 9339 | if (_PyPegen_is_memoized(p, star_target_type, &res)) |
| 9340 | return res; |
| 9341 | int mark = p->mark; |
| 9342 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9343 | p->error_indicator = 1; |
| 9344 | return NULL; |
| 9345 | } |
| 9346 | int start_lineno = p->tokens[mark]->lineno; |
| 9347 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9348 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9349 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9350 | { // '*' (!'*' star_target) |
| 9351 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9352 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9353 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9354 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9355 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9356 | (a = _tmp_120_rule(p)) // !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9357 | ) |
| 9358 | { |
| 9359 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9360 | if (token == NULL) { |
| 9361 | return NULL; |
| 9362 | } |
| 9363 | int end_lineno = token->end_lineno; |
| 9364 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9365 | int end_col_offset = token->end_col_offset; |
| 9366 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9367 | res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); |
| 9368 | if (res == NULL && PyErr_Occurred()) { |
| 9369 | p->error_indicator = 1; |
| 9370 | return NULL; |
| 9371 | } |
| 9372 | goto done; |
| 9373 | } |
| 9374 | p->mark = mark; |
| 9375 | } |
| 9376 | { // t_primary '.' NAME !t_lookahead |
| 9377 | expr_ty a; |
| 9378 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9379 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9380 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9381 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9382 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9383 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9384 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9385 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9386 | && |
| 9387 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9388 | ) |
| 9389 | { |
| 9390 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9391 | if (token == NULL) { |
| 9392 | return NULL; |
| 9393 | } |
| 9394 | int end_lineno = token->end_lineno; |
| 9395 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9396 | int end_col_offset = token->end_col_offset; |
| 9397 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9398 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9399 | if (res == NULL && PyErr_Occurred()) { |
| 9400 | p->error_indicator = 1; |
| 9401 | return NULL; |
| 9402 | } |
| 9403 | goto done; |
| 9404 | } |
| 9405 | p->mark = mark; |
| 9406 | } |
| 9407 | { // t_primary '[' slices ']' !t_lookahead |
| 9408 | expr_ty a; |
| 9409 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9410 | Token * literal; |
| 9411 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9412 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9413 | (a = t_primary_rule(p)) // t_primary |
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 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9416 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9417 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9418 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9419 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9420 | && |
| 9421 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9422 | ) |
| 9423 | { |
| 9424 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9425 | if (token == NULL) { |
| 9426 | return NULL; |
| 9427 | } |
| 9428 | int end_lineno = token->end_lineno; |
| 9429 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9430 | int end_col_offset = token->end_col_offset; |
| 9431 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9432 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9433 | if (res == NULL && PyErr_Occurred()) { |
| 9434 | p->error_indicator = 1; |
| 9435 | return NULL; |
| 9436 | } |
| 9437 | goto done; |
| 9438 | } |
| 9439 | p->mark = mark; |
| 9440 | } |
| 9441 | { // star_atom |
| 9442 | expr_ty star_atom_var; |
| 9443 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9444 | (star_atom_var = star_atom_rule(p)) // star_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9445 | ) |
| 9446 | { |
| 9447 | res = star_atom_var; |
| 9448 | goto done; |
| 9449 | } |
| 9450 | p->mark = mark; |
| 9451 | } |
| 9452 | res = NULL; |
| 9453 | done: |
| 9454 | _PyPegen_insert_memo(p, mark, star_target_type, res); |
| 9455 | return res; |
| 9456 | } |
| 9457 | |
| 9458 | // star_atom: |
| 9459 | // | NAME |
| 9460 | // | '(' star_target ')' |
| 9461 | // | '(' star_targets_seq? ')' |
| 9462 | // | '[' star_targets_seq? ']' |
| 9463 | static expr_ty |
| 9464 | star_atom_rule(Parser *p) |
| 9465 | { |
| 9466 | if (p->error_indicator) { |
| 9467 | return NULL; |
| 9468 | } |
| 9469 | expr_ty res = NULL; |
| 9470 | int mark = p->mark; |
| 9471 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9472 | p->error_indicator = 1; |
| 9473 | return NULL; |
| 9474 | } |
| 9475 | int start_lineno = p->tokens[mark]->lineno; |
| 9476 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9477 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9478 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9479 | { // NAME |
| 9480 | expr_ty a; |
| 9481 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9482 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9483 | ) |
| 9484 | { |
| 9485 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9486 | if (res == NULL && PyErr_Occurred()) { |
| 9487 | p->error_indicator = 1; |
| 9488 | return NULL; |
| 9489 | } |
| 9490 | goto done; |
| 9491 | } |
| 9492 | p->mark = mark; |
| 9493 | } |
| 9494 | { // '(' star_target ')' |
| 9495 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9496 | Token * literal; |
| 9497 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9498 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9499 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9500 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9501 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9502 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9503 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9504 | ) |
| 9505 | { |
| 9506 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9507 | if (res == NULL && PyErr_Occurred()) { |
| 9508 | p->error_indicator = 1; |
| 9509 | return NULL; |
| 9510 | } |
| 9511 | goto done; |
| 9512 | } |
| 9513 | p->mark = mark; |
| 9514 | } |
| 9515 | { // '(' star_targets_seq? ')' |
| 9516 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9517 | Token * literal; |
| 9518 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9519 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9520 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9521 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9522 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9523 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9524 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9525 | ) |
| 9526 | { |
| 9527 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9528 | if (token == NULL) { |
| 9529 | return NULL; |
| 9530 | } |
| 9531 | int end_lineno = token->end_lineno; |
| 9532 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9533 | int end_col_offset = token->end_col_offset; |
| 9534 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9535 | res = _Py_Tuple ( a , Store , EXTRA ); |
| 9536 | if (res == NULL && PyErr_Occurred()) { |
| 9537 | p->error_indicator = 1; |
| 9538 | return NULL; |
| 9539 | } |
| 9540 | goto done; |
| 9541 | } |
| 9542 | p->mark = mark; |
| 9543 | } |
| 9544 | { // '[' star_targets_seq? ']' |
| 9545 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9546 | Token * literal; |
| 9547 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9548 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9549 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9550 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9551 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9552 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9553 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9554 | ) |
| 9555 | { |
| 9556 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9557 | if (token == NULL) { |
| 9558 | return NULL; |
| 9559 | } |
| 9560 | int end_lineno = token->end_lineno; |
| 9561 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9562 | int end_col_offset = token->end_col_offset; |
| 9563 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9564 | res = _Py_List ( a , Store , EXTRA ); |
| 9565 | if (res == NULL && PyErr_Occurred()) { |
| 9566 | p->error_indicator = 1; |
| 9567 | return NULL; |
| 9568 | } |
| 9569 | goto done; |
| 9570 | } |
| 9571 | p->mark = mark; |
| 9572 | } |
| 9573 | res = NULL; |
| 9574 | done: |
| 9575 | return res; |
| 9576 | } |
| 9577 | |
| 9578 | // inside_paren_ann_assign_target: |
| 9579 | // | ann_assign_subscript_attribute_target |
| 9580 | // | NAME |
| 9581 | // | '(' inside_paren_ann_assign_target ')' |
| 9582 | static expr_ty |
| 9583 | inside_paren_ann_assign_target_rule(Parser *p) |
| 9584 | { |
| 9585 | if (p->error_indicator) { |
| 9586 | return NULL; |
| 9587 | } |
| 9588 | expr_ty res = NULL; |
| 9589 | int mark = p->mark; |
| 9590 | { // ann_assign_subscript_attribute_target |
| 9591 | expr_ty ann_assign_subscript_attribute_target_var; |
| 9592 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9593 | (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] | 9594 | ) |
| 9595 | { |
| 9596 | res = ann_assign_subscript_attribute_target_var; |
| 9597 | goto done; |
| 9598 | } |
| 9599 | p->mark = mark; |
| 9600 | } |
| 9601 | { // NAME |
| 9602 | expr_ty a; |
| 9603 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9604 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9605 | ) |
| 9606 | { |
| 9607 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9608 | if (res == NULL && PyErr_Occurred()) { |
| 9609 | p->error_indicator = 1; |
| 9610 | return NULL; |
| 9611 | } |
| 9612 | goto done; |
| 9613 | } |
| 9614 | p->mark = mark; |
| 9615 | } |
| 9616 | { // '(' inside_paren_ann_assign_target ')' |
| 9617 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9618 | Token * literal; |
| 9619 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9620 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9621 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9622 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9623 | (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] | 9624 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9625 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9626 | ) |
| 9627 | { |
| 9628 | res = a; |
| 9629 | if (res == NULL && PyErr_Occurred()) { |
| 9630 | p->error_indicator = 1; |
| 9631 | return NULL; |
| 9632 | } |
| 9633 | goto done; |
| 9634 | } |
| 9635 | p->mark = mark; |
| 9636 | } |
| 9637 | res = NULL; |
| 9638 | done: |
| 9639 | return res; |
| 9640 | } |
| 9641 | |
| 9642 | // ann_assign_subscript_attribute_target: |
| 9643 | // | t_primary '.' NAME !t_lookahead |
| 9644 | // | t_primary '[' slices ']' !t_lookahead |
| 9645 | static expr_ty |
| 9646 | ann_assign_subscript_attribute_target_rule(Parser *p) |
| 9647 | { |
| 9648 | if (p->error_indicator) { |
| 9649 | return NULL; |
| 9650 | } |
| 9651 | expr_ty res = NULL; |
| 9652 | int mark = p->mark; |
| 9653 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9654 | p->error_indicator = 1; |
| 9655 | return NULL; |
| 9656 | } |
| 9657 | int start_lineno = p->tokens[mark]->lineno; |
| 9658 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9659 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9660 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9661 | { // t_primary '.' NAME !t_lookahead |
| 9662 | expr_ty a; |
| 9663 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9664 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9665 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9666 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9667 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9668 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9669 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9670 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9671 | && |
| 9672 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9673 | ) |
| 9674 | { |
| 9675 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9676 | if (token == NULL) { |
| 9677 | return NULL; |
| 9678 | } |
| 9679 | int end_lineno = token->end_lineno; |
| 9680 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9681 | int end_col_offset = token->end_col_offset; |
| 9682 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9683 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9684 | if (res == NULL && PyErr_Occurred()) { |
| 9685 | p->error_indicator = 1; |
| 9686 | return NULL; |
| 9687 | } |
| 9688 | goto done; |
| 9689 | } |
| 9690 | p->mark = mark; |
| 9691 | } |
| 9692 | { // t_primary '[' slices ']' !t_lookahead |
| 9693 | expr_ty a; |
| 9694 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9695 | Token * literal; |
| 9696 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9697 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9698 | (a = t_primary_rule(p)) // t_primary |
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 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9701 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9702 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9703 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9704 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9705 | && |
| 9706 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9707 | ) |
| 9708 | { |
| 9709 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9710 | if (token == NULL) { |
| 9711 | return NULL; |
| 9712 | } |
| 9713 | int end_lineno = token->end_lineno; |
| 9714 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9715 | int end_col_offset = token->end_col_offset; |
| 9716 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9717 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9718 | if (res == NULL && PyErr_Occurred()) { |
| 9719 | p->error_indicator = 1; |
| 9720 | return NULL; |
| 9721 | } |
| 9722 | goto done; |
| 9723 | } |
| 9724 | p->mark = mark; |
| 9725 | } |
| 9726 | res = NULL; |
| 9727 | done: |
| 9728 | return res; |
| 9729 | } |
| 9730 | |
| 9731 | // del_targets: ','.del_target+ ','? |
| 9732 | static asdl_seq* |
| 9733 | del_targets_rule(Parser *p) |
| 9734 | { |
| 9735 | if (p->error_indicator) { |
| 9736 | return NULL; |
| 9737 | } |
| 9738 | asdl_seq* res = NULL; |
| 9739 | int mark = p->mark; |
| 9740 | { // ','.del_target+ ','? |
| 9741 | asdl_seq * a; |
| 9742 | void *opt_var; |
| 9743 | UNUSED(opt_var); // Silence compiler warnings |
| 9744 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9745 | (a = _gather_121_rule(p)) // ','.del_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9746 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9747 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9748 | ) |
| 9749 | { |
| 9750 | res = a; |
| 9751 | if (res == NULL && PyErr_Occurred()) { |
| 9752 | p->error_indicator = 1; |
| 9753 | return NULL; |
| 9754 | } |
| 9755 | goto done; |
| 9756 | } |
| 9757 | p->mark = mark; |
| 9758 | } |
| 9759 | res = NULL; |
| 9760 | done: |
| 9761 | return res; |
| 9762 | } |
| 9763 | |
| 9764 | // del_target: |
| 9765 | // | t_primary '.' NAME !t_lookahead |
| 9766 | // | t_primary '[' slices ']' !t_lookahead |
| 9767 | // | del_t_atom |
| 9768 | static expr_ty |
| 9769 | del_target_rule(Parser *p) |
| 9770 | { |
| 9771 | if (p->error_indicator) { |
| 9772 | return NULL; |
| 9773 | } |
| 9774 | expr_ty res = NULL; |
| 9775 | if (_PyPegen_is_memoized(p, del_target_type, &res)) |
| 9776 | return res; |
| 9777 | int mark = p->mark; |
| 9778 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9779 | p->error_indicator = 1; |
| 9780 | return NULL; |
| 9781 | } |
| 9782 | int start_lineno = p->tokens[mark]->lineno; |
| 9783 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9784 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9785 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9786 | { // t_primary '.' NAME !t_lookahead |
| 9787 | expr_ty a; |
| 9788 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9789 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9790 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9791 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9792 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9793 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9794 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9795 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9796 | && |
| 9797 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9798 | ) |
| 9799 | { |
| 9800 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9801 | if (token == NULL) { |
| 9802 | return NULL; |
| 9803 | } |
| 9804 | int end_lineno = token->end_lineno; |
| 9805 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9806 | int end_col_offset = token->end_col_offset; |
| 9807 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9808 | res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); |
| 9809 | if (res == NULL && PyErr_Occurred()) { |
| 9810 | p->error_indicator = 1; |
| 9811 | return NULL; |
| 9812 | } |
| 9813 | goto done; |
| 9814 | } |
| 9815 | p->mark = mark; |
| 9816 | } |
| 9817 | { // t_primary '[' slices ']' !t_lookahead |
| 9818 | expr_ty a; |
| 9819 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9820 | Token * literal; |
| 9821 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9822 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9823 | (a = t_primary_rule(p)) // t_primary |
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 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9826 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9827 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9828 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9829 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9830 | && |
| 9831 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9832 | ) |
| 9833 | { |
| 9834 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9835 | if (token == NULL) { |
| 9836 | return NULL; |
| 9837 | } |
| 9838 | int end_lineno = token->end_lineno; |
| 9839 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9840 | int end_col_offset = token->end_col_offset; |
| 9841 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9842 | res = _Py_Subscript ( a , b , Del , EXTRA ); |
| 9843 | if (res == NULL && PyErr_Occurred()) { |
| 9844 | p->error_indicator = 1; |
| 9845 | return NULL; |
| 9846 | } |
| 9847 | goto done; |
| 9848 | } |
| 9849 | p->mark = mark; |
| 9850 | } |
| 9851 | { // del_t_atom |
| 9852 | expr_ty del_t_atom_var; |
| 9853 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9854 | (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9855 | ) |
| 9856 | { |
| 9857 | res = del_t_atom_var; |
| 9858 | goto done; |
| 9859 | } |
| 9860 | p->mark = mark; |
| 9861 | } |
| 9862 | res = NULL; |
| 9863 | done: |
| 9864 | _PyPegen_insert_memo(p, mark, del_target_type, res); |
| 9865 | return res; |
| 9866 | } |
| 9867 | |
| 9868 | // del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']' |
| 9869 | static expr_ty |
| 9870 | del_t_atom_rule(Parser *p) |
| 9871 | { |
| 9872 | if (p->error_indicator) { |
| 9873 | return NULL; |
| 9874 | } |
| 9875 | expr_ty res = NULL; |
| 9876 | int mark = p->mark; |
| 9877 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9878 | p->error_indicator = 1; |
| 9879 | return NULL; |
| 9880 | } |
| 9881 | int start_lineno = p->tokens[mark]->lineno; |
| 9882 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9883 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9884 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9885 | { // NAME |
| 9886 | expr_ty a; |
| 9887 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9888 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9889 | ) |
| 9890 | { |
| 9891 | res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9892 | if (res == NULL && PyErr_Occurred()) { |
| 9893 | p->error_indicator = 1; |
| 9894 | return NULL; |
| 9895 | } |
| 9896 | goto done; |
| 9897 | } |
| 9898 | p->mark = mark; |
| 9899 | } |
| 9900 | { // '(' del_target ')' |
| 9901 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9902 | Token * literal; |
| 9903 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9904 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9905 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9906 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9907 | (a = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9908 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9909 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9910 | ) |
| 9911 | { |
| 9912 | res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9913 | if (res == NULL && PyErr_Occurred()) { |
| 9914 | p->error_indicator = 1; |
| 9915 | return NULL; |
| 9916 | } |
| 9917 | goto done; |
| 9918 | } |
| 9919 | p->mark = mark; |
| 9920 | } |
| 9921 | { // '(' del_targets? ')' |
| 9922 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9923 | Token * literal; |
| 9924 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9925 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9926 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9927 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9928 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9929 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9930 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9931 | ) |
| 9932 | { |
| 9933 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9934 | if (token == NULL) { |
| 9935 | return NULL; |
| 9936 | } |
| 9937 | int end_lineno = token->end_lineno; |
| 9938 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9939 | int end_col_offset = token->end_col_offset; |
| 9940 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9941 | res = _Py_Tuple ( a , Del , EXTRA ); |
| 9942 | if (res == NULL && PyErr_Occurred()) { |
| 9943 | p->error_indicator = 1; |
| 9944 | return NULL; |
| 9945 | } |
| 9946 | goto done; |
| 9947 | } |
| 9948 | p->mark = mark; |
| 9949 | } |
| 9950 | { // '[' del_targets? ']' |
| 9951 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9952 | Token * literal; |
| 9953 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9954 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9955 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9956 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9957 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9958 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9959 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9960 | ) |
| 9961 | { |
| 9962 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9963 | if (token == NULL) { |
| 9964 | return NULL; |
| 9965 | } |
| 9966 | int end_lineno = token->end_lineno; |
| 9967 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9968 | int end_col_offset = token->end_col_offset; |
| 9969 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9970 | res = _Py_List ( a , Del , EXTRA ); |
| 9971 | if (res == NULL && PyErr_Occurred()) { |
| 9972 | p->error_indicator = 1; |
| 9973 | return NULL; |
| 9974 | } |
| 9975 | goto done; |
| 9976 | } |
| 9977 | p->mark = mark; |
| 9978 | } |
| 9979 | res = NULL; |
| 9980 | done: |
| 9981 | return res; |
| 9982 | } |
| 9983 | |
| 9984 | // targets: ','.target+ ','? |
| 9985 | static asdl_seq* |
| 9986 | targets_rule(Parser *p) |
| 9987 | { |
| 9988 | if (p->error_indicator) { |
| 9989 | return NULL; |
| 9990 | } |
| 9991 | asdl_seq* res = NULL; |
| 9992 | int mark = p->mark; |
| 9993 | { // ','.target+ ','? |
| 9994 | asdl_seq * a; |
| 9995 | void *opt_var; |
| 9996 | UNUSED(opt_var); // Silence compiler warnings |
| 9997 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 9998 | (a = _gather_123_rule(p)) // ','.target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9999 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10000 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10001 | ) |
| 10002 | { |
| 10003 | res = a; |
| 10004 | if (res == NULL && PyErr_Occurred()) { |
| 10005 | p->error_indicator = 1; |
| 10006 | return NULL; |
| 10007 | } |
| 10008 | goto done; |
| 10009 | } |
| 10010 | p->mark = mark; |
| 10011 | } |
| 10012 | res = NULL; |
| 10013 | done: |
| 10014 | return res; |
| 10015 | } |
| 10016 | |
| 10017 | // target: |
| 10018 | // | t_primary '.' NAME !t_lookahead |
| 10019 | // | t_primary '[' slices ']' !t_lookahead |
| 10020 | // | t_atom |
| 10021 | static expr_ty |
| 10022 | target_rule(Parser *p) |
| 10023 | { |
| 10024 | if (p->error_indicator) { |
| 10025 | return NULL; |
| 10026 | } |
| 10027 | expr_ty res = NULL; |
| 10028 | if (_PyPegen_is_memoized(p, target_type, &res)) |
| 10029 | return res; |
| 10030 | int mark = p->mark; |
| 10031 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10032 | p->error_indicator = 1; |
| 10033 | return NULL; |
| 10034 | } |
| 10035 | int start_lineno = p->tokens[mark]->lineno; |
| 10036 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 10037 | int start_col_offset = p->tokens[mark]->col_offset; |
| 10038 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 10039 | { // t_primary '.' NAME !t_lookahead |
| 10040 | expr_ty a; |
| 10041 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10042 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10043 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10044 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10045 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10046 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10047 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10048 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10049 | && |
| 10050 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10051 | ) |
| 10052 | { |
| 10053 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10054 | if (token == NULL) { |
| 10055 | return NULL; |
| 10056 | } |
| 10057 | int end_lineno = token->end_lineno; |
| 10058 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10059 | int end_col_offset = token->end_col_offset; |
| 10060 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10061 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 10062 | if (res == NULL && PyErr_Occurred()) { |
| 10063 | p->error_indicator = 1; |
| 10064 | return NULL; |
| 10065 | } |
| 10066 | goto done; |
| 10067 | } |
| 10068 | p->mark = mark; |
| 10069 | } |
| 10070 | { // t_primary '[' slices ']' !t_lookahead |
| 10071 | expr_ty a; |
| 10072 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10073 | Token * literal; |
| 10074 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10075 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10076 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10077 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10078 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10079 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10080 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10081 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10082 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10083 | && |
| 10084 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10085 | ) |
| 10086 | { |
| 10087 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10088 | if (token == NULL) { |
| 10089 | return NULL; |
| 10090 | } |
| 10091 | int end_lineno = token->end_lineno; |
| 10092 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10093 | int end_col_offset = token->end_col_offset; |
| 10094 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10095 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 10096 | if (res == NULL && PyErr_Occurred()) { |
| 10097 | p->error_indicator = 1; |
| 10098 | return NULL; |
| 10099 | } |
| 10100 | goto done; |
| 10101 | } |
| 10102 | p->mark = mark; |
| 10103 | } |
| 10104 | { // t_atom |
| 10105 | expr_ty t_atom_var; |
| 10106 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10107 | (t_atom_var = t_atom_rule(p)) // t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10108 | ) |
| 10109 | { |
| 10110 | res = t_atom_var; |
| 10111 | goto done; |
| 10112 | } |
| 10113 | p->mark = mark; |
| 10114 | } |
| 10115 | res = NULL; |
| 10116 | done: |
| 10117 | _PyPegen_insert_memo(p, mark, target_type, res); |
| 10118 | return res; |
| 10119 | } |
| 10120 | |
| 10121 | // Left-recursive |
| 10122 | // t_primary: |
| 10123 | // | t_primary '.' NAME &t_lookahead |
| 10124 | // | t_primary '[' slices ']' &t_lookahead |
| 10125 | // | t_primary genexp &t_lookahead |
| 10126 | // | t_primary '(' arguments? ')' &t_lookahead |
| 10127 | // | atom &t_lookahead |
| 10128 | static expr_ty t_primary_raw(Parser *); |
| 10129 | static expr_ty |
| 10130 | t_primary_rule(Parser *p) |
| 10131 | { |
| 10132 | expr_ty res = NULL; |
| 10133 | if (_PyPegen_is_memoized(p, t_primary_type, &res)) |
| 10134 | return res; |
| 10135 | int mark = p->mark; |
| 10136 | int resmark = p->mark; |
| 10137 | while (1) { |
| 10138 | int tmpvar_8 = _PyPegen_update_memo(p, mark, t_primary_type, res); |
| 10139 | if (tmpvar_8) { |
| 10140 | return res; |
| 10141 | } |
| 10142 | p->mark = mark; |
| 10143 | void *raw = t_primary_raw(p); |
| 10144 | if (raw == NULL || p->mark <= resmark) |
| 10145 | break; |
| 10146 | resmark = p->mark; |
| 10147 | res = raw; |
| 10148 | } |
| 10149 | p->mark = resmark; |
| 10150 | return res; |
| 10151 | } |
| 10152 | static expr_ty |
| 10153 | t_primary_raw(Parser *p) |
| 10154 | { |
| 10155 | if (p->error_indicator) { |
| 10156 | return NULL; |
| 10157 | } |
| 10158 | expr_ty res = NULL; |
| 10159 | int mark = p->mark; |
| 10160 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10161 | p->error_indicator = 1; |
| 10162 | return NULL; |
| 10163 | } |
| 10164 | int start_lineno = p->tokens[mark]->lineno; |
| 10165 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 10166 | int start_col_offset = p->tokens[mark]->col_offset; |
| 10167 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 10168 | { // t_primary '.' NAME &t_lookahead |
| 10169 | expr_ty a; |
| 10170 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10171 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10172 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10173 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10174 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10175 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10176 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10177 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10178 | && |
| 10179 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10180 | ) |
| 10181 | { |
| 10182 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10183 | if (token == NULL) { |
| 10184 | return NULL; |
| 10185 | } |
| 10186 | int end_lineno = token->end_lineno; |
| 10187 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10188 | int end_col_offset = token->end_col_offset; |
| 10189 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10190 | res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 10191 | if (res == NULL && PyErr_Occurred()) { |
| 10192 | p->error_indicator = 1; |
| 10193 | return NULL; |
| 10194 | } |
| 10195 | goto done; |
| 10196 | } |
| 10197 | p->mark = mark; |
| 10198 | } |
| 10199 | { // t_primary '[' slices ']' &t_lookahead |
| 10200 | expr_ty a; |
| 10201 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10202 | Token * literal; |
| 10203 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10204 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10205 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10206 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10207 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10208 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10209 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10210 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10211 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10212 | && |
| 10213 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10214 | ) |
| 10215 | { |
| 10216 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10217 | if (token == NULL) { |
| 10218 | return NULL; |
| 10219 | } |
| 10220 | int end_lineno = token->end_lineno; |
| 10221 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10222 | int end_col_offset = token->end_col_offset; |
| 10223 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10224 | res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 10225 | if (res == NULL && PyErr_Occurred()) { |
| 10226 | p->error_indicator = 1; |
| 10227 | return NULL; |
| 10228 | } |
| 10229 | goto done; |
| 10230 | } |
| 10231 | p->mark = mark; |
| 10232 | } |
| 10233 | { // t_primary genexp &t_lookahead |
| 10234 | expr_ty a; |
| 10235 | expr_ty b; |
| 10236 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10237 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10238 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10239 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10240 | && |
| 10241 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10242 | ) |
| 10243 | { |
| 10244 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10245 | if (token == NULL) { |
| 10246 | return NULL; |
| 10247 | } |
| 10248 | int end_lineno = token->end_lineno; |
| 10249 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10250 | int end_col_offset = token->end_col_offset; |
| 10251 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10252 | res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 10253 | if (res == NULL && PyErr_Occurred()) { |
| 10254 | p->error_indicator = 1; |
| 10255 | return NULL; |
| 10256 | } |
| 10257 | goto done; |
| 10258 | } |
| 10259 | p->mark = mark; |
| 10260 | } |
| 10261 | { // t_primary '(' arguments? ')' &t_lookahead |
| 10262 | expr_ty a; |
| 10263 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10264 | Token * literal; |
| 10265 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10266 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10267 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10268 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10269 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10270 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10271 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10272 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10273 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10274 | && |
| 10275 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10276 | ) |
| 10277 | { |
| 10278 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10279 | if (token == NULL) { |
| 10280 | return NULL; |
| 10281 | } |
| 10282 | int end_lineno = token->end_lineno; |
| 10283 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10284 | int end_col_offset = token->end_col_offset; |
| 10285 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10286 | res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 10287 | if (res == NULL && PyErr_Occurred()) { |
| 10288 | p->error_indicator = 1; |
| 10289 | return NULL; |
| 10290 | } |
| 10291 | goto done; |
| 10292 | } |
| 10293 | p->mark = mark; |
| 10294 | } |
| 10295 | { // atom &t_lookahead |
| 10296 | expr_ty a; |
| 10297 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10298 | (a = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10299 | && |
| 10300 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10301 | ) |
| 10302 | { |
| 10303 | res = a; |
| 10304 | if (res == NULL && PyErr_Occurred()) { |
| 10305 | p->error_indicator = 1; |
| 10306 | return NULL; |
| 10307 | } |
| 10308 | goto done; |
| 10309 | } |
| 10310 | p->mark = mark; |
| 10311 | } |
| 10312 | res = NULL; |
| 10313 | done: |
| 10314 | return res; |
| 10315 | } |
| 10316 | |
| 10317 | // t_lookahead: '(' | '[' | '.' |
| 10318 | static void * |
| 10319 | t_lookahead_rule(Parser *p) |
| 10320 | { |
| 10321 | if (p->error_indicator) { |
| 10322 | return NULL; |
| 10323 | } |
| 10324 | void * res = NULL; |
| 10325 | int mark = p->mark; |
| 10326 | { // '(' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10327 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10328 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10329 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10330 | ) |
| 10331 | { |
| 10332 | res = literal; |
| 10333 | goto done; |
| 10334 | } |
| 10335 | p->mark = mark; |
| 10336 | } |
| 10337 | { // '[' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10338 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10339 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10340 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10341 | ) |
| 10342 | { |
| 10343 | res = literal; |
| 10344 | goto done; |
| 10345 | } |
| 10346 | p->mark = mark; |
| 10347 | } |
| 10348 | { // '.' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10349 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10350 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10351 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10352 | ) |
| 10353 | { |
| 10354 | res = literal; |
| 10355 | goto done; |
| 10356 | } |
| 10357 | p->mark = mark; |
| 10358 | } |
| 10359 | res = NULL; |
| 10360 | done: |
| 10361 | return res; |
| 10362 | } |
| 10363 | |
| 10364 | // t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' |
| 10365 | static expr_ty |
| 10366 | t_atom_rule(Parser *p) |
| 10367 | { |
| 10368 | if (p->error_indicator) { |
| 10369 | return NULL; |
| 10370 | } |
| 10371 | expr_ty res = NULL; |
| 10372 | int mark = p->mark; |
| 10373 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10374 | p->error_indicator = 1; |
| 10375 | return NULL; |
| 10376 | } |
| 10377 | int start_lineno = p->tokens[mark]->lineno; |
| 10378 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 10379 | int start_col_offset = p->tokens[mark]->col_offset; |
| 10380 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 10381 | { // NAME |
| 10382 | expr_ty a; |
| 10383 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10384 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10385 | ) |
| 10386 | { |
| 10387 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10388 | if (res == NULL && PyErr_Occurred()) { |
| 10389 | p->error_indicator = 1; |
| 10390 | return NULL; |
| 10391 | } |
| 10392 | goto done; |
| 10393 | } |
| 10394 | p->mark = mark; |
| 10395 | } |
| 10396 | { // '(' target ')' |
| 10397 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10398 | Token * literal; |
| 10399 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10400 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10401 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10402 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10403 | (a = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10404 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10405 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10406 | ) |
| 10407 | { |
| 10408 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10409 | if (res == NULL && PyErr_Occurred()) { |
| 10410 | p->error_indicator = 1; |
| 10411 | return NULL; |
| 10412 | } |
| 10413 | goto done; |
| 10414 | } |
| 10415 | p->mark = mark; |
| 10416 | } |
| 10417 | { // '(' targets? ')' |
| 10418 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10419 | Token * literal; |
| 10420 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10421 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10422 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10423 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10424 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10425 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10426 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10427 | ) |
| 10428 | { |
| 10429 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10430 | if (token == NULL) { |
| 10431 | return NULL; |
| 10432 | } |
| 10433 | int end_lineno = token->end_lineno; |
| 10434 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10435 | int end_col_offset = token->end_col_offset; |
| 10436 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10437 | res = _Py_Tuple ( b , Store , EXTRA ); |
| 10438 | if (res == NULL && PyErr_Occurred()) { |
| 10439 | p->error_indicator = 1; |
| 10440 | return NULL; |
| 10441 | } |
| 10442 | goto done; |
| 10443 | } |
| 10444 | p->mark = mark; |
| 10445 | } |
| 10446 | { // '[' targets? ']' |
| 10447 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10448 | Token * literal; |
| 10449 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10450 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10451 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10452 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10453 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10454 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10455 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10456 | ) |
| 10457 | { |
| 10458 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10459 | if (token == NULL) { |
| 10460 | return NULL; |
| 10461 | } |
| 10462 | int end_lineno = token->end_lineno; |
| 10463 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10464 | int end_col_offset = token->end_col_offset; |
| 10465 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10466 | res = _Py_List ( b , Store , EXTRA ); |
| 10467 | if (res == NULL && PyErr_Occurred()) { |
| 10468 | p->error_indicator = 1; |
| 10469 | return NULL; |
| 10470 | } |
| 10471 | goto done; |
| 10472 | } |
| 10473 | p->mark = mark; |
| 10474 | } |
| 10475 | res = NULL; |
| 10476 | done: |
| 10477 | return res; |
| 10478 | } |
| 10479 | |
| 10480 | // incorrect_arguments: |
| 10481 | // | args ',' '*' |
| 10482 | // | expression for_if_clauses ',' [args | expression for_if_clauses] |
| 10483 | // | args ',' args |
| 10484 | static void * |
| 10485 | incorrect_arguments_rule(Parser *p) |
| 10486 | { |
| 10487 | if (p->error_indicator) { |
| 10488 | return NULL; |
| 10489 | } |
| 10490 | void * res = NULL; |
| 10491 | int mark = p->mark; |
| 10492 | { // args ',' '*' |
| 10493 | expr_ty args_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10494 | Token * literal; |
| 10495 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10496 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10497 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10498 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10499 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10500 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10501 | (literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10502 | ) |
| 10503 | { |
| 10504 | res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); |
| 10505 | if (res == NULL && PyErr_Occurred()) { |
| 10506 | p->error_indicator = 1; |
| 10507 | return NULL; |
| 10508 | } |
| 10509 | goto done; |
| 10510 | } |
| 10511 | p->mark = mark; |
| 10512 | } |
| 10513 | { // expression for_if_clauses ',' [args | expression for_if_clauses] |
| 10514 | expr_ty expression_var; |
| 10515 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10516 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10517 | void *opt_var; |
| 10518 | UNUSED(opt_var); // Silence compiler warnings |
| 10519 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10520 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10521 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10522 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10523 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10524 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10525 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10526 | (opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10527 | ) |
| 10528 | { |
| 10529 | res = RAISE_SYNTAX_ERROR ( "Generator expression must be parenthesized" ); |
| 10530 | if (res == NULL && PyErr_Occurred()) { |
| 10531 | p->error_indicator = 1; |
| 10532 | return NULL; |
| 10533 | } |
| 10534 | goto done; |
| 10535 | } |
| 10536 | p->mark = mark; |
| 10537 | } |
| 10538 | { // args ',' args |
| 10539 | expr_ty a; |
| 10540 | expr_ty args_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10541 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10542 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10543 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10544 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10545 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10546 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10547 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10548 | ) |
| 10549 | { |
| 10550 | res = _PyPegen_arguments_parsing_error ( p , a ); |
| 10551 | if (res == NULL && PyErr_Occurred()) { |
| 10552 | p->error_indicator = 1; |
| 10553 | return NULL; |
| 10554 | } |
| 10555 | goto done; |
| 10556 | } |
| 10557 | p->mark = mark; |
| 10558 | } |
| 10559 | res = NULL; |
| 10560 | done: |
| 10561 | return res; |
| 10562 | } |
| 10563 | |
| 10564 | // invalid_named_expression: expression ':=' expression |
| 10565 | static void * |
| 10566 | invalid_named_expression_rule(Parser *p) |
| 10567 | { |
| 10568 | if (p->error_indicator) { |
| 10569 | return NULL; |
| 10570 | } |
| 10571 | void * res = NULL; |
| 10572 | int mark = p->mark; |
| 10573 | { // expression ':=' expression |
| 10574 | expr_ty a; |
| 10575 | expr_ty expression_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10576 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10577 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10578 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10579 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10580 | (literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10581 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10582 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10583 | ) |
| 10584 | { |
| 10585 | res = RAISE_SYNTAX_ERROR ( "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); |
| 10586 | if (res == NULL && PyErr_Occurred()) { |
| 10587 | p->error_indicator = 1; |
| 10588 | return NULL; |
| 10589 | } |
| 10590 | goto done; |
| 10591 | } |
| 10592 | p->mark = mark; |
| 10593 | } |
| 10594 | res = NULL; |
| 10595 | done: |
| 10596 | return res; |
| 10597 | } |
| 10598 | |
| 10599 | // invalid_assignment: |
| 10600 | // | list ':' |
| 10601 | // | tuple ':' |
| 10602 | // | expression ':' expression ['=' annotated_rhs] |
| 10603 | // | expression ('=' | augassign) (yield_expr | star_expressions) |
| 10604 | static void * |
| 10605 | invalid_assignment_rule(Parser *p) |
| 10606 | { |
| 10607 | if (p->error_indicator) { |
| 10608 | return NULL; |
| 10609 | } |
| 10610 | void * res = NULL; |
| 10611 | int mark = p->mark; |
| 10612 | { // list ':' |
| 10613 | expr_ty list_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10614 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10615 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10616 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10617 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10618 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10619 | ) |
| 10620 | { |
| 10621 | res = RAISE_SYNTAX_ERROR ( "only single target (not list) can be annotated" ); |
| 10622 | if (res == NULL && PyErr_Occurred()) { |
| 10623 | p->error_indicator = 1; |
| 10624 | return NULL; |
| 10625 | } |
| 10626 | goto done; |
| 10627 | } |
| 10628 | p->mark = mark; |
| 10629 | } |
| 10630 | { // tuple ':' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10631 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10632 | expr_ty tuple_var; |
| 10633 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10634 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10635 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10636 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10637 | ) |
| 10638 | { |
| 10639 | res = RAISE_SYNTAX_ERROR ( "only single target (not tuple) can be annotated" ); |
| 10640 | if (res == NULL && PyErr_Occurred()) { |
| 10641 | p->error_indicator = 1; |
| 10642 | return NULL; |
| 10643 | } |
| 10644 | goto done; |
| 10645 | } |
| 10646 | p->mark = mark; |
| 10647 | } |
| 10648 | { // expression ':' expression ['=' annotated_rhs] |
| 10649 | expr_ty expression_var; |
| 10650 | expr_ty expression_var_1; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10651 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10652 | void *opt_var; |
| 10653 | UNUSED(opt_var); // Silence compiler warnings |
| 10654 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10655 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10656 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10657 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10658 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10659 | (expression_var_1 = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10660 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10661 | (opt_var = _tmp_126_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10662 | ) |
| 10663 | { |
| 10664 | res = RAISE_SYNTAX_ERROR ( "illegal target for annotation" ); |
| 10665 | if (res == NULL && PyErr_Occurred()) { |
| 10666 | p->error_indicator = 1; |
| 10667 | return NULL; |
| 10668 | } |
| 10669 | goto done; |
| 10670 | } |
| 10671 | p->mark = mark; |
| 10672 | } |
| 10673 | { // expression ('=' | augassign) (yield_expr | star_expressions) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10674 | void *_tmp_127_var; |
| 10675 | void *_tmp_128_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10676 | expr_ty a; |
| 10677 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10678 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10679 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10680 | (_tmp_127_var = _tmp_127_rule(p)) // '=' | augassign |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10681 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10682 | (_tmp_128_var = _tmp_128_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10683 | ) |
| 10684 | { |
Batuhan Taskaya | 76c1b4d | 2020-05-01 16:13:43 +0300 | [diff] [blame] | 10685 | res = RAISE_SYNTAX_ERROR_NO_COL_OFFSET ( "cannot assign to %s" , _PyPegen_get_expr_name ( a ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10686 | if (res == NULL && PyErr_Occurred()) { |
| 10687 | p->error_indicator = 1; |
| 10688 | return NULL; |
| 10689 | } |
| 10690 | goto done; |
| 10691 | } |
| 10692 | p->mark = mark; |
| 10693 | } |
| 10694 | res = NULL; |
| 10695 | done: |
| 10696 | return res; |
| 10697 | } |
| 10698 | |
| 10699 | // invalid_block: NEWLINE !INDENT |
| 10700 | static void * |
| 10701 | invalid_block_rule(Parser *p) |
| 10702 | { |
| 10703 | if (p->error_indicator) { |
| 10704 | return NULL; |
| 10705 | } |
| 10706 | void * res = NULL; |
| 10707 | int mark = p->mark; |
| 10708 | { // NEWLINE !INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10709 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10710 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10711 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10712 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10713 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10714 | ) |
| 10715 | { |
| 10716 | res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); |
| 10717 | if (res == NULL && PyErr_Occurred()) { |
| 10718 | p->error_indicator = 1; |
| 10719 | return NULL; |
| 10720 | } |
| 10721 | goto done; |
| 10722 | } |
| 10723 | p->mark = mark; |
| 10724 | } |
| 10725 | res = NULL; |
| 10726 | done: |
| 10727 | return res; |
| 10728 | } |
| 10729 | |
| 10730 | // invalid_comprehension: ('[' | '(' | '{') '*' expression for_if_clauses |
| 10731 | static void * |
| 10732 | invalid_comprehension_rule(Parser *p) |
| 10733 | { |
| 10734 | if (p->error_indicator) { |
| 10735 | return NULL; |
| 10736 | } |
| 10737 | void * res = NULL; |
| 10738 | int mark = p->mark; |
| 10739 | { // ('[' | '(' | '{') '*' expression for_if_clauses |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10740 | void *_tmp_129_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10741 | expr_ty expression_var; |
| 10742 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10743 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10744 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10745 | (_tmp_129_var = _tmp_129_rule(p)) // '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10746 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10747 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10748 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10749 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10750 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10751 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10752 | ) |
| 10753 | { |
| 10754 | res = RAISE_SYNTAX_ERROR ( "iterable unpacking cannot be used in comprehension" ); |
| 10755 | if (res == NULL && PyErr_Occurred()) { |
| 10756 | p->error_indicator = 1; |
| 10757 | return NULL; |
| 10758 | } |
| 10759 | goto done; |
| 10760 | } |
| 10761 | p->mark = mark; |
| 10762 | } |
| 10763 | res = NULL; |
| 10764 | done: |
| 10765 | return res; |
| 10766 | } |
| 10767 | |
| 10768 | // invalid_parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10769 | // | param_no_default* (slash_with_default | param_with_default+) param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10770 | static void * |
| 10771 | invalid_parameters_rule(Parser *p) |
| 10772 | { |
| 10773 | if (p->error_indicator) { |
| 10774 | return NULL; |
| 10775 | } |
| 10776 | void * res = NULL; |
| 10777 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10778 | { // param_no_default* (slash_with_default | param_with_default+) param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10779 | asdl_seq * _loop0_130_var; |
| 10780 | void *_tmp_131_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10781 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10782 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10783 | (_loop0_130_var = _loop0_130_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10784 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10785 | (_tmp_131_var = _tmp_131_rule(p)) // slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10786 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10787 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10788 | ) |
| 10789 | { |
| 10790 | res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 10791 | if (res == NULL && PyErr_Occurred()) { |
| 10792 | p->error_indicator = 1; |
| 10793 | return NULL; |
| 10794 | } |
| 10795 | goto done; |
| 10796 | } |
| 10797 | p->mark = mark; |
| 10798 | } |
| 10799 | res = NULL; |
| 10800 | done: |
| 10801 | return res; |
| 10802 | } |
| 10803 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10804 | // invalid_star_etc: '*' (')' | ',' (')' | '**')) |
| 10805 | static void * |
| 10806 | invalid_star_etc_rule(Parser *p) |
| 10807 | { |
| 10808 | if (p->error_indicator) { |
| 10809 | return NULL; |
| 10810 | } |
| 10811 | void * res = NULL; |
| 10812 | int mark = p->mark; |
| 10813 | { // '*' (')' | ',' (')' | '**')) |
| 10814 | void *_tmp_132_var; |
| 10815 | Token * literal; |
| 10816 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10817 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10818 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10819 | (_tmp_132_var = _tmp_132_rule(p)) // ')' | ',' (')' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10820 | ) |
| 10821 | { |
| 10822 | res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 10823 | if (res == NULL && PyErr_Occurred()) { |
| 10824 | p->error_indicator = 1; |
| 10825 | return NULL; |
| 10826 | } |
| 10827 | goto done; |
| 10828 | } |
| 10829 | p->mark = mark; |
| 10830 | } |
| 10831 | res = NULL; |
| 10832 | done: |
| 10833 | return res; |
| 10834 | } |
| 10835 | |
| 10836 | // invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) |
| 10837 | static void * |
| 10838 | invalid_lambda_star_etc_rule(Parser *p) |
| 10839 | { |
| 10840 | if (p->error_indicator) { |
| 10841 | return NULL; |
| 10842 | } |
| 10843 | void * res = NULL; |
| 10844 | int mark = p->mark; |
| 10845 | { // '*' (':' | ',' (':' | '**')) |
| 10846 | void *_tmp_133_var; |
| 10847 | Token * literal; |
| 10848 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10849 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10850 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10851 | (_tmp_133_var = _tmp_133_rule(p)) // ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10852 | ) |
| 10853 | { |
| 10854 | res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 10855 | if (res == NULL && PyErr_Occurred()) { |
| 10856 | p->error_indicator = 1; |
| 10857 | return NULL; |
| 10858 | } |
| 10859 | goto done; |
| 10860 | } |
| 10861 | p->mark = mark; |
| 10862 | } |
| 10863 | res = NULL; |
| 10864 | done: |
| 10865 | return res; |
| 10866 | } |
| 10867 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10868 | // invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 10869 | static void * |
| 10870 | invalid_double_type_comments_rule(Parser *p) |
| 10871 | { |
| 10872 | if (p->error_indicator) { |
| 10873 | return NULL; |
| 10874 | } |
| 10875 | void * res = NULL; |
| 10876 | int mark = p->mark; |
| 10877 | { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10878 | Token * indent_var; |
| 10879 | Token * newline_var; |
| 10880 | Token * newline_var_1; |
| 10881 | Token * type_comment_var; |
| 10882 | Token * type_comment_var_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10883 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10884 | (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] | 10885 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10886 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10887 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10888 | (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] | 10889 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10890 | (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10891 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10892 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10893 | ) |
| 10894 | { |
| 10895 | res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); |
| 10896 | if (res == NULL && PyErr_Occurred()) { |
| 10897 | p->error_indicator = 1; |
| 10898 | return NULL; |
| 10899 | } |
| 10900 | goto done; |
| 10901 | } |
| 10902 | p->mark = mark; |
| 10903 | } |
| 10904 | res = NULL; |
| 10905 | done: |
| 10906 | return res; |
| 10907 | } |
| 10908 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10909 | // _loop0_1: NEWLINE |
| 10910 | static asdl_seq * |
| 10911 | _loop0_1_rule(Parser *p) |
| 10912 | { |
| 10913 | if (p->error_indicator) { |
| 10914 | return NULL; |
| 10915 | } |
| 10916 | void *res = NULL; |
| 10917 | int mark = p->mark; |
| 10918 | int start_mark = p->mark; |
| 10919 | void **children = PyMem_Malloc(sizeof(void *)); |
| 10920 | if (!children) { |
| 10921 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 10922 | return NULL; |
| 10923 | } |
| 10924 | ssize_t children_capacity = 1; |
| 10925 | ssize_t n = 0; |
| 10926 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10927 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10928 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10929 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10930 | ) |
| 10931 | { |
| 10932 | res = newline_var; |
| 10933 | if (n == children_capacity) { |
| 10934 | children_capacity *= 2; |
| 10935 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 10936 | if (!children) { |
| 10937 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 10938 | return NULL; |
| 10939 | } |
| 10940 | } |
| 10941 | children[n++] = res; |
| 10942 | mark = p->mark; |
| 10943 | } |
| 10944 | p->mark = mark; |
| 10945 | } |
| 10946 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 10947 | if (!seq) { |
| 10948 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1"); |
| 10949 | PyMem_Free(children); |
| 10950 | return NULL; |
| 10951 | } |
| 10952 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 10953 | PyMem_Free(children); |
| 10954 | _PyPegen_insert_memo(p, start_mark, _loop0_1_type, seq); |
| 10955 | return seq; |
| 10956 | } |
| 10957 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10958 | // _loop0_2: NEWLINE |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10959 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10960 | _loop0_2_rule(Parser *p) |
| 10961 | { |
| 10962 | if (p->error_indicator) { |
| 10963 | return NULL; |
| 10964 | } |
| 10965 | void *res = NULL; |
| 10966 | int mark = p->mark; |
| 10967 | int start_mark = p->mark; |
| 10968 | void **children = PyMem_Malloc(sizeof(void *)); |
| 10969 | if (!children) { |
| 10970 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 10971 | return NULL; |
| 10972 | } |
| 10973 | ssize_t children_capacity = 1; |
| 10974 | ssize_t n = 0; |
| 10975 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10976 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10977 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 10978 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10979 | ) |
| 10980 | { |
| 10981 | res = newline_var; |
| 10982 | if (n == children_capacity) { |
| 10983 | children_capacity *= 2; |
| 10984 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 10985 | if (!children) { |
| 10986 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 10987 | return NULL; |
| 10988 | } |
| 10989 | } |
| 10990 | children[n++] = res; |
| 10991 | mark = p->mark; |
| 10992 | } |
| 10993 | p->mark = mark; |
| 10994 | } |
| 10995 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 10996 | if (!seq) { |
| 10997 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2"); |
| 10998 | PyMem_Free(children); |
| 10999 | return NULL; |
| 11000 | } |
| 11001 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11002 | PyMem_Free(children); |
| 11003 | _PyPegen_insert_memo(p, start_mark, _loop0_2_type, seq); |
| 11004 | return seq; |
| 11005 | } |
| 11006 | |
| 11007 | // _loop0_4: ',' expression |
| 11008 | static asdl_seq * |
| 11009 | _loop0_4_rule(Parser *p) |
| 11010 | { |
| 11011 | if (p->error_indicator) { |
| 11012 | return NULL; |
| 11013 | } |
| 11014 | void *res = NULL; |
| 11015 | int mark = p->mark; |
| 11016 | int start_mark = p->mark; |
| 11017 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11018 | if (!children) { |
| 11019 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11020 | return NULL; |
| 11021 | } |
| 11022 | ssize_t children_capacity = 1; |
| 11023 | ssize_t n = 0; |
| 11024 | { // ',' expression |
| 11025 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11026 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11027 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11028 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11029 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11030 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11031 | ) |
| 11032 | { |
| 11033 | res = elem; |
| 11034 | if (res == NULL && PyErr_Occurred()) { |
| 11035 | p->error_indicator = 1; |
| 11036 | PyMem_Free(children); |
| 11037 | return NULL; |
| 11038 | } |
| 11039 | if (n == children_capacity) { |
| 11040 | children_capacity *= 2; |
| 11041 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11042 | if (!children) { |
| 11043 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11044 | return NULL; |
| 11045 | } |
| 11046 | } |
| 11047 | children[n++] = res; |
| 11048 | mark = p->mark; |
| 11049 | } |
| 11050 | p->mark = mark; |
| 11051 | } |
| 11052 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11053 | if (!seq) { |
| 11054 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4"); |
| 11055 | PyMem_Free(children); |
| 11056 | return NULL; |
| 11057 | } |
| 11058 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11059 | PyMem_Free(children); |
| 11060 | _PyPegen_insert_memo(p, start_mark, _loop0_4_type, seq); |
| 11061 | return seq; |
| 11062 | } |
| 11063 | |
| 11064 | // _gather_3: expression _loop0_4 |
| 11065 | static asdl_seq * |
| 11066 | _gather_3_rule(Parser *p) |
| 11067 | { |
| 11068 | if (p->error_indicator) { |
| 11069 | return NULL; |
| 11070 | } |
| 11071 | asdl_seq * res = NULL; |
| 11072 | int mark = p->mark; |
| 11073 | { // expression _loop0_4 |
| 11074 | expr_ty elem; |
| 11075 | asdl_seq * seq; |
| 11076 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11077 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11078 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11079 | (seq = _loop0_4_rule(p)) // _loop0_4 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11080 | ) |
| 11081 | { |
| 11082 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11083 | goto done; |
| 11084 | } |
| 11085 | p->mark = mark; |
| 11086 | } |
| 11087 | res = NULL; |
| 11088 | done: |
| 11089 | return res; |
| 11090 | } |
| 11091 | |
| 11092 | // _loop0_6: ',' expression |
| 11093 | static asdl_seq * |
| 11094 | _loop0_6_rule(Parser *p) |
| 11095 | { |
| 11096 | if (p->error_indicator) { |
| 11097 | return NULL; |
| 11098 | } |
| 11099 | void *res = NULL; |
| 11100 | int mark = p->mark; |
| 11101 | int start_mark = p->mark; |
| 11102 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11103 | if (!children) { |
| 11104 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11105 | return NULL; |
| 11106 | } |
| 11107 | ssize_t children_capacity = 1; |
| 11108 | ssize_t n = 0; |
| 11109 | { // ',' expression |
| 11110 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11111 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11112 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11113 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11114 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11115 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11116 | ) |
| 11117 | { |
| 11118 | res = elem; |
| 11119 | if (res == NULL && PyErr_Occurred()) { |
| 11120 | p->error_indicator = 1; |
| 11121 | PyMem_Free(children); |
| 11122 | return NULL; |
| 11123 | } |
| 11124 | if (n == children_capacity) { |
| 11125 | children_capacity *= 2; |
| 11126 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11127 | if (!children) { |
| 11128 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11129 | return NULL; |
| 11130 | } |
| 11131 | } |
| 11132 | children[n++] = res; |
| 11133 | mark = p->mark; |
| 11134 | } |
| 11135 | p->mark = mark; |
| 11136 | } |
| 11137 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11138 | if (!seq) { |
| 11139 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6"); |
| 11140 | PyMem_Free(children); |
| 11141 | return NULL; |
| 11142 | } |
| 11143 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11144 | PyMem_Free(children); |
| 11145 | _PyPegen_insert_memo(p, start_mark, _loop0_6_type, seq); |
| 11146 | return seq; |
| 11147 | } |
| 11148 | |
| 11149 | // _gather_5: expression _loop0_6 |
| 11150 | static asdl_seq * |
| 11151 | _gather_5_rule(Parser *p) |
| 11152 | { |
| 11153 | if (p->error_indicator) { |
| 11154 | return NULL; |
| 11155 | } |
| 11156 | asdl_seq * res = NULL; |
| 11157 | int mark = p->mark; |
| 11158 | { // expression _loop0_6 |
| 11159 | expr_ty elem; |
| 11160 | asdl_seq * seq; |
| 11161 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11162 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11163 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11164 | (seq = _loop0_6_rule(p)) // _loop0_6 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11165 | ) |
| 11166 | { |
| 11167 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11168 | goto done; |
| 11169 | } |
| 11170 | p->mark = mark; |
| 11171 | } |
| 11172 | res = NULL; |
| 11173 | done: |
| 11174 | return res; |
| 11175 | } |
| 11176 | |
| 11177 | // _loop0_8: ',' expression |
| 11178 | static asdl_seq * |
| 11179 | _loop0_8_rule(Parser *p) |
| 11180 | { |
| 11181 | if (p->error_indicator) { |
| 11182 | return NULL; |
| 11183 | } |
| 11184 | void *res = NULL; |
| 11185 | int mark = p->mark; |
| 11186 | int start_mark = p->mark; |
| 11187 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11188 | if (!children) { |
| 11189 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11190 | return NULL; |
| 11191 | } |
| 11192 | ssize_t children_capacity = 1; |
| 11193 | ssize_t n = 0; |
| 11194 | { // ',' expression |
| 11195 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11196 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11197 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11198 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11199 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11200 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11201 | ) |
| 11202 | { |
| 11203 | res = elem; |
| 11204 | if (res == NULL && PyErr_Occurred()) { |
| 11205 | p->error_indicator = 1; |
| 11206 | PyMem_Free(children); |
| 11207 | return NULL; |
| 11208 | } |
| 11209 | if (n == children_capacity) { |
| 11210 | children_capacity *= 2; |
| 11211 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11212 | if (!children) { |
| 11213 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11214 | return NULL; |
| 11215 | } |
| 11216 | } |
| 11217 | children[n++] = res; |
| 11218 | mark = p->mark; |
| 11219 | } |
| 11220 | p->mark = mark; |
| 11221 | } |
| 11222 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11223 | if (!seq) { |
| 11224 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8"); |
| 11225 | PyMem_Free(children); |
| 11226 | return NULL; |
| 11227 | } |
| 11228 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11229 | PyMem_Free(children); |
| 11230 | _PyPegen_insert_memo(p, start_mark, _loop0_8_type, seq); |
| 11231 | return seq; |
| 11232 | } |
| 11233 | |
| 11234 | // _gather_7: expression _loop0_8 |
| 11235 | static asdl_seq * |
| 11236 | _gather_7_rule(Parser *p) |
| 11237 | { |
| 11238 | if (p->error_indicator) { |
| 11239 | return NULL; |
| 11240 | } |
| 11241 | asdl_seq * res = NULL; |
| 11242 | int mark = p->mark; |
| 11243 | { // expression _loop0_8 |
| 11244 | expr_ty elem; |
| 11245 | asdl_seq * seq; |
| 11246 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11247 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11248 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11249 | (seq = _loop0_8_rule(p)) // _loop0_8 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11250 | ) |
| 11251 | { |
| 11252 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11253 | goto done; |
| 11254 | } |
| 11255 | p->mark = mark; |
| 11256 | } |
| 11257 | res = NULL; |
| 11258 | done: |
| 11259 | return res; |
| 11260 | } |
| 11261 | |
| 11262 | // _loop0_10: ',' expression |
| 11263 | static asdl_seq * |
| 11264 | _loop0_10_rule(Parser *p) |
| 11265 | { |
| 11266 | if (p->error_indicator) { |
| 11267 | return NULL; |
| 11268 | } |
| 11269 | void *res = NULL; |
| 11270 | int mark = p->mark; |
| 11271 | int start_mark = p->mark; |
| 11272 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11273 | if (!children) { |
| 11274 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11275 | return NULL; |
| 11276 | } |
| 11277 | ssize_t children_capacity = 1; |
| 11278 | ssize_t n = 0; |
| 11279 | { // ',' expression |
| 11280 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11281 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11282 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11283 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11284 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11285 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11286 | ) |
| 11287 | { |
| 11288 | res = elem; |
| 11289 | if (res == NULL && PyErr_Occurred()) { |
| 11290 | p->error_indicator = 1; |
| 11291 | PyMem_Free(children); |
| 11292 | return NULL; |
| 11293 | } |
| 11294 | if (n == children_capacity) { |
| 11295 | children_capacity *= 2; |
| 11296 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11297 | if (!children) { |
| 11298 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11299 | return NULL; |
| 11300 | } |
| 11301 | } |
| 11302 | children[n++] = res; |
| 11303 | mark = p->mark; |
| 11304 | } |
| 11305 | p->mark = mark; |
| 11306 | } |
| 11307 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11308 | if (!seq) { |
| 11309 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10"); |
| 11310 | PyMem_Free(children); |
| 11311 | return NULL; |
| 11312 | } |
| 11313 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11314 | PyMem_Free(children); |
| 11315 | _PyPegen_insert_memo(p, start_mark, _loop0_10_type, seq); |
| 11316 | return seq; |
| 11317 | } |
| 11318 | |
| 11319 | // _gather_9: expression _loop0_10 |
| 11320 | static asdl_seq * |
| 11321 | _gather_9_rule(Parser *p) |
| 11322 | { |
| 11323 | if (p->error_indicator) { |
| 11324 | return NULL; |
| 11325 | } |
| 11326 | asdl_seq * res = NULL; |
| 11327 | int mark = p->mark; |
| 11328 | { // expression _loop0_10 |
| 11329 | expr_ty elem; |
| 11330 | asdl_seq * seq; |
| 11331 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11332 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11333 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11334 | (seq = _loop0_10_rule(p)) // _loop0_10 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11335 | ) |
| 11336 | { |
| 11337 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11338 | goto done; |
| 11339 | } |
| 11340 | p->mark = mark; |
| 11341 | } |
| 11342 | res = NULL; |
| 11343 | done: |
| 11344 | return res; |
| 11345 | } |
| 11346 | |
| 11347 | // _loop1_11: statement |
| 11348 | static asdl_seq * |
| 11349 | _loop1_11_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11350 | { |
| 11351 | if (p->error_indicator) { |
| 11352 | return NULL; |
| 11353 | } |
| 11354 | void *res = NULL; |
| 11355 | int mark = p->mark; |
| 11356 | int start_mark = p->mark; |
| 11357 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11358 | if (!children) { |
| 11359 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11360 | return NULL; |
| 11361 | } |
| 11362 | ssize_t children_capacity = 1; |
| 11363 | ssize_t n = 0; |
| 11364 | { // statement |
| 11365 | asdl_seq* statement_var; |
| 11366 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11367 | (statement_var = statement_rule(p)) // statement |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11368 | ) |
| 11369 | { |
| 11370 | res = statement_var; |
| 11371 | if (n == children_capacity) { |
| 11372 | children_capacity *= 2; |
| 11373 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11374 | if (!children) { |
| 11375 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11376 | return NULL; |
| 11377 | } |
| 11378 | } |
| 11379 | children[n++] = res; |
| 11380 | mark = p->mark; |
| 11381 | } |
| 11382 | p->mark = mark; |
| 11383 | } |
| 11384 | if (n == 0) { |
| 11385 | PyMem_Free(children); |
| 11386 | return NULL; |
| 11387 | } |
| 11388 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11389 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11390 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11391 | PyMem_Free(children); |
| 11392 | return NULL; |
| 11393 | } |
| 11394 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11395 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11396 | _PyPegen_insert_memo(p, start_mark, _loop1_11_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11397 | return seq; |
| 11398 | } |
| 11399 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11400 | // _loop0_13: ';' small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11401 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11402 | _loop0_13_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11403 | { |
| 11404 | if (p->error_indicator) { |
| 11405 | return NULL; |
| 11406 | } |
| 11407 | void *res = NULL; |
| 11408 | int mark = p->mark; |
| 11409 | int start_mark = p->mark; |
| 11410 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11411 | if (!children) { |
| 11412 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11413 | return NULL; |
| 11414 | } |
| 11415 | ssize_t children_capacity = 1; |
| 11416 | ssize_t n = 0; |
| 11417 | { // ';' small_stmt |
| 11418 | stmt_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11419 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11420 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11421 | (literal = _PyPegen_expect_token(p, 13)) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11422 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11423 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11424 | ) |
| 11425 | { |
| 11426 | res = elem; |
| 11427 | if (res == NULL && PyErr_Occurred()) { |
| 11428 | p->error_indicator = 1; |
| 11429 | PyMem_Free(children); |
| 11430 | return NULL; |
| 11431 | } |
| 11432 | if (n == children_capacity) { |
| 11433 | children_capacity *= 2; |
| 11434 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11435 | if (!children) { |
| 11436 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11437 | return NULL; |
| 11438 | } |
| 11439 | } |
| 11440 | children[n++] = res; |
| 11441 | mark = p->mark; |
| 11442 | } |
| 11443 | p->mark = mark; |
| 11444 | } |
| 11445 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11446 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11447 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11448 | PyMem_Free(children); |
| 11449 | return NULL; |
| 11450 | } |
| 11451 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11452 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11453 | _PyPegen_insert_memo(p, start_mark, _loop0_13_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11454 | return seq; |
| 11455 | } |
| 11456 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11457 | // _gather_12: small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11458 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11459 | _gather_12_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11460 | { |
| 11461 | if (p->error_indicator) { |
| 11462 | return NULL; |
| 11463 | } |
| 11464 | asdl_seq * res = NULL; |
| 11465 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11466 | { // small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11467 | stmt_ty elem; |
| 11468 | asdl_seq * seq; |
| 11469 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11470 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11471 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11472 | (seq = _loop0_13_rule(p)) // _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11473 | ) |
| 11474 | { |
| 11475 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11476 | goto done; |
| 11477 | } |
| 11478 | p->mark = mark; |
| 11479 | } |
| 11480 | res = NULL; |
| 11481 | done: |
| 11482 | return res; |
| 11483 | } |
| 11484 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11485 | // _tmp_14: 'import' | 'from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11486 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11487 | _tmp_14_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11488 | { |
| 11489 | if (p->error_indicator) { |
| 11490 | return NULL; |
| 11491 | } |
| 11492 | void * res = NULL; |
| 11493 | int mark = p->mark; |
| 11494 | { // 'import' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11495 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11496 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11497 | (keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11498 | ) |
| 11499 | { |
| 11500 | res = keyword; |
| 11501 | goto done; |
| 11502 | } |
| 11503 | p->mark = mark; |
| 11504 | } |
| 11505 | { // 'from' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11506 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11507 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11508 | (keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11509 | ) |
| 11510 | { |
| 11511 | res = keyword; |
| 11512 | goto done; |
| 11513 | } |
| 11514 | p->mark = mark; |
| 11515 | } |
| 11516 | res = NULL; |
| 11517 | done: |
| 11518 | return res; |
| 11519 | } |
| 11520 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11521 | // _tmp_15: 'def' | '@' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11522 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11523 | _tmp_15_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11524 | { |
| 11525 | if (p->error_indicator) { |
| 11526 | return NULL; |
| 11527 | } |
| 11528 | void * res = NULL; |
| 11529 | int mark = p->mark; |
| 11530 | { // 'def' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11531 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11532 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11533 | (keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11534 | ) |
| 11535 | { |
| 11536 | res = keyword; |
| 11537 | goto done; |
| 11538 | } |
| 11539 | p->mark = mark; |
| 11540 | } |
| 11541 | { // '@' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11542 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11543 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11544 | (literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11545 | ) |
| 11546 | { |
| 11547 | res = literal; |
| 11548 | goto done; |
| 11549 | } |
| 11550 | p->mark = mark; |
| 11551 | } |
| 11552 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11553 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11554 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11555 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11556 | ) |
| 11557 | { |
| 11558 | res = async_var; |
| 11559 | goto done; |
| 11560 | } |
| 11561 | p->mark = mark; |
| 11562 | } |
| 11563 | res = NULL; |
| 11564 | done: |
| 11565 | return res; |
| 11566 | } |
| 11567 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11568 | // _tmp_16: 'class' | '@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11569 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11570 | _tmp_16_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11571 | { |
| 11572 | if (p->error_indicator) { |
| 11573 | return NULL; |
| 11574 | } |
| 11575 | void * res = NULL; |
| 11576 | int mark = p->mark; |
| 11577 | { // 'class' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11578 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11579 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11580 | (keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11581 | ) |
| 11582 | { |
| 11583 | res = keyword; |
| 11584 | goto done; |
| 11585 | } |
| 11586 | p->mark = mark; |
| 11587 | } |
| 11588 | { // '@' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11589 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11590 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11591 | (literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11592 | ) |
| 11593 | { |
| 11594 | res = literal; |
| 11595 | goto done; |
| 11596 | } |
| 11597 | p->mark = mark; |
| 11598 | } |
| 11599 | res = NULL; |
| 11600 | done: |
| 11601 | return res; |
| 11602 | } |
| 11603 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11604 | // _tmp_17: 'with' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11605 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11606 | _tmp_17_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11607 | { |
| 11608 | if (p->error_indicator) { |
| 11609 | return NULL; |
| 11610 | } |
| 11611 | void * res = NULL; |
| 11612 | int mark = p->mark; |
| 11613 | { // 'with' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11614 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11615 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11616 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11617 | ) |
| 11618 | { |
| 11619 | res = keyword; |
| 11620 | goto done; |
| 11621 | } |
| 11622 | p->mark = mark; |
| 11623 | } |
| 11624 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11625 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11626 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11627 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11628 | ) |
| 11629 | { |
| 11630 | res = async_var; |
| 11631 | goto done; |
| 11632 | } |
| 11633 | p->mark = mark; |
| 11634 | } |
| 11635 | res = NULL; |
| 11636 | done: |
| 11637 | return res; |
| 11638 | } |
| 11639 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11640 | // _tmp_18: 'for' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11641 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11642 | _tmp_18_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11643 | { |
| 11644 | if (p->error_indicator) { |
| 11645 | return NULL; |
| 11646 | } |
| 11647 | void * res = NULL; |
| 11648 | int mark = p->mark; |
| 11649 | { // 'for' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11650 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11651 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11652 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11653 | ) |
| 11654 | { |
| 11655 | res = keyword; |
| 11656 | goto done; |
| 11657 | } |
| 11658 | p->mark = mark; |
| 11659 | } |
| 11660 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11661 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11662 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11663 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11664 | ) |
| 11665 | { |
| 11666 | res = async_var; |
| 11667 | goto done; |
| 11668 | } |
| 11669 | p->mark = mark; |
| 11670 | } |
| 11671 | res = NULL; |
| 11672 | done: |
| 11673 | return res; |
| 11674 | } |
| 11675 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11676 | // _tmp_19: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11677 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11678 | _tmp_19_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11679 | { |
| 11680 | if (p->error_indicator) { |
| 11681 | return NULL; |
| 11682 | } |
| 11683 | void * res = NULL; |
| 11684 | int mark = p->mark; |
| 11685 | { // '=' annotated_rhs |
| 11686 | expr_ty d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11687 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11688 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11689 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11690 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11691 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11692 | ) |
| 11693 | { |
| 11694 | res = d; |
| 11695 | if (res == NULL && PyErr_Occurred()) { |
| 11696 | p->error_indicator = 1; |
| 11697 | return NULL; |
| 11698 | } |
| 11699 | goto done; |
| 11700 | } |
| 11701 | p->mark = mark; |
| 11702 | } |
| 11703 | res = NULL; |
| 11704 | done: |
| 11705 | return res; |
| 11706 | } |
| 11707 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11708 | // _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11709 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11710 | _tmp_20_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11711 | { |
| 11712 | if (p->error_indicator) { |
| 11713 | return NULL; |
| 11714 | } |
| 11715 | void * res = NULL; |
| 11716 | int mark = p->mark; |
| 11717 | { // '(' inside_paren_ann_assign_target ')' |
| 11718 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11719 | Token * literal; |
| 11720 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11721 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11722 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11723 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11724 | (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] | 11725 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11726 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11727 | ) |
| 11728 | { |
| 11729 | res = b; |
| 11730 | if (res == NULL && PyErr_Occurred()) { |
| 11731 | p->error_indicator = 1; |
| 11732 | return NULL; |
| 11733 | } |
| 11734 | goto done; |
| 11735 | } |
| 11736 | p->mark = mark; |
| 11737 | } |
| 11738 | { // ann_assign_subscript_attribute_target |
| 11739 | expr_ty ann_assign_subscript_attribute_target_var; |
| 11740 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11741 | (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] | 11742 | ) |
| 11743 | { |
| 11744 | res = ann_assign_subscript_attribute_target_var; |
| 11745 | goto done; |
| 11746 | } |
| 11747 | p->mark = mark; |
| 11748 | } |
| 11749 | res = NULL; |
| 11750 | done: |
| 11751 | return res; |
| 11752 | } |
| 11753 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11754 | // _tmp_21: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11755 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11756 | _tmp_21_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11757 | { |
| 11758 | if (p->error_indicator) { |
| 11759 | return NULL; |
| 11760 | } |
| 11761 | void * res = NULL; |
| 11762 | int mark = p->mark; |
| 11763 | { // '=' annotated_rhs |
| 11764 | expr_ty d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11765 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11766 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11767 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11768 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11769 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11770 | ) |
| 11771 | { |
| 11772 | res = d; |
| 11773 | if (res == NULL && PyErr_Occurred()) { |
| 11774 | p->error_indicator = 1; |
| 11775 | return NULL; |
| 11776 | } |
| 11777 | goto done; |
| 11778 | } |
| 11779 | p->mark = mark; |
| 11780 | } |
| 11781 | res = NULL; |
| 11782 | done: |
| 11783 | return res; |
| 11784 | } |
| 11785 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11786 | // _loop1_22: (star_targets '=') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11787 | static asdl_seq * |
| 11788 | _loop1_22_rule(Parser *p) |
| 11789 | { |
| 11790 | if (p->error_indicator) { |
| 11791 | return NULL; |
| 11792 | } |
| 11793 | void *res = NULL; |
| 11794 | int mark = p->mark; |
| 11795 | int start_mark = p->mark; |
| 11796 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11797 | if (!children) { |
| 11798 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11799 | return NULL; |
| 11800 | } |
| 11801 | ssize_t children_capacity = 1; |
| 11802 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11803 | { // (star_targets '=') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11804 | void *_tmp_134_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11805 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11806 | (_tmp_134_var = _tmp_134_rule(p)) // star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11807 | ) |
| 11808 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11809 | res = _tmp_134_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11810 | if (n == children_capacity) { |
| 11811 | children_capacity *= 2; |
| 11812 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11813 | if (!children) { |
| 11814 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11815 | return NULL; |
| 11816 | } |
| 11817 | } |
| 11818 | children[n++] = res; |
| 11819 | mark = p->mark; |
| 11820 | } |
| 11821 | p->mark = mark; |
| 11822 | } |
| 11823 | if (n == 0) { |
| 11824 | PyMem_Free(children); |
| 11825 | return NULL; |
| 11826 | } |
| 11827 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11828 | if (!seq) { |
| 11829 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22"); |
| 11830 | PyMem_Free(children); |
| 11831 | return NULL; |
| 11832 | } |
| 11833 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11834 | PyMem_Free(children); |
| 11835 | _PyPegen_insert_memo(p, start_mark, _loop1_22_type, seq); |
| 11836 | return seq; |
| 11837 | } |
| 11838 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11839 | // _tmp_23: yield_expr | star_expressions |
| 11840 | static void * |
| 11841 | _tmp_23_rule(Parser *p) |
| 11842 | { |
| 11843 | if (p->error_indicator) { |
| 11844 | return NULL; |
| 11845 | } |
| 11846 | void * res = NULL; |
| 11847 | int mark = p->mark; |
| 11848 | { // yield_expr |
| 11849 | expr_ty yield_expr_var; |
| 11850 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11851 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11852 | ) |
| 11853 | { |
| 11854 | res = yield_expr_var; |
| 11855 | goto done; |
| 11856 | } |
| 11857 | p->mark = mark; |
| 11858 | } |
| 11859 | { // star_expressions |
| 11860 | expr_ty star_expressions_var; |
| 11861 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11862 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11863 | ) |
| 11864 | { |
| 11865 | res = star_expressions_var; |
| 11866 | goto done; |
| 11867 | } |
| 11868 | p->mark = mark; |
| 11869 | } |
| 11870 | res = NULL; |
| 11871 | done: |
| 11872 | return res; |
| 11873 | } |
| 11874 | |
| 11875 | // _tmp_24: yield_expr | star_expressions |
| 11876 | static void * |
| 11877 | _tmp_24_rule(Parser *p) |
| 11878 | { |
| 11879 | if (p->error_indicator) { |
| 11880 | return NULL; |
| 11881 | } |
| 11882 | void * res = NULL; |
| 11883 | int mark = p->mark; |
| 11884 | { // yield_expr |
| 11885 | expr_ty yield_expr_var; |
| 11886 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11887 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11888 | ) |
| 11889 | { |
| 11890 | res = yield_expr_var; |
| 11891 | goto done; |
| 11892 | } |
| 11893 | p->mark = mark; |
| 11894 | } |
| 11895 | { // star_expressions |
| 11896 | expr_ty star_expressions_var; |
| 11897 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11898 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11899 | ) |
| 11900 | { |
| 11901 | res = star_expressions_var; |
| 11902 | goto done; |
| 11903 | } |
| 11904 | p->mark = mark; |
| 11905 | } |
| 11906 | res = NULL; |
| 11907 | done: |
| 11908 | return res; |
| 11909 | } |
| 11910 | |
| 11911 | // _loop0_26: ',' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11912 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11913 | _loop0_26_rule(Parser *p) |
| 11914 | { |
| 11915 | if (p->error_indicator) { |
| 11916 | return NULL; |
| 11917 | } |
| 11918 | void *res = NULL; |
| 11919 | int mark = p->mark; |
| 11920 | int start_mark = p->mark; |
| 11921 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11922 | if (!children) { |
| 11923 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11924 | return NULL; |
| 11925 | } |
| 11926 | ssize_t children_capacity = 1; |
| 11927 | ssize_t n = 0; |
| 11928 | { // ',' NAME |
| 11929 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11930 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11931 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11932 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11933 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11934 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11935 | ) |
| 11936 | { |
| 11937 | res = elem; |
| 11938 | if (res == NULL && PyErr_Occurred()) { |
| 11939 | p->error_indicator = 1; |
| 11940 | PyMem_Free(children); |
| 11941 | return NULL; |
| 11942 | } |
| 11943 | if (n == children_capacity) { |
| 11944 | children_capacity *= 2; |
| 11945 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11946 | if (!children) { |
| 11947 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11948 | return NULL; |
| 11949 | } |
| 11950 | } |
| 11951 | children[n++] = res; |
| 11952 | mark = p->mark; |
| 11953 | } |
| 11954 | p->mark = mark; |
| 11955 | } |
| 11956 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11957 | if (!seq) { |
| 11958 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26"); |
| 11959 | PyMem_Free(children); |
| 11960 | return NULL; |
| 11961 | } |
| 11962 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11963 | PyMem_Free(children); |
| 11964 | _PyPegen_insert_memo(p, start_mark, _loop0_26_type, seq); |
| 11965 | return seq; |
| 11966 | } |
| 11967 | |
| 11968 | // _gather_25: NAME _loop0_26 |
| 11969 | static asdl_seq * |
| 11970 | _gather_25_rule(Parser *p) |
| 11971 | { |
| 11972 | if (p->error_indicator) { |
| 11973 | return NULL; |
| 11974 | } |
| 11975 | asdl_seq * res = NULL; |
| 11976 | int mark = p->mark; |
| 11977 | { // NAME _loop0_26 |
| 11978 | expr_ty elem; |
| 11979 | asdl_seq * seq; |
| 11980 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11981 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11982 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 11983 | (seq = _loop0_26_rule(p)) // _loop0_26 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11984 | ) |
| 11985 | { |
| 11986 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11987 | goto done; |
| 11988 | } |
| 11989 | p->mark = mark; |
| 11990 | } |
| 11991 | res = NULL; |
| 11992 | done: |
| 11993 | return res; |
| 11994 | } |
| 11995 | |
| 11996 | // _loop0_28: ',' NAME |
| 11997 | static asdl_seq * |
| 11998 | _loop0_28_rule(Parser *p) |
| 11999 | { |
| 12000 | if (p->error_indicator) { |
| 12001 | return NULL; |
| 12002 | } |
| 12003 | void *res = NULL; |
| 12004 | int mark = p->mark; |
| 12005 | int start_mark = p->mark; |
| 12006 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12007 | if (!children) { |
| 12008 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12009 | return NULL; |
| 12010 | } |
| 12011 | ssize_t children_capacity = 1; |
| 12012 | ssize_t n = 0; |
| 12013 | { // ',' NAME |
| 12014 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12015 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12016 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12017 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12018 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12019 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12020 | ) |
| 12021 | { |
| 12022 | res = elem; |
| 12023 | if (res == NULL && PyErr_Occurred()) { |
| 12024 | p->error_indicator = 1; |
| 12025 | PyMem_Free(children); |
| 12026 | return NULL; |
| 12027 | } |
| 12028 | if (n == children_capacity) { |
| 12029 | children_capacity *= 2; |
| 12030 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12031 | if (!children) { |
| 12032 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12033 | return NULL; |
| 12034 | } |
| 12035 | } |
| 12036 | children[n++] = res; |
| 12037 | mark = p->mark; |
| 12038 | } |
| 12039 | p->mark = mark; |
| 12040 | } |
| 12041 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12042 | if (!seq) { |
| 12043 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28"); |
| 12044 | PyMem_Free(children); |
| 12045 | return NULL; |
| 12046 | } |
| 12047 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12048 | PyMem_Free(children); |
| 12049 | _PyPegen_insert_memo(p, start_mark, _loop0_28_type, seq); |
| 12050 | return seq; |
| 12051 | } |
| 12052 | |
| 12053 | // _gather_27: NAME _loop0_28 |
| 12054 | static asdl_seq * |
| 12055 | _gather_27_rule(Parser *p) |
| 12056 | { |
| 12057 | if (p->error_indicator) { |
| 12058 | return NULL; |
| 12059 | } |
| 12060 | asdl_seq * res = NULL; |
| 12061 | int mark = p->mark; |
| 12062 | { // NAME _loop0_28 |
| 12063 | expr_ty elem; |
| 12064 | asdl_seq * seq; |
| 12065 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12066 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12067 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12068 | (seq = _loop0_28_rule(p)) // _loop0_28 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12069 | ) |
| 12070 | { |
| 12071 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12072 | goto done; |
| 12073 | } |
| 12074 | p->mark = mark; |
| 12075 | } |
| 12076 | res = NULL; |
| 12077 | done: |
| 12078 | return res; |
| 12079 | } |
| 12080 | |
| 12081 | // _tmp_29: ',' expression |
| 12082 | static void * |
| 12083 | _tmp_29_rule(Parser *p) |
| 12084 | { |
| 12085 | if (p->error_indicator) { |
| 12086 | return NULL; |
| 12087 | } |
| 12088 | void * res = NULL; |
| 12089 | int mark = p->mark; |
| 12090 | { // ',' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12091 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12092 | expr_ty z; |
| 12093 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12094 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12095 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12096 | (z = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12097 | ) |
| 12098 | { |
| 12099 | res = z; |
| 12100 | if (res == NULL && PyErr_Occurred()) { |
| 12101 | p->error_indicator = 1; |
| 12102 | return NULL; |
| 12103 | } |
| 12104 | goto done; |
| 12105 | } |
| 12106 | p->mark = mark; |
| 12107 | } |
| 12108 | res = NULL; |
| 12109 | done: |
| 12110 | return res; |
| 12111 | } |
| 12112 | |
| 12113 | // _loop0_30: ('.' | '...') |
| 12114 | static asdl_seq * |
| 12115 | _loop0_30_rule(Parser *p) |
| 12116 | { |
| 12117 | if (p->error_indicator) { |
| 12118 | return NULL; |
| 12119 | } |
| 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) { |
| 12125 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12126 | return NULL; |
| 12127 | } |
| 12128 | ssize_t children_capacity = 1; |
| 12129 | ssize_t n = 0; |
| 12130 | { // ('.' | '...') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12131 | void *_tmp_135_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12132 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12133 | (_tmp_135_var = _tmp_135_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12134 | ) |
| 12135 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12136 | res = _tmp_135_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12137 | if (n == children_capacity) { |
| 12138 | children_capacity *= 2; |
| 12139 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12140 | if (!children) { |
| 12141 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12142 | return NULL; |
| 12143 | } |
| 12144 | } |
| 12145 | children[n++] = res; |
| 12146 | mark = p->mark; |
| 12147 | } |
| 12148 | p->mark = mark; |
| 12149 | } |
| 12150 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12151 | if (!seq) { |
| 12152 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30"); |
| 12153 | PyMem_Free(children); |
| 12154 | return NULL; |
| 12155 | } |
| 12156 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12157 | PyMem_Free(children); |
| 12158 | _PyPegen_insert_memo(p, start_mark, _loop0_30_type, seq); |
| 12159 | return seq; |
| 12160 | } |
| 12161 | |
| 12162 | // _loop1_31: ('.' | '...') |
| 12163 | static asdl_seq * |
| 12164 | _loop1_31_rule(Parser *p) |
| 12165 | { |
| 12166 | if (p->error_indicator) { |
| 12167 | return NULL; |
| 12168 | } |
| 12169 | void *res = NULL; |
| 12170 | int mark = p->mark; |
| 12171 | int start_mark = p->mark; |
| 12172 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12173 | if (!children) { |
| 12174 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12175 | return NULL; |
| 12176 | } |
| 12177 | ssize_t children_capacity = 1; |
| 12178 | ssize_t n = 0; |
| 12179 | { // ('.' | '...') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12180 | void *_tmp_136_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12181 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12182 | (_tmp_136_var = _tmp_136_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12183 | ) |
| 12184 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12185 | res = _tmp_136_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12186 | if (n == children_capacity) { |
| 12187 | children_capacity *= 2; |
| 12188 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12189 | if (!children) { |
| 12190 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12191 | return NULL; |
| 12192 | } |
| 12193 | } |
| 12194 | children[n++] = res; |
| 12195 | mark = p->mark; |
| 12196 | } |
| 12197 | p->mark = mark; |
| 12198 | } |
| 12199 | if (n == 0) { |
| 12200 | PyMem_Free(children); |
| 12201 | return NULL; |
| 12202 | } |
| 12203 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12204 | if (!seq) { |
| 12205 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31"); |
| 12206 | PyMem_Free(children); |
| 12207 | return NULL; |
| 12208 | } |
| 12209 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12210 | PyMem_Free(children); |
| 12211 | _PyPegen_insert_memo(p, start_mark, _loop1_31_type, seq); |
| 12212 | return seq; |
| 12213 | } |
| 12214 | |
| 12215 | // _loop0_33: ',' import_from_as_name |
| 12216 | static asdl_seq * |
| 12217 | _loop0_33_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12218 | { |
| 12219 | if (p->error_indicator) { |
| 12220 | return NULL; |
| 12221 | } |
| 12222 | void *res = NULL; |
| 12223 | int mark = p->mark; |
| 12224 | int start_mark = p->mark; |
| 12225 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12226 | if (!children) { |
| 12227 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12228 | return NULL; |
| 12229 | } |
| 12230 | ssize_t children_capacity = 1; |
| 12231 | ssize_t n = 0; |
| 12232 | { // ',' import_from_as_name |
| 12233 | alias_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12234 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12235 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12236 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12237 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12238 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12239 | ) |
| 12240 | { |
| 12241 | res = elem; |
| 12242 | if (res == NULL && PyErr_Occurred()) { |
| 12243 | p->error_indicator = 1; |
| 12244 | PyMem_Free(children); |
| 12245 | return NULL; |
| 12246 | } |
| 12247 | if (n == children_capacity) { |
| 12248 | children_capacity *= 2; |
| 12249 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12250 | if (!children) { |
| 12251 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12252 | return NULL; |
| 12253 | } |
| 12254 | } |
| 12255 | children[n++] = res; |
| 12256 | mark = p->mark; |
| 12257 | } |
| 12258 | p->mark = mark; |
| 12259 | } |
| 12260 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12261 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12262 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12263 | PyMem_Free(children); |
| 12264 | return NULL; |
| 12265 | } |
| 12266 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12267 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12268 | _PyPegen_insert_memo(p, start_mark, _loop0_33_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12269 | return seq; |
| 12270 | } |
| 12271 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12272 | // _gather_32: import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12273 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12274 | _gather_32_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12275 | { |
| 12276 | if (p->error_indicator) { |
| 12277 | return NULL; |
| 12278 | } |
| 12279 | asdl_seq * res = NULL; |
| 12280 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12281 | { // import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12282 | alias_ty elem; |
| 12283 | asdl_seq * seq; |
| 12284 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12285 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12286 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12287 | (seq = _loop0_33_rule(p)) // _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12288 | ) |
| 12289 | { |
| 12290 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12291 | goto done; |
| 12292 | } |
| 12293 | p->mark = mark; |
| 12294 | } |
| 12295 | res = NULL; |
| 12296 | done: |
| 12297 | return res; |
| 12298 | } |
| 12299 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12300 | // _tmp_34: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12301 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12302 | _tmp_34_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12303 | { |
| 12304 | if (p->error_indicator) { |
| 12305 | return NULL; |
| 12306 | } |
| 12307 | void * res = NULL; |
| 12308 | int mark = p->mark; |
| 12309 | { // 'as' NAME |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12310 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12311 | expr_ty z; |
| 12312 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12313 | (keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12314 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12315 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12316 | ) |
| 12317 | { |
| 12318 | res = z; |
| 12319 | if (res == NULL && PyErr_Occurred()) { |
| 12320 | p->error_indicator = 1; |
| 12321 | return NULL; |
| 12322 | } |
| 12323 | goto done; |
| 12324 | } |
| 12325 | p->mark = mark; |
| 12326 | } |
| 12327 | res = NULL; |
| 12328 | done: |
| 12329 | return res; |
| 12330 | } |
| 12331 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12332 | // _loop0_36: ',' dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12333 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12334 | _loop0_36_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12335 | { |
| 12336 | if (p->error_indicator) { |
| 12337 | return NULL; |
| 12338 | } |
| 12339 | void *res = NULL; |
| 12340 | int mark = p->mark; |
| 12341 | int start_mark = p->mark; |
| 12342 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12343 | if (!children) { |
| 12344 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12345 | return NULL; |
| 12346 | } |
| 12347 | ssize_t children_capacity = 1; |
| 12348 | ssize_t n = 0; |
| 12349 | { // ',' dotted_as_name |
| 12350 | alias_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12351 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12352 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12353 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12354 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12355 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12356 | ) |
| 12357 | { |
| 12358 | res = elem; |
| 12359 | if (res == NULL && PyErr_Occurred()) { |
| 12360 | p->error_indicator = 1; |
| 12361 | PyMem_Free(children); |
| 12362 | return NULL; |
| 12363 | } |
| 12364 | if (n == children_capacity) { |
| 12365 | children_capacity *= 2; |
| 12366 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12367 | if (!children) { |
| 12368 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12369 | return NULL; |
| 12370 | } |
| 12371 | } |
| 12372 | children[n++] = res; |
| 12373 | mark = p->mark; |
| 12374 | } |
| 12375 | p->mark = mark; |
| 12376 | } |
| 12377 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12378 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12379 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12380 | PyMem_Free(children); |
| 12381 | return NULL; |
| 12382 | } |
| 12383 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12384 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12385 | _PyPegen_insert_memo(p, start_mark, _loop0_36_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12386 | return seq; |
| 12387 | } |
| 12388 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12389 | // _gather_35: dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12390 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12391 | _gather_35_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12392 | { |
| 12393 | if (p->error_indicator) { |
| 12394 | return NULL; |
| 12395 | } |
| 12396 | asdl_seq * res = NULL; |
| 12397 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12398 | { // dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12399 | alias_ty elem; |
| 12400 | asdl_seq * seq; |
| 12401 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12402 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12403 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12404 | (seq = _loop0_36_rule(p)) // _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12405 | ) |
| 12406 | { |
| 12407 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12408 | goto done; |
| 12409 | } |
| 12410 | p->mark = mark; |
| 12411 | } |
| 12412 | res = NULL; |
| 12413 | done: |
| 12414 | return res; |
| 12415 | } |
| 12416 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12417 | // _tmp_37: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12418 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12419 | _tmp_37_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 | } |
| 12424 | void * res = NULL; |
| 12425 | int mark = p->mark; |
| 12426 | { // 'as' NAME |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12427 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12428 | expr_ty z; |
| 12429 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12430 | (keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12431 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12432 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12433 | ) |
| 12434 | { |
| 12435 | res = z; |
| 12436 | if (res == NULL && PyErr_Occurred()) { |
| 12437 | p->error_indicator = 1; |
| 12438 | return NULL; |
| 12439 | } |
| 12440 | goto done; |
| 12441 | } |
| 12442 | p->mark = mark; |
| 12443 | } |
| 12444 | res = NULL; |
| 12445 | done: |
| 12446 | return res; |
| 12447 | } |
| 12448 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12449 | // _loop0_39: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12450 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12451 | _loop0_39_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12452 | { |
| 12453 | if (p->error_indicator) { |
| 12454 | return NULL; |
| 12455 | } |
| 12456 | void *res = NULL; |
| 12457 | int mark = p->mark; |
| 12458 | int start_mark = p->mark; |
| 12459 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12460 | if (!children) { |
| 12461 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12462 | return NULL; |
| 12463 | } |
| 12464 | ssize_t children_capacity = 1; |
| 12465 | ssize_t n = 0; |
| 12466 | { // ',' with_item |
| 12467 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12468 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12469 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12470 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12471 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12472 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12473 | ) |
| 12474 | { |
| 12475 | res = elem; |
| 12476 | if (res == NULL && PyErr_Occurred()) { |
| 12477 | p->error_indicator = 1; |
| 12478 | PyMem_Free(children); |
| 12479 | return NULL; |
| 12480 | } |
| 12481 | if (n == children_capacity) { |
| 12482 | children_capacity *= 2; |
| 12483 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12484 | if (!children) { |
| 12485 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12486 | return NULL; |
| 12487 | } |
| 12488 | } |
| 12489 | children[n++] = res; |
| 12490 | mark = p->mark; |
| 12491 | } |
| 12492 | p->mark = mark; |
| 12493 | } |
| 12494 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12495 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12496 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12497 | PyMem_Free(children); |
| 12498 | return NULL; |
| 12499 | } |
| 12500 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12501 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12502 | _PyPegen_insert_memo(p, start_mark, _loop0_39_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12503 | return seq; |
| 12504 | } |
| 12505 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12506 | // _gather_38: with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12507 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12508 | _gather_38_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12509 | { |
| 12510 | if (p->error_indicator) { |
| 12511 | return NULL; |
| 12512 | } |
| 12513 | asdl_seq * res = NULL; |
| 12514 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12515 | { // with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12516 | withitem_ty elem; |
| 12517 | asdl_seq * seq; |
| 12518 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12519 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12520 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12521 | (seq = _loop0_39_rule(p)) // _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12522 | ) |
| 12523 | { |
| 12524 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12525 | goto done; |
| 12526 | } |
| 12527 | p->mark = mark; |
| 12528 | } |
| 12529 | res = NULL; |
| 12530 | done: |
| 12531 | return res; |
| 12532 | } |
| 12533 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12534 | // _loop0_41: ',' with_item |
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_41_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 | } |
| 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) { |
| 12546 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12547 | return NULL; |
| 12548 | } |
| 12549 | ssize_t children_capacity = 1; |
| 12550 | ssize_t n = 0; |
| 12551 | { // ',' with_item |
| 12552 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12553 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12554 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +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 = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12558 | ) |
| 12559 | { |
| 12560 | res = elem; |
| 12561 | if (res == NULL && PyErr_Occurred()) { |
| 12562 | p->error_indicator = 1; |
| 12563 | PyMem_Free(children); |
| 12564 | return NULL; |
| 12565 | } |
| 12566 | if (n == children_capacity) { |
| 12567 | children_capacity *= 2; |
| 12568 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12569 | if (!children) { |
| 12570 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12571 | return NULL; |
| 12572 | } |
| 12573 | } |
| 12574 | children[n++] = res; |
| 12575 | mark = p->mark; |
| 12576 | } |
| 12577 | p->mark = mark; |
| 12578 | } |
| 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_41"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12582 | PyMem_Free(children); |
| 12583 | return NULL; |
| 12584 | } |
| 12585 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12586 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12587 | _PyPegen_insert_memo(p, start_mark, _loop0_41_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12588 | return seq; |
| 12589 | } |
| 12590 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12591 | // _gather_40: with_item _loop0_41 |
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_40_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 | } |
| 12598 | asdl_seq * res = NULL; |
| 12599 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12600 | { // with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12601 | withitem_ty elem; |
| 12602 | asdl_seq * seq; |
| 12603 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12604 | (elem = with_item_rule(p)) // with_item |
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_41_rule(p)) // _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12607 | ) |
| 12608 | { |
| 12609 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12610 | goto done; |
| 12611 | } |
| 12612 | p->mark = mark; |
| 12613 | } |
| 12614 | res = NULL; |
| 12615 | done: |
| 12616 | return res; |
| 12617 | } |
| 12618 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12619 | // _loop0_43: ',' with_item |
| 12620 | static asdl_seq * |
| 12621 | _loop0_43_rule(Parser *p) |
| 12622 | { |
| 12623 | if (p->error_indicator) { |
| 12624 | return NULL; |
| 12625 | } |
| 12626 | void *res = NULL; |
| 12627 | int mark = p->mark; |
| 12628 | int start_mark = p->mark; |
| 12629 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12630 | if (!children) { |
| 12631 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12632 | return NULL; |
| 12633 | } |
| 12634 | ssize_t children_capacity = 1; |
| 12635 | ssize_t n = 0; |
| 12636 | { // ',' with_item |
| 12637 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12638 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12639 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12640 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12641 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12642 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12643 | ) |
| 12644 | { |
| 12645 | res = elem; |
| 12646 | if (res == NULL && PyErr_Occurred()) { |
| 12647 | p->error_indicator = 1; |
| 12648 | PyMem_Free(children); |
| 12649 | return NULL; |
| 12650 | } |
| 12651 | if (n == children_capacity) { |
| 12652 | children_capacity *= 2; |
| 12653 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12654 | if (!children) { |
| 12655 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12656 | return NULL; |
| 12657 | } |
| 12658 | } |
| 12659 | children[n++] = res; |
| 12660 | mark = p->mark; |
| 12661 | } |
| 12662 | p->mark = mark; |
| 12663 | } |
| 12664 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12665 | if (!seq) { |
| 12666 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43"); |
| 12667 | PyMem_Free(children); |
| 12668 | return NULL; |
| 12669 | } |
| 12670 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12671 | PyMem_Free(children); |
| 12672 | _PyPegen_insert_memo(p, start_mark, _loop0_43_type, seq); |
| 12673 | return seq; |
| 12674 | } |
| 12675 | |
| 12676 | // _gather_42: with_item _loop0_43 |
| 12677 | static asdl_seq * |
| 12678 | _gather_42_rule(Parser *p) |
| 12679 | { |
| 12680 | if (p->error_indicator) { |
| 12681 | return NULL; |
| 12682 | } |
| 12683 | asdl_seq * res = NULL; |
| 12684 | int mark = p->mark; |
| 12685 | { // with_item _loop0_43 |
| 12686 | withitem_ty elem; |
| 12687 | asdl_seq * seq; |
| 12688 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12689 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12690 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12691 | (seq = _loop0_43_rule(p)) // _loop0_43 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12692 | ) |
| 12693 | { |
| 12694 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12695 | goto done; |
| 12696 | } |
| 12697 | p->mark = mark; |
| 12698 | } |
| 12699 | res = NULL; |
| 12700 | done: |
| 12701 | return res; |
| 12702 | } |
| 12703 | |
| 12704 | // _loop0_45: ',' with_item |
| 12705 | static asdl_seq * |
| 12706 | _loop0_45_rule(Parser *p) |
| 12707 | { |
| 12708 | if (p->error_indicator) { |
| 12709 | return NULL; |
| 12710 | } |
| 12711 | void *res = NULL; |
| 12712 | int mark = p->mark; |
| 12713 | int start_mark = p->mark; |
| 12714 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12715 | if (!children) { |
| 12716 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12717 | return NULL; |
| 12718 | } |
| 12719 | ssize_t children_capacity = 1; |
| 12720 | ssize_t n = 0; |
| 12721 | { // ',' with_item |
| 12722 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12723 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12724 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12725 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12726 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12727 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12728 | ) |
| 12729 | { |
| 12730 | res = elem; |
| 12731 | if (res == NULL && PyErr_Occurred()) { |
| 12732 | p->error_indicator = 1; |
| 12733 | PyMem_Free(children); |
| 12734 | return NULL; |
| 12735 | } |
| 12736 | if (n == children_capacity) { |
| 12737 | children_capacity *= 2; |
| 12738 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12739 | if (!children) { |
| 12740 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12741 | return NULL; |
| 12742 | } |
| 12743 | } |
| 12744 | children[n++] = res; |
| 12745 | mark = p->mark; |
| 12746 | } |
| 12747 | p->mark = mark; |
| 12748 | } |
| 12749 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12750 | if (!seq) { |
| 12751 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45"); |
| 12752 | PyMem_Free(children); |
| 12753 | return NULL; |
| 12754 | } |
| 12755 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12756 | PyMem_Free(children); |
| 12757 | _PyPegen_insert_memo(p, start_mark, _loop0_45_type, seq); |
| 12758 | return seq; |
| 12759 | } |
| 12760 | |
| 12761 | // _gather_44: with_item _loop0_45 |
| 12762 | static asdl_seq * |
| 12763 | _gather_44_rule(Parser *p) |
| 12764 | { |
| 12765 | if (p->error_indicator) { |
| 12766 | return NULL; |
| 12767 | } |
| 12768 | asdl_seq * res = NULL; |
| 12769 | int mark = p->mark; |
| 12770 | { // with_item _loop0_45 |
| 12771 | withitem_ty elem; |
| 12772 | asdl_seq * seq; |
| 12773 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12774 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12775 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12776 | (seq = _loop0_45_rule(p)) // _loop0_45 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12777 | ) |
| 12778 | { |
| 12779 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12780 | goto done; |
| 12781 | } |
| 12782 | p->mark = mark; |
| 12783 | } |
| 12784 | res = NULL; |
| 12785 | done: |
| 12786 | return res; |
| 12787 | } |
| 12788 | |
| 12789 | // _tmp_46: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12790 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12791 | _tmp_46_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12792 | { |
| 12793 | if (p->error_indicator) { |
| 12794 | return NULL; |
| 12795 | } |
| 12796 | void * res = NULL; |
| 12797 | int mark = p->mark; |
| 12798 | { // 'as' target |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12799 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12800 | expr_ty t; |
| 12801 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12802 | (keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12803 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12804 | (t = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12805 | ) |
| 12806 | { |
| 12807 | res = t; |
| 12808 | if (res == NULL && PyErr_Occurred()) { |
| 12809 | p->error_indicator = 1; |
| 12810 | return NULL; |
| 12811 | } |
| 12812 | goto done; |
| 12813 | } |
| 12814 | p->mark = mark; |
| 12815 | } |
| 12816 | res = NULL; |
| 12817 | done: |
| 12818 | return res; |
| 12819 | } |
| 12820 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12821 | // _loop1_47: except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12822 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12823 | _loop1_47_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12824 | { |
| 12825 | if (p->error_indicator) { |
| 12826 | return NULL; |
| 12827 | } |
| 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) { |
| 12833 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12834 | return NULL; |
| 12835 | } |
| 12836 | ssize_t children_capacity = 1; |
| 12837 | ssize_t n = 0; |
| 12838 | { // except_block |
| 12839 | excepthandler_ty except_block_var; |
| 12840 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12841 | (except_block_var = except_block_rule(p)) // except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12842 | ) |
| 12843 | { |
| 12844 | res = except_block_var; |
| 12845 | if (n == children_capacity) { |
| 12846 | children_capacity *= 2; |
| 12847 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12848 | if (!children) { |
| 12849 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12850 | return NULL; |
| 12851 | } |
| 12852 | } |
| 12853 | children[n++] = res; |
| 12854 | mark = p->mark; |
| 12855 | } |
| 12856 | p->mark = mark; |
| 12857 | } |
| 12858 | if (n == 0) { |
| 12859 | PyMem_Free(children); |
| 12860 | return NULL; |
| 12861 | } |
| 12862 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12863 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12864 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12865 | PyMem_Free(children); |
| 12866 | return NULL; |
| 12867 | } |
| 12868 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12869 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12870 | _PyPegen_insert_memo(p, start_mark, _loop1_47_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12871 | return seq; |
| 12872 | } |
| 12873 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12874 | // _tmp_48: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12875 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12876 | _tmp_48_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12877 | { |
| 12878 | if (p->error_indicator) { |
| 12879 | return NULL; |
| 12880 | } |
| 12881 | void * res = NULL; |
| 12882 | int mark = p->mark; |
| 12883 | { // 'as' target |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12884 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12885 | expr_ty z; |
| 12886 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12887 | (keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12888 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12889 | (z = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12890 | ) |
| 12891 | { |
| 12892 | res = z; |
| 12893 | if (res == NULL && PyErr_Occurred()) { |
| 12894 | p->error_indicator = 1; |
| 12895 | return NULL; |
| 12896 | } |
| 12897 | goto done; |
| 12898 | } |
| 12899 | p->mark = mark; |
| 12900 | } |
| 12901 | res = NULL; |
| 12902 | done: |
| 12903 | return res; |
| 12904 | } |
| 12905 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12906 | // _tmp_49: 'from' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12907 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12908 | _tmp_49_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12909 | { |
| 12910 | if (p->error_indicator) { |
| 12911 | return NULL; |
| 12912 | } |
| 12913 | void * res = NULL; |
| 12914 | int mark = p->mark; |
| 12915 | { // 'from' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12916 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12917 | expr_ty z; |
| 12918 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12919 | (keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12920 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12921 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12922 | ) |
| 12923 | { |
| 12924 | res = z; |
| 12925 | if (res == NULL && PyErr_Occurred()) { |
| 12926 | p->error_indicator = 1; |
| 12927 | return NULL; |
| 12928 | } |
| 12929 | goto done; |
| 12930 | } |
| 12931 | p->mark = mark; |
| 12932 | } |
| 12933 | res = NULL; |
| 12934 | done: |
| 12935 | return res; |
| 12936 | } |
| 12937 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12938 | // _tmp_50: '->' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12939 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12940 | _tmp_50_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12941 | { |
| 12942 | if (p->error_indicator) { |
| 12943 | return NULL; |
| 12944 | } |
| 12945 | void * res = NULL; |
| 12946 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12947 | { // '->' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12948 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12949 | expr_ty z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12950 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12951 | (literal = _PyPegen_expect_token(p, 51)) // token='->' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12952 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12953 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12954 | ) |
| 12955 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12956 | res = z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12957 | if (res == NULL && PyErr_Occurred()) { |
| 12958 | p->error_indicator = 1; |
| 12959 | return NULL; |
| 12960 | } |
| 12961 | goto done; |
| 12962 | } |
| 12963 | p->mark = mark; |
| 12964 | } |
| 12965 | res = NULL; |
| 12966 | done: |
| 12967 | return res; |
| 12968 | } |
| 12969 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12970 | // _tmp_51: '->' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12971 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12972 | _tmp_51_rule(Parser *p) |
| 12973 | { |
| 12974 | if (p->error_indicator) { |
| 12975 | return NULL; |
| 12976 | } |
| 12977 | void * res = NULL; |
| 12978 | int mark = p->mark; |
| 12979 | { // '->' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12980 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12981 | expr_ty z; |
| 12982 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12983 | (literal = _PyPegen_expect_token(p, 51)) // token='->' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12984 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 12985 | (z = expression_rule(p)) // expression |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12986 | ) |
| 12987 | { |
| 12988 | res = z; |
| 12989 | if (res == NULL && PyErr_Occurred()) { |
| 12990 | p->error_indicator = 1; |
| 12991 | return NULL; |
| 12992 | } |
| 12993 | goto done; |
| 12994 | } |
| 12995 | p->mark = mark; |
| 12996 | } |
| 12997 | res = NULL; |
| 12998 | done: |
| 12999 | return res; |
| 13000 | } |
| 13001 | |
| 13002 | // _tmp_52: NEWLINE INDENT |
| 13003 | static void * |
| 13004 | _tmp_52_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13005 | { |
| 13006 | if (p->error_indicator) { |
| 13007 | return NULL; |
| 13008 | } |
| 13009 | void * res = NULL; |
| 13010 | int mark = p->mark; |
| 13011 | { // NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13012 | Token * indent_var; |
| 13013 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13014 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13015 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13016 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13017 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13018 | ) |
| 13019 | { |
| 13020 | res = _PyPegen_dummy_name(p, newline_var, indent_var); |
| 13021 | goto done; |
| 13022 | } |
| 13023 | p->mark = mark; |
| 13024 | } |
| 13025 | res = NULL; |
| 13026 | done: |
| 13027 | return res; |
| 13028 | } |
| 13029 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13030 | // _loop0_53: param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13031 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13032 | _loop0_53_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13033 | { |
| 13034 | if (p->error_indicator) { |
| 13035 | return NULL; |
| 13036 | } |
| 13037 | void *res = NULL; |
| 13038 | int mark = p->mark; |
| 13039 | int start_mark = p->mark; |
| 13040 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13041 | if (!children) { |
| 13042 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13043 | return NULL; |
| 13044 | } |
| 13045 | ssize_t children_capacity = 1; |
| 13046 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13047 | { // param_no_default |
| 13048 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13049 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13050 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13051 | ) |
| 13052 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13053 | res = param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13054 | if (n == children_capacity) { |
| 13055 | children_capacity *= 2; |
| 13056 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13057 | if (!children) { |
| 13058 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13059 | return NULL; |
| 13060 | } |
| 13061 | } |
| 13062 | children[n++] = res; |
| 13063 | mark = p->mark; |
| 13064 | } |
| 13065 | p->mark = mark; |
| 13066 | } |
| 13067 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13068 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13069 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13070 | PyMem_Free(children); |
| 13071 | return NULL; |
| 13072 | } |
| 13073 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13074 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13075 | _PyPegen_insert_memo(p, start_mark, _loop0_53_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13076 | return seq; |
| 13077 | } |
| 13078 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13079 | // _loop0_54: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13080 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13081 | _loop0_54_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13082 | { |
| 13083 | if (p->error_indicator) { |
| 13084 | return NULL; |
| 13085 | } |
| 13086 | void *res = NULL; |
| 13087 | int mark = p->mark; |
| 13088 | int start_mark = p->mark; |
| 13089 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13090 | if (!children) { |
| 13091 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13092 | return NULL; |
| 13093 | } |
| 13094 | ssize_t children_capacity = 1; |
| 13095 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13096 | { // param_with_default |
| 13097 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13098 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13099 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13100 | ) |
| 13101 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13102 | res = param_with_default_var; |
| 13103 | if (n == children_capacity) { |
| 13104 | children_capacity *= 2; |
| 13105 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13106 | if (!children) { |
| 13107 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13108 | return NULL; |
| 13109 | } |
| 13110 | } |
| 13111 | children[n++] = res; |
| 13112 | mark = p->mark; |
| 13113 | } |
| 13114 | p->mark = mark; |
| 13115 | } |
| 13116 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13117 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13118 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13119 | PyMem_Free(children); |
| 13120 | return NULL; |
| 13121 | } |
| 13122 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13123 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13124 | _PyPegen_insert_memo(p, start_mark, _loop0_54_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13125 | return seq; |
| 13126 | } |
| 13127 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13128 | // _loop0_55: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13129 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13130 | _loop0_55_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13131 | { |
| 13132 | if (p->error_indicator) { |
| 13133 | return NULL; |
| 13134 | } |
| 13135 | void *res = NULL; |
| 13136 | int mark = p->mark; |
| 13137 | int start_mark = p->mark; |
| 13138 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13139 | if (!children) { |
| 13140 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13141 | return NULL; |
| 13142 | } |
| 13143 | ssize_t children_capacity = 1; |
| 13144 | ssize_t n = 0; |
| 13145 | { // param_with_default |
| 13146 | NameDefaultPair* param_with_default_var; |
| 13147 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13148 | (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] | 13149 | ) |
| 13150 | { |
| 13151 | res = param_with_default_var; |
| 13152 | if (n == children_capacity) { |
| 13153 | children_capacity *= 2; |
| 13154 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13155 | if (!children) { |
| 13156 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13157 | return NULL; |
| 13158 | } |
| 13159 | } |
| 13160 | children[n++] = res; |
| 13161 | mark = p->mark; |
| 13162 | } |
| 13163 | p->mark = mark; |
| 13164 | } |
| 13165 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13166 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13167 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13168 | PyMem_Free(children); |
| 13169 | return NULL; |
| 13170 | } |
| 13171 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13172 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13173 | _PyPegen_insert_memo(p, start_mark, _loop0_55_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13174 | return seq; |
| 13175 | } |
| 13176 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13177 | // _loop1_56: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13178 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13179 | _loop1_56_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13180 | { |
| 13181 | if (p->error_indicator) { |
| 13182 | return NULL; |
| 13183 | } |
| 13184 | void *res = NULL; |
| 13185 | int mark = p->mark; |
| 13186 | int start_mark = p->mark; |
| 13187 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13188 | if (!children) { |
| 13189 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13190 | return NULL; |
| 13191 | } |
| 13192 | ssize_t children_capacity = 1; |
| 13193 | ssize_t n = 0; |
| 13194 | { // param_no_default |
| 13195 | arg_ty param_no_default_var; |
| 13196 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13197 | (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] | 13198 | ) |
| 13199 | { |
| 13200 | res = param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13201 | if (n == children_capacity) { |
| 13202 | children_capacity *= 2; |
| 13203 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13204 | if (!children) { |
| 13205 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13206 | return NULL; |
| 13207 | } |
| 13208 | } |
| 13209 | children[n++] = res; |
| 13210 | mark = p->mark; |
| 13211 | } |
| 13212 | p->mark = mark; |
| 13213 | } |
| 13214 | if (n == 0) { |
| 13215 | PyMem_Free(children); |
| 13216 | return NULL; |
| 13217 | } |
| 13218 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13219 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13220 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13221 | PyMem_Free(children); |
| 13222 | return NULL; |
| 13223 | } |
| 13224 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13225 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13226 | _PyPegen_insert_memo(p, start_mark, _loop1_56_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13227 | return seq; |
| 13228 | } |
| 13229 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13230 | // _loop0_57: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13231 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13232 | _loop0_57_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13233 | { |
| 13234 | if (p->error_indicator) { |
| 13235 | return NULL; |
| 13236 | } |
| 13237 | void *res = NULL; |
| 13238 | int mark = p->mark; |
| 13239 | int start_mark = p->mark; |
| 13240 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13241 | if (!children) { |
| 13242 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13243 | return NULL; |
| 13244 | } |
| 13245 | ssize_t children_capacity = 1; |
| 13246 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13247 | { // param_with_default |
| 13248 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13249 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13250 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13251 | ) |
| 13252 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13253 | res = param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13254 | if (n == children_capacity) { |
| 13255 | children_capacity *= 2; |
| 13256 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13257 | if (!children) { |
| 13258 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13259 | return NULL; |
| 13260 | } |
| 13261 | } |
| 13262 | children[n++] = res; |
| 13263 | mark = p->mark; |
| 13264 | } |
| 13265 | p->mark = mark; |
| 13266 | } |
| 13267 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13268 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13269 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13270 | PyMem_Free(children); |
| 13271 | return NULL; |
| 13272 | } |
| 13273 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13274 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13275 | _PyPegen_insert_memo(p, start_mark, _loop0_57_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13276 | return seq; |
| 13277 | } |
| 13278 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13279 | // _loop1_58: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13280 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13281 | _loop1_58_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13282 | { |
| 13283 | if (p->error_indicator) { |
| 13284 | return NULL; |
| 13285 | } |
| 13286 | void *res = NULL; |
| 13287 | int mark = p->mark; |
| 13288 | int start_mark = p->mark; |
| 13289 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13290 | if (!children) { |
| 13291 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13292 | return NULL; |
| 13293 | } |
| 13294 | ssize_t children_capacity = 1; |
| 13295 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13296 | { // param_with_default |
| 13297 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13298 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13299 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13300 | ) |
| 13301 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13302 | res = param_with_default_var; |
| 13303 | if (n == children_capacity) { |
| 13304 | children_capacity *= 2; |
| 13305 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13306 | if (!children) { |
| 13307 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13308 | return NULL; |
| 13309 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13310 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13311 | children[n++] = res; |
| 13312 | mark = p->mark; |
| 13313 | } |
| 13314 | p->mark = mark; |
| 13315 | } |
| 13316 | if (n == 0) { |
| 13317 | PyMem_Free(children); |
| 13318 | return NULL; |
| 13319 | } |
| 13320 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13321 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13322 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13323 | PyMem_Free(children); |
| 13324 | return NULL; |
| 13325 | } |
| 13326 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13327 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13328 | _PyPegen_insert_memo(p, start_mark, _loop1_58_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13329 | return seq; |
| 13330 | } |
| 13331 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13332 | // _loop1_59: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13333 | static asdl_seq * |
| 13334 | _loop1_59_rule(Parser *p) |
| 13335 | { |
| 13336 | if (p->error_indicator) { |
| 13337 | return NULL; |
| 13338 | } |
| 13339 | void *res = NULL; |
| 13340 | int mark = p->mark; |
| 13341 | int start_mark = p->mark; |
| 13342 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13343 | if (!children) { |
| 13344 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13345 | return NULL; |
| 13346 | } |
| 13347 | ssize_t children_capacity = 1; |
| 13348 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13349 | { // param_no_default |
| 13350 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13351 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13352 | (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] | 13353 | ) |
| 13354 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13355 | res = param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13356 | if (n == children_capacity) { |
| 13357 | children_capacity *= 2; |
| 13358 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13359 | if (!children) { |
| 13360 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13361 | return NULL; |
| 13362 | } |
| 13363 | } |
| 13364 | children[n++] = res; |
| 13365 | mark = p->mark; |
| 13366 | } |
| 13367 | p->mark = mark; |
| 13368 | } |
| 13369 | if (n == 0) { |
| 13370 | PyMem_Free(children); |
| 13371 | return NULL; |
| 13372 | } |
| 13373 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13374 | if (!seq) { |
| 13375 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59"); |
| 13376 | PyMem_Free(children); |
| 13377 | return NULL; |
| 13378 | } |
| 13379 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13380 | PyMem_Free(children); |
| 13381 | _PyPegen_insert_memo(p, start_mark, _loop1_59_type, seq); |
| 13382 | return seq; |
| 13383 | } |
| 13384 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13385 | // _loop1_60: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13386 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13387 | _loop1_60_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13388 | { |
| 13389 | if (p->error_indicator) { |
| 13390 | return NULL; |
| 13391 | } |
| 13392 | void *res = NULL; |
| 13393 | int mark = p->mark; |
| 13394 | int start_mark = p->mark; |
| 13395 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13396 | if (!children) { |
| 13397 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13398 | return NULL; |
| 13399 | } |
| 13400 | ssize_t children_capacity = 1; |
| 13401 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13402 | { // param_no_default |
| 13403 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13404 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13405 | (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] | 13406 | ) |
| 13407 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13408 | res = param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13409 | if (n == children_capacity) { |
| 13410 | children_capacity *= 2; |
| 13411 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13412 | if (!children) { |
| 13413 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13414 | return NULL; |
| 13415 | } |
| 13416 | } |
| 13417 | children[n++] = res; |
| 13418 | mark = p->mark; |
| 13419 | } |
| 13420 | p->mark = mark; |
| 13421 | } |
| 13422 | if (n == 0) { |
| 13423 | PyMem_Free(children); |
| 13424 | return NULL; |
| 13425 | } |
| 13426 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13427 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13428 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13429 | PyMem_Free(children); |
| 13430 | return NULL; |
| 13431 | } |
| 13432 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13433 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13434 | _PyPegen_insert_memo(p, start_mark, _loop1_60_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13435 | return seq; |
| 13436 | } |
| 13437 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13438 | // _loop0_61: param_no_default |
| 13439 | static asdl_seq * |
| 13440 | _loop0_61_rule(Parser *p) |
| 13441 | { |
| 13442 | if (p->error_indicator) { |
| 13443 | return NULL; |
| 13444 | } |
| 13445 | void *res = NULL; |
| 13446 | int mark = p->mark; |
| 13447 | int start_mark = p->mark; |
| 13448 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13449 | if (!children) { |
| 13450 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13451 | return NULL; |
| 13452 | } |
| 13453 | ssize_t children_capacity = 1; |
| 13454 | ssize_t n = 0; |
| 13455 | { // param_no_default |
| 13456 | arg_ty param_no_default_var; |
| 13457 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13458 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13459 | ) |
| 13460 | { |
| 13461 | res = param_no_default_var; |
| 13462 | if (n == children_capacity) { |
| 13463 | children_capacity *= 2; |
| 13464 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13465 | if (!children) { |
| 13466 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13467 | return NULL; |
| 13468 | } |
| 13469 | } |
| 13470 | children[n++] = res; |
| 13471 | mark = p->mark; |
| 13472 | } |
| 13473 | p->mark = mark; |
| 13474 | } |
| 13475 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13476 | if (!seq) { |
| 13477 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61"); |
| 13478 | PyMem_Free(children); |
| 13479 | return NULL; |
| 13480 | } |
| 13481 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13482 | PyMem_Free(children); |
| 13483 | _PyPegen_insert_memo(p, start_mark, _loop0_61_type, seq); |
| 13484 | return seq; |
| 13485 | } |
| 13486 | |
| 13487 | // _loop1_62: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13488 | static asdl_seq * |
| 13489 | _loop1_62_rule(Parser *p) |
| 13490 | { |
| 13491 | if (p->error_indicator) { |
| 13492 | return NULL; |
| 13493 | } |
| 13494 | void *res = NULL; |
| 13495 | int mark = p->mark; |
| 13496 | int start_mark = p->mark; |
| 13497 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13498 | if (!children) { |
| 13499 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13500 | return NULL; |
| 13501 | } |
| 13502 | ssize_t children_capacity = 1; |
| 13503 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13504 | { // param_with_default |
| 13505 | NameDefaultPair* param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13506 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13507 | (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] | 13508 | ) |
| 13509 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13510 | res = param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13511 | if (n == children_capacity) { |
| 13512 | children_capacity *= 2; |
| 13513 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13514 | if (!children) { |
| 13515 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13516 | return NULL; |
| 13517 | } |
| 13518 | } |
| 13519 | children[n++] = res; |
| 13520 | mark = p->mark; |
| 13521 | } |
| 13522 | p->mark = mark; |
| 13523 | } |
| 13524 | if (n == 0) { |
| 13525 | PyMem_Free(children); |
| 13526 | return NULL; |
| 13527 | } |
| 13528 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13529 | if (!seq) { |
| 13530 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62"); |
| 13531 | PyMem_Free(children); |
| 13532 | return NULL; |
| 13533 | } |
| 13534 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13535 | PyMem_Free(children); |
| 13536 | _PyPegen_insert_memo(p, start_mark, _loop1_62_type, seq); |
| 13537 | return seq; |
| 13538 | } |
| 13539 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13540 | // _loop0_63: param_no_default |
| 13541 | static asdl_seq * |
| 13542 | _loop0_63_rule(Parser *p) |
| 13543 | { |
| 13544 | if (p->error_indicator) { |
| 13545 | return NULL; |
| 13546 | } |
| 13547 | void *res = NULL; |
| 13548 | int mark = p->mark; |
| 13549 | int start_mark = p->mark; |
| 13550 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13551 | if (!children) { |
| 13552 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13553 | return NULL; |
| 13554 | } |
| 13555 | ssize_t children_capacity = 1; |
| 13556 | ssize_t n = 0; |
| 13557 | { // param_no_default |
| 13558 | arg_ty param_no_default_var; |
| 13559 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13560 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13561 | ) |
| 13562 | { |
| 13563 | res = param_no_default_var; |
| 13564 | if (n == children_capacity) { |
| 13565 | children_capacity *= 2; |
| 13566 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13567 | if (!children) { |
| 13568 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13569 | return NULL; |
| 13570 | } |
| 13571 | } |
| 13572 | children[n++] = res; |
| 13573 | mark = p->mark; |
| 13574 | } |
| 13575 | p->mark = mark; |
| 13576 | } |
| 13577 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13578 | if (!seq) { |
| 13579 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63"); |
| 13580 | PyMem_Free(children); |
| 13581 | return NULL; |
| 13582 | } |
| 13583 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13584 | PyMem_Free(children); |
| 13585 | _PyPegen_insert_memo(p, start_mark, _loop0_63_type, seq); |
| 13586 | return seq; |
| 13587 | } |
| 13588 | |
| 13589 | // _loop1_64: param_with_default |
| 13590 | static asdl_seq * |
| 13591 | _loop1_64_rule(Parser *p) |
| 13592 | { |
| 13593 | if (p->error_indicator) { |
| 13594 | return NULL; |
| 13595 | } |
| 13596 | void *res = NULL; |
| 13597 | int mark = p->mark; |
| 13598 | int start_mark = p->mark; |
| 13599 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13600 | if (!children) { |
| 13601 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13602 | return NULL; |
| 13603 | } |
| 13604 | ssize_t children_capacity = 1; |
| 13605 | ssize_t n = 0; |
| 13606 | { // param_with_default |
| 13607 | NameDefaultPair* param_with_default_var; |
| 13608 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13609 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13610 | ) |
| 13611 | { |
| 13612 | res = param_with_default_var; |
| 13613 | if (n == children_capacity) { |
| 13614 | children_capacity *= 2; |
| 13615 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13616 | if (!children) { |
| 13617 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13618 | return NULL; |
| 13619 | } |
| 13620 | } |
| 13621 | children[n++] = res; |
| 13622 | mark = p->mark; |
| 13623 | } |
| 13624 | p->mark = mark; |
| 13625 | } |
| 13626 | if (n == 0) { |
| 13627 | PyMem_Free(children); |
| 13628 | return NULL; |
| 13629 | } |
| 13630 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13631 | if (!seq) { |
| 13632 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64"); |
| 13633 | PyMem_Free(children); |
| 13634 | return NULL; |
| 13635 | } |
| 13636 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13637 | PyMem_Free(children); |
| 13638 | _PyPegen_insert_memo(p, start_mark, _loop1_64_type, seq); |
| 13639 | return seq; |
| 13640 | } |
| 13641 | |
| 13642 | // _loop0_65: param_maybe_default |
| 13643 | static asdl_seq * |
| 13644 | _loop0_65_rule(Parser *p) |
| 13645 | { |
| 13646 | if (p->error_indicator) { |
| 13647 | return NULL; |
| 13648 | } |
| 13649 | void *res = NULL; |
| 13650 | int mark = p->mark; |
| 13651 | int start_mark = p->mark; |
| 13652 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13653 | if (!children) { |
| 13654 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13655 | return NULL; |
| 13656 | } |
| 13657 | ssize_t children_capacity = 1; |
| 13658 | ssize_t n = 0; |
| 13659 | { // param_maybe_default |
| 13660 | NameDefaultPair* param_maybe_default_var; |
| 13661 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13662 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13663 | ) |
| 13664 | { |
| 13665 | res = param_maybe_default_var; |
| 13666 | if (n == children_capacity) { |
| 13667 | children_capacity *= 2; |
| 13668 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13669 | if (!children) { |
| 13670 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13671 | return NULL; |
| 13672 | } |
| 13673 | } |
| 13674 | children[n++] = res; |
| 13675 | mark = p->mark; |
| 13676 | } |
| 13677 | p->mark = mark; |
| 13678 | } |
| 13679 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13680 | if (!seq) { |
| 13681 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65"); |
| 13682 | PyMem_Free(children); |
| 13683 | return NULL; |
| 13684 | } |
| 13685 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13686 | PyMem_Free(children); |
| 13687 | _PyPegen_insert_memo(p, start_mark, _loop0_65_type, seq); |
| 13688 | return seq; |
| 13689 | } |
| 13690 | |
| 13691 | // _loop1_66: param_maybe_default |
| 13692 | static asdl_seq * |
| 13693 | _loop1_66_rule(Parser *p) |
| 13694 | { |
| 13695 | if (p->error_indicator) { |
| 13696 | return NULL; |
| 13697 | } |
| 13698 | void *res = NULL; |
| 13699 | int mark = p->mark; |
| 13700 | int start_mark = p->mark; |
| 13701 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13702 | if (!children) { |
| 13703 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13704 | return NULL; |
| 13705 | } |
| 13706 | ssize_t children_capacity = 1; |
| 13707 | ssize_t n = 0; |
| 13708 | { // param_maybe_default |
| 13709 | NameDefaultPair* param_maybe_default_var; |
| 13710 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13711 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13712 | ) |
| 13713 | { |
| 13714 | res = param_maybe_default_var; |
| 13715 | if (n == children_capacity) { |
| 13716 | children_capacity *= 2; |
| 13717 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13718 | if (!children) { |
| 13719 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13720 | return NULL; |
| 13721 | } |
| 13722 | } |
| 13723 | children[n++] = res; |
| 13724 | mark = p->mark; |
| 13725 | } |
| 13726 | p->mark = mark; |
| 13727 | } |
| 13728 | if (n == 0) { |
| 13729 | PyMem_Free(children); |
| 13730 | return NULL; |
| 13731 | } |
| 13732 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13733 | if (!seq) { |
| 13734 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66"); |
| 13735 | PyMem_Free(children); |
| 13736 | return NULL; |
| 13737 | } |
| 13738 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13739 | PyMem_Free(children); |
| 13740 | _PyPegen_insert_memo(p, start_mark, _loop1_66_type, seq); |
| 13741 | return seq; |
| 13742 | } |
| 13743 | |
| 13744 | // _loop1_67: ('@' named_expression NEWLINE) |
| 13745 | static asdl_seq * |
| 13746 | _loop1_67_rule(Parser *p) |
| 13747 | { |
| 13748 | if (p->error_indicator) { |
| 13749 | return NULL; |
| 13750 | } |
| 13751 | void *res = NULL; |
| 13752 | int mark = p->mark; |
| 13753 | int start_mark = p->mark; |
| 13754 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13755 | if (!children) { |
| 13756 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13757 | return NULL; |
| 13758 | } |
| 13759 | ssize_t children_capacity = 1; |
| 13760 | ssize_t n = 0; |
| 13761 | { // ('@' named_expression NEWLINE) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13762 | void *_tmp_137_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13763 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13764 | (_tmp_137_var = _tmp_137_rule(p)) // '@' named_expression NEWLINE |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13765 | ) |
| 13766 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13767 | res = _tmp_137_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13768 | if (n == children_capacity) { |
| 13769 | children_capacity *= 2; |
| 13770 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13771 | if (!children) { |
| 13772 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13773 | return NULL; |
| 13774 | } |
| 13775 | } |
| 13776 | children[n++] = res; |
| 13777 | mark = p->mark; |
| 13778 | } |
| 13779 | p->mark = mark; |
| 13780 | } |
| 13781 | if (n == 0) { |
| 13782 | PyMem_Free(children); |
| 13783 | return NULL; |
| 13784 | } |
| 13785 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13786 | if (!seq) { |
| 13787 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67"); |
| 13788 | PyMem_Free(children); |
| 13789 | return NULL; |
| 13790 | } |
| 13791 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13792 | PyMem_Free(children); |
| 13793 | _PyPegen_insert_memo(p, start_mark, _loop1_67_type, seq); |
| 13794 | return seq; |
| 13795 | } |
| 13796 | |
| 13797 | // _tmp_68: '(' arguments? ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13798 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13799 | _tmp_68_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13800 | { |
| 13801 | if (p->error_indicator) { |
| 13802 | return NULL; |
| 13803 | } |
| 13804 | void * res = NULL; |
| 13805 | int mark = p->mark; |
| 13806 | { // '(' arguments? ')' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13807 | Token * literal; |
| 13808 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13809 | void *z; |
| 13810 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13811 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13812 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13813 | (z = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13814 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13815 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13816 | ) |
| 13817 | { |
| 13818 | res = z; |
| 13819 | if (res == NULL && PyErr_Occurred()) { |
| 13820 | p->error_indicator = 1; |
| 13821 | return NULL; |
| 13822 | } |
| 13823 | goto done; |
| 13824 | } |
| 13825 | p->mark = mark; |
| 13826 | } |
| 13827 | res = NULL; |
| 13828 | done: |
| 13829 | return res; |
| 13830 | } |
| 13831 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13832 | // _loop0_70: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13833 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13834 | _loop0_70_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13835 | { |
| 13836 | if (p->error_indicator) { |
| 13837 | return NULL; |
| 13838 | } |
| 13839 | void *res = NULL; |
| 13840 | int mark = p->mark; |
| 13841 | int start_mark = p->mark; |
| 13842 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13843 | if (!children) { |
| 13844 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13845 | return NULL; |
| 13846 | } |
| 13847 | ssize_t children_capacity = 1; |
| 13848 | ssize_t n = 0; |
| 13849 | { // ',' star_expression |
| 13850 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13851 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13852 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13853 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13854 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13855 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13856 | ) |
| 13857 | { |
| 13858 | res = elem; |
| 13859 | if (res == NULL && PyErr_Occurred()) { |
| 13860 | p->error_indicator = 1; |
| 13861 | PyMem_Free(children); |
| 13862 | return NULL; |
| 13863 | } |
| 13864 | if (n == children_capacity) { |
| 13865 | children_capacity *= 2; |
| 13866 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13867 | if (!children) { |
| 13868 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13869 | return NULL; |
| 13870 | } |
| 13871 | } |
| 13872 | children[n++] = res; |
| 13873 | mark = p->mark; |
| 13874 | } |
| 13875 | p->mark = mark; |
| 13876 | } |
| 13877 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13878 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13879 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13880 | PyMem_Free(children); |
| 13881 | return NULL; |
| 13882 | } |
| 13883 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13884 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13885 | _PyPegen_insert_memo(p, start_mark, _loop0_70_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13886 | return seq; |
| 13887 | } |
| 13888 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13889 | // _gather_69: star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13890 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13891 | _gather_69_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13892 | { |
| 13893 | if (p->error_indicator) { |
| 13894 | return NULL; |
| 13895 | } |
| 13896 | asdl_seq * res = NULL; |
| 13897 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13898 | { // star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13899 | expr_ty elem; |
| 13900 | asdl_seq * seq; |
| 13901 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13902 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13903 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13904 | (seq = _loop0_70_rule(p)) // _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13905 | ) |
| 13906 | { |
| 13907 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 13908 | goto done; |
| 13909 | } |
| 13910 | p->mark = mark; |
| 13911 | } |
| 13912 | res = NULL; |
| 13913 | done: |
| 13914 | return res; |
| 13915 | } |
| 13916 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13917 | // _loop1_71: (',' star_expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13918 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13919 | _loop1_71_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13920 | { |
| 13921 | if (p->error_indicator) { |
| 13922 | return NULL; |
| 13923 | } |
| 13924 | void *res = NULL; |
| 13925 | int mark = p->mark; |
| 13926 | int start_mark = p->mark; |
| 13927 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13928 | if (!children) { |
| 13929 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13930 | return NULL; |
| 13931 | } |
| 13932 | ssize_t children_capacity = 1; |
| 13933 | ssize_t n = 0; |
| 13934 | { // (',' star_expression) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13935 | void *_tmp_138_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13936 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13937 | (_tmp_138_var = _tmp_138_rule(p)) // ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13938 | ) |
| 13939 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13940 | res = _tmp_138_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13941 | if (n == children_capacity) { |
| 13942 | children_capacity *= 2; |
| 13943 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13944 | if (!children) { |
| 13945 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13946 | return NULL; |
| 13947 | } |
| 13948 | } |
| 13949 | children[n++] = res; |
| 13950 | mark = p->mark; |
| 13951 | } |
| 13952 | p->mark = mark; |
| 13953 | } |
| 13954 | if (n == 0) { |
| 13955 | PyMem_Free(children); |
| 13956 | return NULL; |
| 13957 | } |
| 13958 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13959 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13960 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13961 | PyMem_Free(children); |
| 13962 | return NULL; |
| 13963 | } |
| 13964 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13965 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13966 | _PyPegen_insert_memo(p, start_mark, _loop1_71_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13967 | return seq; |
| 13968 | } |
| 13969 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13970 | // _loop0_73: ',' star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13971 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13972 | _loop0_73_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13973 | { |
| 13974 | if (p->error_indicator) { |
| 13975 | return NULL; |
| 13976 | } |
| 13977 | void *res = NULL; |
| 13978 | int mark = p->mark; |
| 13979 | int start_mark = p->mark; |
| 13980 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13981 | if (!children) { |
| 13982 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13983 | return NULL; |
| 13984 | } |
| 13985 | ssize_t children_capacity = 1; |
| 13986 | ssize_t n = 0; |
| 13987 | { // ',' star_named_expression |
| 13988 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13989 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13990 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13991 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13992 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 13993 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13994 | ) |
| 13995 | { |
| 13996 | res = elem; |
| 13997 | if (res == NULL && PyErr_Occurred()) { |
| 13998 | p->error_indicator = 1; |
| 13999 | PyMem_Free(children); |
| 14000 | return NULL; |
| 14001 | } |
| 14002 | if (n == children_capacity) { |
| 14003 | children_capacity *= 2; |
| 14004 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14005 | if (!children) { |
| 14006 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14007 | return NULL; |
| 14008 | } |
| 14009 | } |
| 14010 | children[n++] = res; |
| 14011 | mark = p->mark; |
| 14012 | } |
| 14013 | p->mark = mark; |
| 14014 | } |
| 14015 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14016 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14017 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14018 | PyMem_Free(children); |
| 14019 | return NULL; |
| 14020 | } |
| 14021 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14022 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14023 | _PyPegen_insert_memo(p, start_mark, _loop0_73_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14024 | return seq; |
| 14025 | } |
| 14026 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14027 | // _gather_72: star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14028 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14029 | _gather_72_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14030 | { |
| 14031 | if (p->error_indicator) { |
| 14032 | return NULL; |
| 14033 | } |
| 14034 | asdl_seq * res = NULL; |
| 14035 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14036 | { // star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14037 | expr_ty elem; |
| 14038 | asdl_seq * seq; |
| 14039 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14040 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14041 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14042 | (seq = _loop0_73_rule(p)) // _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14043 | ) |
| 14044 | { |
| 14045 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 14046 | goto done; |
| 14047 | } |
| 14048 | p->mark = mark; |
| 14049 | } |
| 14050 | res = NULL; |
| 14051 | done: |
| 14052 | return res; |
| 14053 | } |
| 14054 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14055 | // _loop1_74: (',' expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14056 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14057 | _loop1_74_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14058 | { |
| 14059 | if (p->error_indicator) { |
| 14060 | return NULL; |
| 14061 | } |
| 14062 | void *res = NULL; |
| 14063 | int mark = p->mark; |
| 14064 | int start_mark = p->mark; |
| 14065 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14066 | if (!children) { |
| 14067 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14068 | return NULL; |
| 14069 | } |
| 14070 | ssize_t children_capacity = 1; |
| 14071 | ssize_t n = 0; |
| 14072 | { // (',' expression) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14073 | void *_tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14074 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14075 | (_tmp_139_var = _tmp_139_rule(p)) // ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14076 | ) |
| 14077 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14078 | res = _tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14079 | if (n == children_capacity) { |
| 14080 | children_capacity *= 2; |
| 14081 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14082 | if (!children) { |
| 14083 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14084 | return NULL; |
| 14085 | } |
| 14086 | } |
| 14087 | children[n++] = res; |
| 14088 | mark = p->mark; |
| 14089 | } |
| 14090 | p->mark = mark; |
| 14091 | } |
| 14092 | if (n == 0) { |
| 14093 | PyMem_Free(children); |
| 14094 | return NULL; |
| 14095 | } |
| 14096 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14097 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14098 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14099 | PyMem_Free(children); |
| 14100 | return NULL; |
| 14101 | } |
| 14102 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14103 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14104 | _PyPegen_insert_memo(p, start_mark, _loop1_74_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14105 | return seq; |
| 14106 | } |
| 14107 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14108 | // _loop0_75: lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14109 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14110 | _loop0_75_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14111 | { |
| 14112 | if (p->error_indicator) { |
| 14113 | return NULL; |
| 14114 | } |
| 14115 | void *res = NULL; |
| 14116 | int mark = p->mark; |
| 14117 | int start_mark = p->mark; |
| 14118 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14119 | if (!children) { |
| 14120 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14121 | return NULL; |
| 14122 | } |
| 14123 | ssize_t children_capacity = 1; |
| 14124 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14125 | { // lambda_param_no_default |
| 14126 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14127 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14128 | (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] | 14129 | ) |
| 14130 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14131 | res = lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14132 | if (n == children_capacity) { |
| 14133 | children_capacity *= 2; |
| 14134 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14135 | if (!children) { |
| 14136 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14137 | return NULL; |
| 14138 | } |
| 14139 | } |
| 14140 | children[n++] = res; |
| 14141 | mark = p->mark; |
| 14142 | } |
| 14143 | p->mark = mark; |
| 14144 | } |
| 14145 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14146 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14147 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14148 | PyMem_Free(children); |
| 14149 | return NULL; |
| 14150 | } |
| 14151 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14152 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14153 | _PyPegen_insert_memo(p, start_mark, _loop0_75_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14154 | return seq; |
| 14155 | } |
| 14156 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14157 | // _loop0_76: lambda_param_with_default |
| 14158 | static asdl_seq * |
| 14159 | _loop0_76_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14160 | { |
| 14161 | if (p->error_indicator) { |
| 14162 | return NULL; |
| 14163 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14164 | void *res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14165 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14166 | int start_mark = p->mark; |
| 14167 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14168 | if (!children) { |
| 14169 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14170 | return NULL; |
| 14171 | } |
| 14172 | ssize_t children_capacity = 1; |
| 14173 | ssize_t n = 0; |
| 14174 | { // lambda_param_with_default |
| 14175 | NameDefaultPair* lambda_param_with_default_var; |
| 14176 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14177 | (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] | 14178 | ) |
| 14179 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14180 | res = lambda_param_with_default_var; |
| 14181 | if (n == children_capacity) { |
| 14182 | children_capacity *= 2; |
| 14183 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14184 | if (!children) { |
| 14185 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14186 | return NULL; |
| 14187 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14188 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14189 | children[n++] = res; |
| 14190 | mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14191 | } |
| 14192 | p->mark = mark; |
| 14193 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14194 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14195 | if (!seq) { |
| 14196 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76"); |
| 14197 | PyMem_Free(children); |
| 14198 | return NULL; |
| 14199 | } |
| 14200 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14201 | PyMem_Free(children); |
| 14202 | _PyPegen_insert_memo(p, start_mark, _loop0_76_type, seq); |
| 14203 | return seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14204 | } |
| 14205 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14206 | // _loop0_77: lambda_param_with_default |
| 14207 | static asdl_seq * |
| 14208 | _loop0_77_rule(Parser *p) |
| 14209 | { |
| 14210 | if (p->error_indicator) { |
| 14211 | return NULL; |
| 14212 | } |
| 14213 | void *res = NULL; |
| 14214 | int mark = p->mark; |
| 14215 | int start_mark = p->mark; |
| 14216 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14217 | if (!children) { |
| 14218 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14219 | return NULL; |
| 14220 | } |
| 14221 | ssize_t children_capacity = 1; |
| 14222 | ssize_t n = 0; |
| 14223 | { // lambda_param_with_default |
| 14224 | NameDefaultPair* lambda_param_with_default_var; |
| 14225 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14226 | (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] | 14227 | ) |
| 14228 | { |
| 14229 | res = lambda_param_with_default_var; |
| 14230 | if (n == children_capacity) { |
| 14231 | children_capacity *= 2; |
| 14232 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14233 | if (!children) { |
| 14234 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14235 | return NULL; |
| 14236 | } |
| 14237 | } |
| 14238 | children[n++] = res; |
| 14239 | mark = p->mark; |
| 14240 | } |
| 14241 | p->mark = mark; |
| 14242 | } |
| 14243 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14244 | if (!seq) { |
| 14245 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77"); |
| 14246 | PyMem_Free(children); |
| 14247 | return NULL; |
| 14248 | } |
| 14249 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14250 | PyMem_Free(children); |
| 14251 | _PyPegen_insert_memo(p, start_mark, _loop0_77_type, seq); |
| 14252 | return seq; |
| 14253 | } |
| 14254 | |
| 14255 | // _loop1_78: lambda_param_no_default |
| 14256 | static asdl_seq * |
| 14257 | _loop1_78_rule(Parser *p) |
| 14258 | { |
| 14259 | if (p->error_indicator) { |
| 14260 | return NULL; |
| 14261 | } |
| 14262 | void *res = NULL; |
| 14263 | int mark = p->mark; |
| 14264 | int start_mark = p->mark; |
| 14265 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14266 | if (!children) { |
| 14267 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14268 | return NULL; |
| 14269 | } |
| 14270 | ssize_t children_capacity = 1; |
| 14271 | ssize_t n = 0; |
| 14272 | { // lambda_param_no_default |
| 14273 | arg_ty lambda_param_no_default_var; |
| 14274 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14275 | (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] | 14276 | ) |
| 14277 | { |
| 14278 | res = lambda_param_no_default_var; |
| 14279 | if (n == children_capacity) { |
| 14280 | children_capacity *= 2; |
| 14281 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14282 | if (!children) { |
| 14283 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14284 | return NULL; |
| 14285 | } |
| 14286 | } |
| 14287 | children[n++] = res; |
| 14288 | mark = p->mark; |
| 14289 | } |
| 14290 | p->mark = mark; |
| 14291 | } |
| 14292 | if (n == 0) { |
| 14293 | PyMem_Free(children); |
| 14294 | return NULL; |
| 14295 | } |
| 14296 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14297 | if (!seq) { |
| 14298 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78"); |
| 14299 | PyMem_Free(children); |
| 14300 | return NULL; |
| 14301 | } |
| 14302 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14303 | PyMem_Free(children); |
| 14304 | _PyPegen_insert_memo(p, start_mark, _loop1_78_type, seq); |
| 14305 | return seq; |
| 14306 | } |
| 14307 | |
| 14308 | // _loop0_79: lambda_param_with_default |
| 14309 | static asdl_seq * |
| 14310 | _loop0_79_rule(Parser *p) |
| 14311 | { |
| 14312 | if (p->error_indicator) { |
| 14313 | return NULL; |
| 14314 | } |
| 14315 | void *res = NULL; |
| 14316 | int mark = p->mark; |
| 14317 | int start_mark = p->mark; |
| 14318 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14319 | if (!children) { |
| 14320 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14321 | return NULL; |
| 14322 | } |
| 14323 | ssize_t children_capacity = 1; |
| 14324 | ssize_t n = 0; |
| 14325 | { // lambda_param_with_default |
| 14326 | NameDefaultPair* lambda_param_with_default_var; |
| 14327 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14328 | (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] | 14329 | ) |
| 14330 | { |
| 14331 | res = lambda_param_with_default_var; |
| 14332 | if (n == children_capacity) { |
| 14333 | children_capacity *= 2; |
| 14334 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14335 | if (!children) { |
| 14336 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14337 | return NULL; |
| 14338 | } |
| 14339 | } |
| 14340 | children[n++] = res; |
| 14341 | mark = p->mark; |
| 14342 | } |
| 14343 | p->mark = mark; |
| 14344 | } |
| 14345 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14346 | if (!seq) { |
| 14347 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79"); |
| 14348 | PyMem_Free(children); |
| 14349 | return NULL; |
| 14350 | } |
| 14351 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14352 | PyMem_Free(children); |
| 14353 | _PyPegen_insert_memo(p, start_mark, _loop0_79_type, seq); |
| 14354 | return seq; |
| 14355 | } |
| 14356 | |
| 14357 | // _loop1_80: lambda_param_with_default |
| 14358 | static asdl_seq * |
| 14359 | _loop1_80_rule(Parser *p) |
| 14360 | { |
| 14361 | if (p->error_indicator) { |
| 14362 | return NULL; |
| 14363 | } |
| 14364 | void *res = NULL; |
| 14365 | int mark = p->mark; |
| 14366 | int start_mark = p->mark; |
| 14367 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14368 | if (!children) { |
| 14369 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14370 | return NULL; |
| 14371 | } |
| 14372 | ssize_t children_capacity = 1; |
| 14373 | ssize_t n = 0; |
| 14374 | { // lambda_param_with_default |
| 14375 | NameDefaultPair* lambda_param_with_default_var; |
| 14376 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14377 | (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] | 14378 | ) |
| 14379 | { |
| 14380 | res = lambda_param_with_default_var; |
| 14381 | if (n == children_capacity) { |
| 14382 | children_capacity *= 2; |
| 14383 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14384 | if (!children) { |
| 14385 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14386 | return NULL; |
| 14387 | } |
| 14388 | } |
| 14389 | children[n++] = res; |
| 14390 | mark = p->mark; |
| 14391 | } |
| 14392 | p->mark = mark; |
| 14393 | } |
| 14394 | if (n == 0) { |
| 14395 | PyMem_Free(children); |
| 14396 | return NULL; |
| 14397 | } |
| 14398 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14399 | if (!seq) { |
| 14400 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80"); |
| 14401 | PyMem_Free(children); |
| 14402 | return NULL; |
| 14403 | } |
| 14404 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14405 | PyMem_Free(children); |
| 14406 | _PyPegen_insert_memo(p, start_mark, _loop1_80_type, seq); |
| 14407 | return seq; |
| 14408 | } |
| 14409 | |
| 14410 | // _loop1_81: lambda_param_no_default |
| 14411 | static asdl_seq * |
| 14412 | _loop1_81_rule(Parser *p) |
| 14413 | { |
| 14414 | if (p->error_indicator) { |
| 14415 | return NULL; |
| 14416 | } |
| 14417 | void *res = NULL; |
| 14418 | int mark = p->mark; |
| 14419 | int start_mark = p->mark; |
| 14420 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14421 | if (!children) { |
| 14422 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14423 | return NULL; |
| 14424 | } |
| 14425 | ssize_t children_capacity = 1; |
| 14426 | ssize_t n = 0; |
| 14427 | { // lambda_param_no_default |
| 14428 | arg_ty lambda_param_no_default_var; |
| 14429 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14430 | (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] | 14431 | ) |
| 14432 | { |
| 14433 | res = lambda_param_no_default_var; |
| 14434 | if (n == children_capacity) { |
| 14435 | children_capacity *= 2; |
| 14436 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14437 | if (!children) { |
| 14438 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14439 | return NULL; |
| 14440 | } |
| 14441 | } |
| 14442 | children[n++] = res; |
| 14443 | mark = p->mark; |
| 14444 | } |
| 14445 | p->mark = mark; |
| 14446 | } |
| 14447 | if (n == 0) { |
| 14448 | PyMem_Free(children); |
| 14449 | return NULL; |
| 14450 | } |
| 14451 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14452 | if (!seq) { |
| 14453 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81"); |
| 14454 | PyMem_Free(children); |
| 14455 | return NULL; |
| 14456 | } |
| 14457 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14458 | PyMem_Free(children); |
| 14459 | _PyPegen_insert_memo(p, start_mark, _loop1_81_type, seq); |
| 14460 | return seq; |
| 14461 | } |
| 14462 | |
| 14463 | // _loop1_82: lambda_param_no_default |
| 14464 | static asdl_seq * |
| 14465 | _loop1_82_rule(Parser *p) |
| 14466 | { |
| 14467 | if (p->error_indicator) { |
| 14468 | return NULL; |
| 14469 | } |
| 14470 | void *res = NULL; |
| 14471 | int mark = p->mark; |
| 14472 | int start_mark = p->mark; |
| 14473 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14474 | if (!children) { |
| 14475 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14476 | return NULL; |
| 14477 | } |
| 14478 | ssize_t children_capacity = 1; |
| 14479 | ssize_t n = 0; |
| 14480 | { // lambda_param_no_default |
| 14481 | arg_ty lambda_param_no_default_var; |
| 14482 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14483 | (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] | 14484 | ) |
| 14485 | { |
| 14486 | res = lambda_param_no_default_var; |
| 14487 | if (n == children_capacity) { |
| 14488 | children_capacity *= 2; |
| 14489 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14490 | if (!children) { |
| 14491 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14492 | return NULL; |
| 14493 | } |
| 14494 | } |
| 14495 | children[n++] = res; |
| 14496 | mark = p->mark; |
| 14497 | } |
| 14498 | p->mark = mark; |
| 14499 | } |
| 14500 | if (n == 0) { |
| 14501 | PyMem_Free(children); |
| 14502 | return NULL; |
| 14503 | } |
| 14504 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14505 | if (!seq) { |
| 14506 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82"); |
| 14507 | PyMem_Free(children); |
| 14508 | return NULL; |
| 14509 | } |
| 14510 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14511 | PyMem_Free(children); |
| 14512 | _PyPegen_insert_memo(p, start_mark, _loop1_82_type, seq); |
| 14513 | return seq; |
| 14514 | } |
| 14515 | |
| 14516 | // _loop0_83: lambda_param_no_default |
| 14517 | static asdl_seq * |
| 14518 | _loop0_83_rule(Parser *p) |
| 14519 | { |
| 14520 | if (p->error_indicator) { |
| 14521 | return NULL; |
| 14522 | } |
| 14523 | void *res = NULL; |
| 14524 | int mark = p->mark; |
| 14525 | int start_mark = p->mark; |
| 14526 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14527 | if (!children) { |
| 14528 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14529 | return NULL; |
| 14530 | } |
| 14531 | ssize_t children_capacity = 1; |
| 14532 | ssize_t n = 0; |
| 14533 | { // lambda_param_no_default |
| 14534 | arg_ty lambda_param_no_default_var; |
| 14535 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14536 | (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] | 14537 | ) |
| 14538 | { |
| 14539 | res = lambda_param_no_default_var; |
| 14540 | if (n == children_capacity) { |
| 14541 | children_capacity *= 2; |
| 14542 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14543 | if (!children) { |
| 14544 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14545 | return NULL; |
| 14546 | } |
| 14547 | } |
| 14548 | children[n++] = res; |
| 14549 | mark = p->mark; |
| 14550 | } |
| 14551 | p->mark = mark; |
| 14552 | } |
| 14553 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14554 | if (!seq) { |
| 14555 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83"); |
| 14556 | PyMem_Free(children); |
| 14557 | return NULL; |
| 14558 | } |
| 14559 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14560 | PyMem_Free(children); |
| 14561 | _PyPegen_insert_memo(p, start_mark, _loop0_83_type, seq); |
| 14562 | return seq; |
| 14563 | } |
| 14564 | |
| 14565 | // _loop1_84: lambda_param_with_default |
| 14566 | static asdl_seq * |
| 14567 | _loop1_84_rule(Parser *p) |
| 14568 | { |
| 14569 | if (p->error_indicator) { |
| 14570 | return NULL; |
| 14571 | } |
| 14572 | void *res = NULL; |
| 14573 | int mark = p->mark; |
| 14574 | int start_mark = p->mark; |
| 14575 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14576 | if (!children) { |
| 14577 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14578 | return NULL; |
| 14579 | } |
| 14580 | ssize_t children_capacity = 1; |
| 14581 | ssize_t n = 0; |
| 14582 | { // lambda_param_with_default |
| 14583 | NameDefaultPair* lambda_param_with_default_var; |
| 14584 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14585 | (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] | 14586 | ) |
| 14587 | { |
| 14588 | res = lambda_param_with_default_var; |
| 14589 | if (n == children_capacity) { |
| 14590 | children_capacity *= 2; |
| 14591 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14592 | if (!children) { |
| 14593 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14594 | return NULL; |
| 14595 | } |
| 14596 | } |
| 14597 | children[n++] = res; |
| 14598 | mark = p->mark; |
| 14599 | } |
| 14600 | p->mark = mark; |
| 14601 | } |
| 14602 | if (n == 0) { |
| 14603 | PyMem_Free(children); |
| 14604 | return NULL; |
| 14605 | } |
| 14606 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14607 | if (!seq) { |
| 14608 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84"); |
| 14609 | PyMem_Free(children); |
| 14610 | return NULL; |
| 14611 | } |
| 14612 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14613 | PyMem_Free(children); |
| 14614 | _PyPegen_insert_memo(p, start_mark, _loop1_84_type, seq); |
| 14615 | return seq; |
| 14616 | } |
| 14617 | |
| 14618 | // _loop0_85: lambda_param_no_default |
| 14619 | static asdl_seq * |
| 14620 | _loop0_85_rule(Parser *p) |
| 14621 | { |
| 14622 | if (p->error_indicator) { |
| 14623 | return NULL; |
| 14624 | } |
| 14625 | void *res = NULL; |
| 14626 | int mark = p->mark; |
| 14627 | int start_mark = p->mark; |
| 14628 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14629 | if (!children) { |
| 14630 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14631 | return NULL; |
| 14632 | } |
| 14633 | ssize_t children_capacity = 1; |
| 14634 | ssize_t n = 0; |
| 14635 | { // lambda_param_no_default |
| 14636 | arg_ty lambda_param_no_default_var; |
| 14637 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14638 | (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] | 14639 | ) |
| 14640 | { |
| 14641 | res = lambda_param_no_default_var; |
| 14642 | if (n == children_capacity) { |
| 14643 | children_capacity *= 2; |
| 14644 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14645 | if (!children) { |
| 14646 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14647 | return NULL; |
| 14648 | } |
| 14649 | } |
| 14650 | children[n++] = res; |
| 14651 | mark = p->mark; |
| 14652 | } |
| 14653 | p->mark = mark; |
| 14654 | } |
| 14655 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14656 | if (!seq) { |
| 14657 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85"); |
| 14658 | PyMem_Free(children); |
| 14659 | return NULL; |
| 14660 | } |
| 14661 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14662 | PyMem_Free(children); |
| 14663 | _PyPegen_insert_memo(p, start_mark, _loop0_85_type, seq); |
| 14664 | return seq; |
| 14665 | } |
| 14666 | |
| 14667 | // _loop1_86: lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14668 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14669 | _loop1_86_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14670 | { |
| 14671 | if (p->error_indicator) { |
| 14672 | return NULL; |
| 14673 | } |
| 14674 | void *res = NULL; |
| 14675 | int mark = p->mark; |
| 14676 | int start_mark = p->mark; |
| 14677 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14678 | if (!children) { |
| 14679 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14680 | return NULL; |
| 14681 | } |
| 14682 | ssize_t children_capacity = 1; |
| 14683 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14684 | { // lambda_param_with_default |
| 14685 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14686 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14687 | (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] | 14688 | ) |
| 14689 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14690 | res = lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14691 | if (n == children_capacity) { |
| 14692 | children_capacity *= 2; |
| 14693 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14694 | if (!children) { |
| 14695 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14696 | return NULL; |
| 14697 | } |
| 14698 | } |
| 14699 | children[n++] = res; |
| 14700 | mark = p->mark; |
| 14701 | } |
| 14702 | p->mark = mark; |
| 14703 | } |
| 14704 | if (n == 0) { |
| 14705 | PyMem_Free(children); |
| 14706 | return NULL; |
| 14707 | } |
| 14708 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14709 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14710 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14711 | PyMem_Free(children); |
| 14712 | return NULL; |
| 14713 | } |
| 14714 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14715 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14716 | _PyPegen_insert_memo(p, start_mark, _loop1_86_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14717 | return seq; |
| 14718 | } |
| 14719 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14720 | // _loop0_87: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14721 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14722 | _loop0_87_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14723 | { |
| 14724 | if (p->error_indicator) { |
| 14725 | return NULL; |
| 14726 | } |
| 14727 | void *res = NULL; |
| 14728 | int mark = p->mark; |
| 14729 | int start_mark = p->mark; |
| 14730 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14731 | if (!children) { |
| 14732 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14733 | return NULL; |
| 14734 | } |
| 14735 | ssize_t children_capacity = 1; |
| 14736 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14737 | { // lambda_param_maybe_default |
| 14738 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14739 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14740 | (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] | 14741 | ) |
| 14742 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14743 | res = lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14744 | if (n == children_capacity) { |
| 14745 | children_capacity *= 2; |
| 14746 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14747 | if (!children) { |
| 14748 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14749 | return NULL; |
| 14750 | } |
| 14751 | } |
| 14752 | children[n++] = res; |
| 14753 | mark = p->mark; |
| 14754 | } |
| 14755 | p->mark = mark; |
| 14756 | } |
| 14757 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14758 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14759 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14760 | PyMem_Free(children); |
| 14761 | return NULL; |
| 14762 | } |
| 14763 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14764 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14765 | _PyPegen_insert_memo(p, start_mark, _loop0_87_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14766 | return seq; |
| 14767 | } |
| 14768 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14769 | // _loop1_88: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14770 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14771 | _loop1_88_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14772 | { |
| 14773 | if (p->error_indicator) { |
| 14774 | return NULL; |
| 14775 | } |
| 14776 | void *res = NULL; |
| 14777 | int mark = p->mark; |
| 14778 | int start_mark = p->mark; |
| 14779 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14780 | if (!children) { |
| 14781 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14782 | return NULL; |
| 14783 | } |
| 14784 | ssize_t children_capacity = 1; |
| 14785 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14786 | { // lambda_param_maybe_default |
| 14787 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14788 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14789 | (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] | 14790 | ) |
| 14791 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14792 | res = lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14793 | if (n == children_capacity) { |
| 14794 | children_capacity *= 2; |
| 14795 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14796 | if (!children) { |
| 14797 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14798 | return NULL; |
| 14799 | } |
| 14800 | } |
| 14801 | children[n++] = res; |
| 14802 | mark = p->mark; |
| 14803 | } |
| 14804 | p->mark = mark; |
| 14805 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14806 | if (n == 0) { |
| 14807 | PyMem_Free(children); |
| 14808 | return NULL; |
| 14809 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14810 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14811 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14812 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14813 | PyMem_Free(children); |
| 14814 | return NULL; |
| 14815 | } |
| 14816 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14817 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14818 | _PyPegen_insert_memo(p, start_mark, _loop1_88_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14819 | return seq; |
| 14820 | } |
| 14821 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14822 | // _loop1_89: ('or' conjunction) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14823 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14824 | _loop1_89_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14825 | { |
| 14826 | if (p->error_indicator) { |
| 14827 | return NULL; |
| 14828 | } |
| 14829 | void *res = NULL; |
| 14830 | int mark = p->mark; |
| 14831 | int start_mark = p->mark; |
| 14832 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14833 | if (!children) { |
| 14834 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14835 | return NULL; |
| 14836 | } |
| 14837 | ssize_t children_capacity = 1; |
| 14838 | ssize_t n = 0; |
| 14839 | { // ('or' conjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14840 | void *_tmp_140_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14841 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14842 | (_tmp_140_var = _tmp_140_rule(p)) // 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14843 | ) |
| 14844 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14845 | res = _tmp_140_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14846 | if (n == children_capacity) { |
| 14847 | children_capacity *= 2; |
| 14848 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14849 | if (!children) { |
| 14850 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14851 | return NULL; |
| 14852 | } |
| 14853 | } |
| 14854 | children[n++] = res; |
| 14855 | mark = p->mark; |
| 14856 | } |
| 14857 | p->mark = mark; |
| 14858 | } |
| 14859 | if (n == 0) { |
| 14860 | PyMem_Free(children); |
| 14861 | return NULL; |
| 14862 | } |
| 14863 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14864 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14865 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14866 | PyMem_Free(children); |
| 14867 | return NULL; |
| 14868 | } |
| 14869 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14870 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14871 | _PyPegen_insert_memo(p, start_mark, _loop1_89_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14872 | return seq; |
| 14873 | } |
| 14874 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14875 | // _loop1_90: ('and' inversion) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14876 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14877 | _loop1_90_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14878 | { |
| 14879 | if (p->error_indicator) { |
| 14880 | return NULL; |
| 14881 | } |
| 14882 | void *res = NULL; |
| 14883 | int mark = p->mark; |
| 14884 | int start_mark = p->mark; |
| 14885 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14886 | if (!children) { |
| 14887 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14888 | return NULL; |
| 14889 | } |
| 14890 | ssize_t children_capacity = 1; |
| 14891 | ssize_t n = 0; |
| 14892 | { // ('and' inversion) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14893 | void *_tmp_141_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14894 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14895 | (_tmp_141_var = _tmp_141_rule(p)) // 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14896 | ) |
| 14897 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14898 | res = _tmp_141_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14899 | if (n == children_capacity) { |
| 14900 | children_capacity *= 2; |
| 14901 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14902 | if (!children) { |
| 14903 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14904 | return NULL; |
| 14905 | } |
| 14906 | } |
| 14907 | children[n++] = res; |
| 14908 | mark = p->mark; |
| 14909 | } |
| 14910 | p->mark = mark; |
| 14911 | } |
| 14912 | if (n == 0) { |
| 14913 | PyMem_Free(children); |
| 14914 | return NULL; |
| 14915 | } |
| 14916 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14917 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14918 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14919 | PyMem_Free(children); |
| 14920 | return NULL; |
| 14921 | } |
| 14922 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14923 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14924 | _PyPegen_insert_memo(p, start_mark, _loop1_90_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14925 | return seq; |
| 14926 | } |
| 14927 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14928 | // _loop1_91: compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14929 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14930 | _loop1_91_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14931 | { |
| 14932 | if (p->error_indicator) { |
| 14933 | return NULL; |
| 14934 | } |
| 14935 | void *res = NULL; |
| 14936 | int mark = p->mark; |
| 14937 | int start_mark = p->mark; |
| 14938 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14939 | if (!children) { |
| 14940 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14941 | return NULL; |
| 14942 | } |
| 14943 | ssize_t children_capacity = 1; |
| 14944 | ssize_t n = 0; |
| 14945 | { // compare_op_bitwise_or_pair |
| 14946 | CmpopExprPair* compare_op_bitwise_or_pair_var; |
| 14947 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14948 | (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] | 14949 | ) |
| 14950 | { |
| 14951 | res = compare_op_bitwise_or_pair_var; |
| 14952 | if (n == children_capacity) { |
| 14953 | children_capacity *= 2; |
| 14954 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14955 | if (!children) { |
| 14956 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14957 | return NULL; |
| 14958 | } |
| 14959 | } |
| 14960 | children[n++] = res; |
| 14961 | mark = p->mark; |
| 14962 | } |
| 14963 | p->mark = mark; |
| 14964 | } |
| 14965 | if (n == 0) { |
| 14966 | PyMem_Free(children); |
| 14967 | return NULL; |
| 14968 | } |
| 14969 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14970 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14971 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14972 | PyMem_Free(children); |
| 14973 | return NULL; |
| 14974 | } |
| 14975 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14976 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14977 | _PyPegen_insert_memo(p, start_mark, _loop1_91_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14978 | return seq; |
| 14979 | } |
| 14980 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14981 | // _tmp_92: '!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 14982 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14983 | _tmp_92_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 14984 | { |
| 14985 | if (p->error_indicator) { |
| 14986 | return NULL; |
| 14987 | } |
| 14988 | void * res = NULL; |
| 14989 | int mark = p->mark; |
| 14990 | { // '!=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 14991 | Token * tok; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 14992 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 14993 | (tok = _PyPegen_expect_token(p, 28)) // token='!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 14994 | ) |
| 14995 | { |
| 14996 | res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; |
| 14997 | if (res == NULL && PyErr_Occurred()) { |
| 14998 | p->error_indicator = 1; |
| 14999 | return NULL; |
| 15000 | } |
| 15001 | goto done; |
| 15002 | } |
| 15003 | p->mark = mark; |
| 15004 | } |
| 15005 | res = NULL; |
| 15006 | done: |
| 15007 | return res; |
| 15008 | } |
| 15009 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15010 | // _loop0_94: ',' slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15011 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15012 | _loop0_94_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15013 | { |
| 15014 | if (p->error_indicator) { |
| 15015 | return NULL; |
| 15016 | } |
| 15017 | void *res = NULL; |
| 15018 | int mark = p->mark; |
| 15019 | int start_mark = p->mark; |
| 15020 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15021 | if (!children) { |
| 15022 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15023 | return NULL; |
| 15024 | } |
| 15025 | ssize_t children_capacity = 1; |
| 15026 | ssize_t n = 0; |
| 15027 | { // ',' slice |
| 15028 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15029 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15030 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15031 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15032 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15033 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15034 | ) |
| 15035 | { |
| 15036 | res = elem; |
| 15037 | if (res == NULL && PyErr_Occurred()) { |
| 15038 | p->error_indicator = 1; |
| 15039 | PyMem_Free(children); |
| 15040 | return NULL; |
| 15041 | } |
| 15042 | if (n == children_capacity) { |
| 15043 | children_capacity *= 2; |
| 15044 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15045 | if (!children) { |
| 15046 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15047 | return NULL; |
| 15048 | } |
| 15049 | } |
| 15050 | children[n++] = res; |
| 15051 | mark = p->mark; |
| 15052 | } |
| 15053 | p->mark = mark; |
| 15054 | } |
| 15055 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15056 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15057 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15058 | PyMem_Free(children); |
| 15059 | return NULL; |
| 15060 | } |
| 15061 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15062 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15063 | _PyPegen_insert_memo(p, start_mark, _loop0_94_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15064 | return seq; |
| 15065 | } |
| 15066 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15067 | // _gather_93: slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15068 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15069 | _gather_93_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15070 | { |
| 15071 | if (p->error_indicator) { |
| 15072 | return NULL; |
| 15073 | } |
| 15074 | asdl_seq * res = NULL; |
| 15075 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15076 | { // slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15077 | expr_ty elem; |
| 15078 | asdl_seq * seq; |
| 15079 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15080 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15081 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15082 | (seq = _loop0_94_rule(p)) // _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15083 | ) |
| 15084 | { |
| 15085 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15086 | goto done; |
| 15087 | } |
| 15088 | p->mark = mark; |
| 15089 | } |
| 15090 | res = NULL; |
| 15091 | done: |
| 15092 | return res; |
| 15093 | } |
| 15094 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15095 | // _tmp_95: ':' expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15096 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15097 | _tmp_95_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15098 | { |
| 15099 | if (p->error_indicator) { |
| 15100 | return NULL; |
| 15101 | } |
| 15102 | void * res = NULL; |
| 15103 | int mark = p->mark; |
| 15104 | { // ':' expression? |
| 15105 | void *d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15106 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15107 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15108 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15109 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15110 | (d = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15111 | ) |
| 15112 | { |
| 15113 | res = d; |
| 15114 | if (res == NULL && PyErr_Occurred()) { |
| 15115 | p->error_indicator = 1; |
| 15116 | return NULL; |
| 15117 | } |
| 15118 | goto done; |
| 15119 | } |
| 15120 | p->mark = mark; |
| 15121 | } |
| 15122 | res = NULL; |
| 15123 | done: |
| 15124 | return res; |
| 15125 | } |
| 15126 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15127 | // _tmp_96: tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15128 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15129 | _tmp_96_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15130 | { |
| 15131 | if (p->error_indicator) { |
| 15132 | return NULL; |
| 15133 | } |
| 15134 | void * res = NULL; |
| 15135 | int mark = p->mark; |
| 15136 | { // tuple |
| 15137 | expr_ty tuple_var; |
| 15138 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15139 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15140 | ) |
| 15141 | { |
| 15142 | res = tuple_var; |
| 15143 | goto done; |
| 15144 | } |
| 15145 | p->mark = mark; |
| 15146 | } |
| 15147 | { // group |
| 15148 | expr_ty group_var; |
| 15149 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15150 | (group_var = group_rule(p)) // group |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15151 | ) |
| 15152 | { |
| 15153 | res = group_var; |
| 15154 | goto done; |
| 15155 | } |
| 15156 | p->mark = mark; |
| 15157 | } |
| 15158 | { // genexp |
| 15159 | expr_ty genexp_var; |
| 15160 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15161 | (genexp_var = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15162 | ) |
| 15163 | { |
| 15164 | res = genexp_var; |
| 15165 | goto done; |
| 15166 | } |
| 15167 | p->mark = mark; |
| 15168 | } |
| 15169 | res = NULL; |
| 15170 | done: |
| 15171 | return res; |
| 15172 | } |
| 15173 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15174 | // _tmp_97: list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15175 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15176 | _tmp_97_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15177 | { |
| 15178 | if (p->error_indicator) { |
| 15179 | return NULL; |
| 15180 | } |
| 15181 | void * res = NULL; |
| 15182 | int mark = p->mark; |
| 15183 | { // list |
| 15184 | expr_ty list_var; |
| 15185 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15186 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15187 | ) |
| 15188 | { |
| 15189 | res = list_var; |
| 15190 | goto done; |
| 15191 | } |
| 15192 | p->mark = mark; |
| 15193 | } |
| 15194 | { // listcomp |
| 15195 | expr_ty listcomp_var; |
| 15196 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15197 | (listcomp_var = listcomp_rule(p)) // listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15198 | ) |
| 15199 | { |
| 15200 | res = listcomp_var; |
| 15201 | goto done; |
| 15202 | } |
| 15203 | p->mark = mark; |
| 15204 | } |
| 15205 | res = NULL; |
| 15206 | done: |
| 15207 | return res; |
| 15208 | } |
| 15209 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15210 | // _tmp_98: dict | set | dictcomp | setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15211 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15212 | _tmp_98_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15213 | { |
| 15214 | if (p->error_indicator) { |
| 15215 | return NULL; |
| 15216 | } |
| 15217 | void * res = NULL; |
| 15218 | int mark = p->mark; |
| 15219 | { // dict |
| 15220 | expr_ty dict_var; |
| 15221 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15222 | (dict_var = dict_rule(p)) // dict |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15223 | ) |
| 15224 | { |
| 15225 | res = dict_var; |
| 15226 | goto done; |
| 15227 | } |
| 15228 | p->mark = mark; |
| 15229 | } |
| 15230 | { // set |
| 15231 | expr_ty set_var; |
| 15232 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15233 | (set_var = set_rule(p)) // set |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15234 | ) |
| 15235 | { |
| 15236 | res = set_var; |
| 15237 | goto done; |
| 15238 | } |
| 15239 | p->mark = mark; |
| 15240 | } |
| 15241 | { // dictcomp |
| 15242 | expr_ty dictcomp_var; |
| 15243 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15244 | (dictcomp_var = dictcomp_rule(p)) // dictcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15245 | ) |
| 15246 | { |
| 15247 | res = dictcomp_var; |
| 15248 | goto done; |
| 15249 | } |
| 15250 | p->mark = mark; |
| 15251 | } |
| 15252 | { // setcomp |
| 15253 | expr_ty setcomp_var; |
| 15254 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15255 | (setcomp_var = setcomp_rule(p)) // setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15256 | ) |
| 15257 | { |
| 15258 | res = setcomp_var; |
| 15259 | goto done; |
| 15260 | } |
| 15261 | p->mark = mark; |
| 15262 | } |
| 15263 | res = NULL; |
| 15264 | done: |
| 15265 | return res; |
| 15266 | } |
| 15267 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15268 | // _loop1_99: STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15269 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15270 | _loop1_99_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15271 | { |
| 15272 | if (p->error_indicator) { |
| 15273 | return NULL; |
| 15274 | } |
| 15275 | void *res = NULL; |
| 15276 | int mark = p->mark; |
| 15277 | int start_mark = p->mark; |
| 15278 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15279 | if (!children) { |
| 15280 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15281 | return NULL; |
| 15282 | } |
| 15283 | ssize_t children_capacity = 1; |
| 15284 | ssize_t n = 0; |
| 15285 | { // STRING |
| 15286 | expr_ty string_var; |
| 15287 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15288 | (string_var = _PyPegen_string_token(p)) // STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15289 | ) |
| 15290 | { |
| 15291 | res = string_var; |
| 15292 | if (n == children_capacity) { |
| 15293 | children_capacity *= 2; |
| 15294 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15295 | if (!children) { |
| 15296 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15297 | return NULL; |
| 15298 | } |
| 15299 | } |
| 15300 | children[n++] = res; |
| 15301 | mark = p->mark; |
| 15302 | } |
| 15303 | p->mark = mark; |
| 15304 | } |
| 15305 | if (n == 0) { |
| 15306 | PyMem_Free(children); |
| 15307 | return NULL; |
| 15308 | } |
| 15309 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15310 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15311 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15312 | PyMem_Free(children); |
| 15313 | return NULL; |
| 15314 | } |
| 15315 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15316 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15317 | _PyPegen_insert_memo(p, start_mark, _loop1_99_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15318 | return seq; |
| 15319 | } |
| 15320 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15321 | // _tmp_100: star_named_expression ',' star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15322 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15323 | _tmp_100_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15324 | { |
| 15325 | if (p->error_indicator) { |
| 15326 | return NULL; |
| 15327 | } |
| 15328 | void * res = NULL; |
| 15329 | int mark = p->mark; |
| 15330 | { // star_named_expression ',' star_named_expressions? |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15331 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15332 | expr_ty y; |
| 15333 | void *z; |
| 15334 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15335 | (y = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15336 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15337 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15338 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15339 | (z = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15340 | ) |
| 15341 | { |
| 15342 | res = _PyPegen_seq_insert_in_front ( p , y , z ); |
| 15343 | if (res == NULL && PyErr_Occurred()) { |
| 15344 | p->error_indicator = 1; |
| 15345 | return NULL; |
| 15346 | } |
| 15347 | goto done; |
| 15348 | } |
| 15349 | p->mark = mark; |
| 15350 | } |
| 15351 | res = NULL; |
| 15352 | done: |
| 15353 | return res; |
| 15354 | } |
| 15355 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15356 | // _tmp_101: yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15357 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15358 | _tmp_101_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15359 | { |
| 15360 | if (p->error_indicator) { |
| 15361 | return NULL; |
| 15362 | } |
| 15363 | void * res = NULL; |
| 15364 | int mark = p->mark; |
| 15365 | { // yield_expr |
| 15366 | expr_ty yield_expr_var; |
| 15367 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15368 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15369 | ) |
| 15370 | { |
| 15371 | res = yield_expr_var; |
| 15372 | goto done; |
| 15373 | } |
| 15374 | p->mark = mark; |
| 15375 | } |
| 15376 | { // named_expression |
| 15377 | expr_ty named_expression_var; |
| 15378 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15379 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15380 | ) |
| 15381 | { |
| 15382 | res = named_expression_var; |
| 15383 | goto done; |
| 15384 | } |
| 15385 | p->mark = mark; |
| 15386 | } |
| 15387 | res = NULL; |
| 15388 | done: |
| 15389 | return res; |
| 15390 | } |
| 15391 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15392 | // _loop0_103: ',' kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15393 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15394 | _loop0_103_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15395 | { |
| 15396 | if (p->error_indicator) { |
| 15397 | return NULL; |
| 15398 | } |
| 15399 | void *res = NULL; |
| 15400 | int mark = p->mark; |
| 15401 | int start_mark = p->mark; |
| 15402 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15403 | if (!children) { |
| 15404 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15405 | return NULL; |
| 15406 | } |
| 15407 | ssize_t children_capacity = 1; |
| 15408 | ssize_t n = 0; |
| 15409 | { // ',' kvpair |
| 15410 | KeyValuePair* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15411 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15412 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15413 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15414 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15415 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15416 | ) |
| 15417 | { |
| 15418 | res = elem; |
| 15419 | if (res == NULL && PyErr_Occurred()) { |
| 15420 | p->error_indicator = 1; |
| 15421 | PyMem_Free(children); |
| 15422 | return NULL; |
| 15423 | } |
| 15424 | if (n == children_capacity) { |
| 15425 | children_capacity *= 2; |
| 15426 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15427 | if (!children) { |
| 15428 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15429 | return NULL; |
| 15430 | } |
| 15431 | } |
| 15432 | children[n++] = res; |
| 15433 | mark = p->mark; |
| 15434 | } |
| 15435 | p->mark = mark; |
| 15436 | } |
| 15437 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15438 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15439 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15440 | PyMem_Free(children); |
| 15441 | return NULL; |
| 15442 | } |
| 15443 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15444 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15445 | _PyPegen_insert_memo(p, start_mark, _loop0_103_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15446 | return seq; |
| 15447 | } |
| 15448 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15449 | // _gather_102: kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15450 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15451 | _gather_102_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15452 | { |
| 15453 | if (p->error_indicator) { |
| 15454 | return NULL; |
| 15455 | } |
| 15456 | asdl_seq * res = NULL; |
| 15457 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15458 | { // kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15459 | KeyValuePair* elem; |
| 15460 | asdl_seq * seq; |
| 15461 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15462 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15463 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15464 | (seq = _loop0_103_rule(p)) // _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15465 | ) |
| 15466 | { |
| 15467 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15468 | goto done; |
| 15469 | } |
| 15470 | p->mark = mark; |
| 15471 | } |
| 15472 | res = NULL; |
| 15473 | done: |
| 15474 | return res; |
| 15475 | } |
| 15476 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15477 | // _loop1_104: for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15478 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15479 | _loop1_104_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15480 | { |
| 15481 | if (p->error_indicator) { |
| 15482 | return NULL; |
| 15483 | } |
| 15484 | void *res = NULL; |
| 15485 | int mark = p->mark; |
| 15486 | int start_mark = p->mark; |
| 15487 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15488 | if (!children) { |
| 15489 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15490 | return NULL; |
| 15491 | } |
| 15492 | ssize_t children_capacity = 1; |
| 15493 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15494 | { // for_if_clause |
| 15495 | comprehension_ty for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15496 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15497 | (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15498 | ) |
| 15499 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15500 | res = for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15501 | if (n == children_capacity) { |
| 15502 | children_capacity *= 2; |
| 15503 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15504 | if (!children) { |
| 15505 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15506 | return NULL; |
| 15507 | } |
| 15508 | } |
| 15509 | children[n++] = res; |
| 15510 | mark = p->mark; |
| 15511 | } |
| 15512 | p->mark = mark; |
| 15513 | } |
| 15514 | if (n == 0) { |
| 15515 | PyMem_Free(children); |
| 15516 | return NULL; |
| 15517 | } |
| 15518 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15519 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15520 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15521 | PyMem_Free(children); |
| 15522 | return NULL; |
| 15523 | } |
| 15524 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15525 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15526 | _PyPegen_insert_memo(p, start_mark, _loop1_104_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15527 | return seq; |
| 15528 | } |
| 15529 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15530 | // _loop0_105: ('if' disjunction) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15531 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15532 | _loop0_105_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15533 | { |
| 15534 | if (p->error_indicator) { |
| 15535 | return NULL; |
| 15536 | } |
| 15537 | void *res = NULL; |
| 15538 | int mark = p->mark; |
| 15539 | int start_mark = p->mark; |
| 15540 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15541 | if (!children) { |
| 15542 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15543 | return NULL; |
| 15544 | } |
| 15545 | ssize_t children_capacity = 1; |
| 15546 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15547 | { // ('if' disjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15548 | void *_tmp_142_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15549 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15550 | (_tmp_142_var = _tmp_142_rule(p)) // 'if' disjunction |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15551 | ) |
| 15552 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15553 | res = _tmp_142_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15554 | if (n == children_capacity) { |
| 15555 | children_capacity *= 2; |
| 15556 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15557 | if (!children) { |
| 15558 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15559 | return NULL; |
| 15560 | } |
| 15561 | } |
| 15562 | children[n++] = res; |
| 15563 | mark = p->mark; |
| 15564 | } |
| 15565 | p->mark = mark; |
| 15566 | } |
| 15567 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15568 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15569 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105"); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15570 | PyMem_Free(children); |
| 15571 | return NULL; |
| 15572 | } |
| 15573 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15574 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15575 | _PyPegen_insert_memo(p, start_mark, _loop0_105_type, seq); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15576 | return seq; |
| 15577 | } |
| 15578 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15579 | // _loop0_106: ('if' disjunction) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15580 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15581 | _loop0_106_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15582 | { |
| 15583 | if (p->error_indicator) { |
| 15584 | return NULL; |
| 15585 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15586 | void *res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15587 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15588 | int start_mark = p->mark; |
| 15589 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15590 | if (!children) { |
| 15591 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15592 | return NULL; |
| 15593 | } |
| 15594 | ssize_t children_capacity = 1; |
| 15595 | ssize_t n = 0; |
| 15596 | { // ('if' disjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15597 | void *_tmp_143_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15598 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15599 | (_tmp_143_var = _tmp_143_rule(p)) // 'if' disjunction |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15600 | ) |
| 15601 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15602 | res = _tmp_143_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15603 | if (n == children_capacity) { |
| 15604 | children_capacity *= 2; |
| 15605 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15606 | if (!children) { |
| 15607 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15608 | return NULL; |
| 15609 | } |
| 15610 | } |
| 15611 | children[n++] = res; |
| 15612 | mark = p->mark; |
| 15613 | } |
| 15614 | p->mark = mark; |
| 15615 | } |
| 15616 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15617 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15618 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106"); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15619 | PyMem_Free(children); |
| 15620 | return NULL; |
| 15621 | } |
| 15622 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15623 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15624 | _PyPegen_insert_memo(p, start_mark, _loop0_106_type, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15625 | return seq; |
| 15626 | } |
| 15627 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15628 | // _tmp_107: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15629 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15630 | _tmp_107_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15631 | { |
| 15632 | if (p->error_indicator) { |
| 15633 | return NULL; |
| 15634 | } |
| 15635 | void * res = NULL; |
| 15636 | int mark = p->mark; |
| 15637 | { // ',' args |
| 15638 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15639 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15640 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15641 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15642 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15643 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15644 | ) |
| 15645 | { |
| 15646 | res = c; |
| 15647 | if (res == NULL && PyErr_Occurred()) { |
| 15648 | p->error_indicator = 1; |
| 15649 | return NULL; |
| 15650 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15651 | goto done; |
| 15652 | } |
| 15653 | p->mark = mark; |
| 15654 | } |
| 15655 | res = NULL; |
| 15656 | done: |
| 15657 | return res; |
| 15658 | } |
| 15659 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15660 | // _tmp_108: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15661 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15662 | _tmp_108_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15663 | { |
| 15664 | if (p->error_indicator) { |
| 15665 | return NULL; |
| 15666 | } |
| 15667 | void * res = NULL; |
| 15668 | int mark = p->mark; |
| 15669 | { // ',' args |
| 15670 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15671 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15672 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15673 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15674 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15675 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15676 | ) |
| 15677 | { |
| 15678 | res = c; |
| 15679 | if (res == NULL && PyErr_Occurred()) { |
| 15680 | p->error_indicator = 1; |
| 15681 | return NULL; |
| 15682 | } |
| 15683 | goto done; |
| 15684 | } |
| 15685 | p->mark = mark; |
| 15686 | } |
| 15687 | res = NULL; |
| 15688 | done: |
| 15689 | return res; |
| 15690 | } |
| 15691 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15692 | // _loop0_110: ',' kwarg_or_starred |
| 15693 | static asdl_seq * |
| 15694 | _loop0_110_rule(Parser *p) |
| 15695 | { |
| 15696 | if (p->error_indicator) { |
| 15697 | return NULL; |
| 15698 | } |
| 15699 | void *res = NULL; |
| 15700 | int mark = p->mark; |
| 15701 | int start_mark = p->mark; |
| 15702 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15703 | if (!children) { |
| 15704 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15705 | return NULL; |
| 15706 | } |
| 15707 | ssize_t children_capacity = 1; |
| 15708 | ssize_t n = 0; |
| 15709 | { // ',' kwarg_or_starred |
| 15710 | KeywordOrStarred* elem; |
| 15711 | Token * literal; |
| 15712 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15713 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15714 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15715 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15716 | ) |
| 15717 | { |
| 15718 | res = elem; |
| 15719 | if (res == NULL && PyErr_Occurred()) { |
| 15720 | p->error_indicator = 1; |
| 15721 | PyMem_Free(children); |
| 15722 | return NULL; |
| 15723 | } |
| 15724 | if (n == children_capacity) { |
| 15725 | children_capacity *= 2; |
| 15726 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15727 | if (!children) { |
| 15728 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15729 | return NULL; |
| 15730 | } |
| 15731 | } |
| 15732 | children[n++] = res; |
| 15733 | mark = p->mark; |
| 15734 | } |
| 15735 | p->mark = mark; |
| 15736 | } |
| 15737 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15738 | if (!seq) { |
| 15739 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110"); |
| 15740 | PyMem_Free(children); |
| 15741 | return NULL; |
| 15742 | } |
| 15743 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15744 | PyMem_Free(children); |
| 15745 | _PyPegen_insert_memo(p, start_mark, _loop0_110_type, seq); |
| 15746 | return seq; |
| 15747 | } |
| 15748 | |
| 15749 | // _gather_109: kwarg_or_starred _loop0_110 |
| 15750 | static asdl_seq * |
| 15751 | _gather_109_rule(Parser *p) |
| 15752 | { |
| 15753 | if (p->error_indicator) { |
| 15754 | return NULL; |
| 15755 | } |
| 15756 | asdl_seq * res = NULL; |
| 15757 | int mark = p->mark; |
| 15758 | { // kwarg_or_starred _loop0_110 |
| 15759 | KeywordOrStarred* elem; |
| 15760 | asdl_seq * seq; |
| 15761 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15762 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15763 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15764 | (seq = _loop0_110_rule(p)) // _loop0_110 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15765 | ) |
| 15766 | { |
| 15767 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15768 | goto done; |
| 15769 | } |
| 15770 | p->mark = mark; |
| 15771 | } |
| 15772 | res = NULL; |
| 15773 | done: |
| 15774 | return res; |
| 15775 | } |
| 15776 | |
| 15777 | // _loop0_112: ',' kwarg_or_double_starred |
| 15778 | static asdl_seq * |
| 15779 | _loop0_112_rule(Parser *p) |
| 15780 | { |
| 15781 | if (p->error_indicator) { |
| 15782 | return NULL; |
| 15783 | } |
| 15784 | void *res = NULL; |
| 15785 | int mark = p->mark; |
| 15786 | int start_mark = p->mark; |
| 15787 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15788 | if (!children) { |
| 15789 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15790 | return NULL; |
| 15791 | } |
| 15792 | ssize_t children_capacity = 1; |
| 15793 | ssize_t n = 0; |
| 15794 | { // ',' kwarg_or_double_starred |
| 15795 | KeywordOrStarred* elem; |
| 15796 | Token * literal; |
| 15797 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15798 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15799 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15800 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15801 | ) |
| 15802 | { |
| 15803 | res = elem; |
| 15804 | if (res == NULL && PyErr_Occurred()) { |
| 15805 | p->error_indicator = 1; |
| 15806 | PyMem_Free(children); |
| 15807 | return NULL; |
| 15808 | } |
| 15809 | if (n == children_capacity) { |
| 15810 | children_capacity *= 2; |
| 15811 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15812 | if (!children) { |
| 15813 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15814 | return NULL; |
| 15815 | } |
| 15816 | } |
| 15817 | children[n++] = res; |
| 15818 | mark = p->mark; |
| 15819 | } |
| 15820 | p->mark = mark; |
| 15821 | } |
| 15822 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15823 | if (!seq) { |
| 15824 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112"); |
| 15825 | PyMem_Free(children); |
| 15826 | return NULL; |
| 15827 | } |
| 15828 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15829 | PyMem_Free(children); |
| 15830 | _PyPegen_insert_memo(p, start_mark, _loop0_112_type, seq); |
| 15831 | return seq; |
| 15832 | } |
| 15833 | |
| 15834 | // _gather_111: kwarg_or_double_starred _loop0_112 |
| 15835 | static asdl_seq * |
| 15836 | _gather_111_rule(Parser *p) |
| 15837 | { |
| 15838 | if (p->error_indicator) { |
| 15839 | return NULL; |
| 15840 | } |
| 15841 | asdl_seq * res = NULL; |
| 15842 | int mark = p->mark; |
| 15843 | { // kwarg_or_double_starred _loop0_112 |
| 15844 | KeywordOrStarred* elem; |
| 15845 | asdl_seq * seq; |
| 15846 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15847 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15848 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15849 | (seq = _loop0_112_rule(p)) // _loop0_112 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15850 | ) |
| 15851 | { |
| 15852 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15853 | goto done; |
| 15854 | } |
| 15855 | p->mark = mark; |
| 15856 | } |
| 15857 | res = NULL; |
| 15858 | done: |
| 15859 | return res; |
| 15860 | } |
| 15861 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15862 | // _loop0_114: ',' kwarg_or_starred |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15863 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15864 | _loop0_114_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15865 | { |
| 15866 | if (p->error_indicator) { |
| 15867 | return NULL; |
| 15868 | } |
| 15869 | void *res = NULL; |
| 15870 | int mark = p->mark; |
| 15871 | int start_mark = p->mark; |
| 15872 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15873 | if (!children) { |
| 15874 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15875 | return NULL; |
| 15876 | } |
| 15877 | ssize_t children_capacity = 1; |
| 15878 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15879 | { // ',' kwarg_or_starred |
| 15880 | KeywordOrStarred* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15881 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15882 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15883 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15884 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15885 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15886 | ) |
| 15887 | { |
| 15888 | res = elem; |
| 15889 | if (res == NULL && PyErr_Occurred()) { |
| 15890 | p->error_indicator = 1; |
| 15891 | PyMem_Free(children); |
| 15892 | return NULL; |
| 15893 | } |
| 15894 | if (n == children_capacity) { |
| 15895 | children_capacity *= 2; |
| 15896 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15897 | if (!children) { |
| 15898 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15899 | return NULL; |
| 15900 | } |
| 15901 | } |
| 15902 | children[n++] = res; |
| 15903 | mark = p->mark; |
| 15904 | } |
| 15905 | p->mark = mark; |
| 15906 | } |
| 15907 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15908 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15909 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15910 | PyMem_Free(children); |
| 15911 | return NULL; |
| 15912 | } |
| 15913 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15914 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15915 | _PyPegen_insert_memo(p, start_mark, _loop0_114_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15916 | return seq; |
| 15917 | } |
| 15918 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15919 | // _gather_113: kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15920 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15921 | _gather_113_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15922 | { |
| 15923 | if (p->error_indicator) { |
| 15924 | return NULL; |
| 15925 | } |
| 15926 | asdl_seq * res = NULL; |
| 15927 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15928 | { // kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15929 | KeywordOrStarred* elem; |
| 15930 | asdl_seq * seq; |
| 15931 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15932 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15933 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15934 | (seq = _loop0_114_rule(p)) // _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15935 | ) |
| 15936 | { |
| 15937 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15938 | goto done; |
| 15939 | } |
| 15940 | p->mark = mark; |
| 15941 | } |
| 15942 | res = NULL; |
| 15943 | done: |
| 15944 | return res; |
| 15945 | } |
| 15946 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15947 | // _loop0_116: ',' kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15948 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15949 | _loop0_116_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15950 | { |
| 15951 | if (p->error_indicator) { |
| 15952 | return NULL; |
| 15953 | } |
| 15954 | void *res = NULL; |
| 15955 | int mark = p->mark; |
| 15956 | int start_mark = p->mark; |
| 15957 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15958 | if (!children) { |
| 15959 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15960 | return NULL; |
| 15961 | } |
| 15962 | ssize_t children_capacity = 1; |
| 15963 | ssize_t n = 0; |
| 15964 | { // ',' kwarg_or_double_starred |
| 15965 | KeywordOrStarred* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15966 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15967 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15968 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15969 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 15970 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15971 | ) |
| 15972 | { |
| 15973 | res = elem; |
| 15974 | if (res == NULL && PyErr_Occurred()) { |
| 15975 | p->error_indicator = 1; |
| 15976 | PyMem_Free(children); |
| 15977 | return NULL; |
| 15978 | } |
| 15979 | if (n == children_capacity) { |
| 15980 | children_capacity *= 2; |
| 15981 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15982 | if (!children) { |
| 15983 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15984 | return NULL; |
| 15985 | } |
| 15986 | } |
| 15987 | children[n++] = res; |
| 15988 | mark = p->mark; |
| 15989 | } |
| 15990 | p->mark = mark; |
| 15991 | } |
| 15992 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15993 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15994 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15995 | PyMem_Free(children); |
| 15996 | return NULL; |
| 15997 | } |
| 15998 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15999 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16000 | _PyPegen_insert_memo(p, start_mark, _loop0_116_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16001 | return seq; |
| 16002 | } |
| 16003 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16004 | // _gather_115: kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16005 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16006 | _gather_115_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16007 | { |
| 16008 | if (p->error_indicator) { |
| 16009 | return NULL; |
| 16010 | } |
| 16011 | asdl_seq * res = NULL; |
| 16012 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16013 | { // kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16014 | KeywordOrStarred* elem; |
| 16015 | asdl_seq * seq; |
| 16016 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16017 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16018 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16019 | (seq = _loop0_116_rule(p)) // _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16020 | ) |
| 16021 | { |
| 16022 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16023 | goto done; |
| 16024 | } |
| 16025 | p->mark = mark; |
| 16026 | } |
| 16027 | res = NULL; |
| 16028 | done: |
| 16029 | return res; |
| 16030 | } |
| 16031 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16032 | // _loop0_117: (',' star_target) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16033 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16034 | _loop0_117_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16035 | { |
| 16036 | if (p->error_indicator) { |
| 16037 | return NULL; |
| 16038 | } |
| 16039 | void *res = NULL; |
| 16040 | int mark = p->mark; |
| 16041 | int start_mark = p->mark; |
| 16042 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16043 | if (!children) { |
| 16044 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16045 | return NULL; |
| 16046 | } |
| 16047 | ssize_t children_capacity = 1; |
| 16048 | ssize_t n = 0; |
| 16049 | { // (',' star_target) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16050 | void *_tmp_144_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16051 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16052 | (_tmp_144_var = _tmp_144_rule(p)) // ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16053 | ) |
| 16054 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16055 | res = _tmp_144_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16056 | if (n == children_capacity) { |
| 16057 | children_capacity *= 2; |
| 16058 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16059 | if (!children) { |
| 16060 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16061 | return NULL; |
| 16062 | } |
| 16063 | } |
| 16064 | children[n++] = res; |
| 16065 | mark = p->mark; |
| 16066 | } |
| 16067 | p->mark = mark; |
| 16068 | } |
| 16069 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16070 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16071 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117"); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16072 | PyMem_Free(children); |
| 16073 | return NULL; |
| 16074 | } |
| 16075 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16076 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16077 | _PyPegen_insert_memo(p, start_mark, _loop0_117_type, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16078 | return seq; |
| 16079 | } |
| 16080 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16081 | // _loop0_119: ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16082 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16083 | _loop0_119_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16084 | { |
| 16085 | if (p->error_indicator) { |
| 16086 | return NULL; |
| 16087 | } |
| 16088 | void *res = NULL; |
| 16089 | int mark = p->mark; |
| 16090 | int start_mark = p->mark; |
| 16091 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16092 | if (!children) { |
| 16093 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16094 | return NULL; |
| 16095 | } |
| 16096 | ssize_t children_capacity = 1; |
| 16097 | ssize_t n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16098 | { // ',' star_target |
| 16099 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16100 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16101 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16102 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16103 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16104 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16105 | ) |
| 16106 | { |
| 16107 | res = elem; |
| 16108 | if (res == NULL && PyErr_Occurred()) { |
| 16109 | p->error_indicator = 1; |
| 16110 | PyMem_Free(children); |
| 16111 | return NULL; |
| 16112 | } |
| 16113 | if (n == children_capacity) { |
| 16114 | children_capacity *= 2; |
| 16115 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16116 | if (!children) { |
| 16117 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16118 | return NULL; |
| 16119 | } |
| 16120 | } |
| 16121 | children[n++] = res; |
| 16122 | mark = p->mark; |
| 16123 | } |
| 16124 | p->mark = mark; |
| 16125 | } |
| 16126 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16127 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16128 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16129 | PyMem_Free(children); |
| 16130 | return NULL; |
| 16131 | } |
| 16132 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16133 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16134 | _PyPegen_insert_memo(p, start_mark, _loop0_119_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16135 | return seq; |
| 16136 | } |
| 16137 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16138 | // _gather_118: star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16139 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16140 | _gather_118_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16141 | { |
| 16142 | if (p->error_indicator) { |
| 16143 | return NULL; |
| 16144 | } |
| 16145 | asdl_seq * res = NULL; |
| 16146 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16147 | { // star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16148 | expr_ty elem; |
| 16149 | asdl_seq * seq; |
| 16150 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16151 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16152 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16153 | (seq = _loop0_119_rule(p)) // _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16154 | ) |
| 16155 | { |
| 16156 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16157 | goto done; |
| 16158 | } |
| 16159 | p->mark = mark; |
| 16160 | } |
| 16161 | res = NULL; |
| 16162 | done: |
| 16163 | return res; |
| 16164 | } |
| 16165 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16166 | // _tmp_120: !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16167 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16168 | _tmp_120_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16169 | { |
| 16170 | if (p->error_indicator) { |
| 16171 | return NULL; |
| 16172 | } |
| 16173 | void * res = NULL; |
| 16174 | int mark = p->mark; |
| 16175 | { // !'*' star_target |
| 16176 | expr_ty star_target_var; |
| 16177 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16178 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16179 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16180 | (star_target_var = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16181 | ) |
| 16182 | { |
| 16183 | res = star_target_var; |
| 16184 | goto done; |
| 16185 | } |
| 16186 | p->mark = mark; |
| 16187 | } |
| 16188 | res = NULL; |
| 16189 | done: |
| 16190 | return res; |
| 16191 | } |
| 16192 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16193 | // _loop0_122: ',' del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16194 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16195 | _loop0_122_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16196 | { |
| 16197 | if (p->error_indicator) { |
| 16198 | return NULL; |
| 16199 | } |
| 16200 | void *res = NULL; |
| 16201 | int mark = p->mark; |
| 16202 | int start_mark = p->mark; |
| 16203 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16204 | if (!children) { |
| 16205 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16206 | return NULL; |
| 16207 | } |
| 16208 | ssize_t children_capacity = 1; |
| 16209 | ssize_t n = 0; |
| 16210 | { // ',' del_target |
| 16211 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16212 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16213 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16214 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16215 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16216 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16217 | ) |
| 16218 | { |
| 16219 | res = elem; |
| 16220 | if (res == NULL && PyErr_Occurred()) { |
| 16221 | p->error_indicator = 1; |
| 16222 | PyMem_Free(children); |
| 16223 | return NULL; |
| 16224 | } |
| 16225 | if (n == children_capacity) { |
| 16226 | children_capacity *= 2; |
| 16227 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16228 | if (!children) { |
| 16229 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16230 | return NULL; |
| 16231 | } |
| 16232 | } |
| 16233 | children[n++] = res; |
| 16234 | mark = p->mark; |
| 16235 | } |
| 16236 | p->mark = mark; |
| 16237 | } |
| 16238 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16239 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16240 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16241 | PyMem_Free(children); |
| 16242 | return NULL; |
| 16243 | } |
| 16244 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16245 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16246 | _PyPegen_insert_memo(p, start_mark, _loop0_122_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16247 | return seq; |
| 16248 | } |
| 16249 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16250 | // _gather_121: del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16251 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16252 | _gather_121_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16253 | { |
| 16254 | if (p->error_indicator) { |
| 16255 | return NULL; |
| 16256 | } |
| 16257 | asdl_seq * res = NULL; |
| 16258 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16259 | { // del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16260 | expr_ty elem; |
| 16261 | asdl_seq * seq; |
| 16262 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16263 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16264 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16265 | (seq = _loop0_122_rule(p)) // _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16266 | ) |
| 16267 | { |
| 16268 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16269 | goto done; |
| 16270 | } |
| 16271 | p->mark = mark; |
| 16272 | } |
| 16273 | res = NULL; |
| 16274 | done: |
| 16275 | return res; |
| 16276 | } |
| 16277 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16278 | // _loop0_124: ',' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16279 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16280 | _loop0_124_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16281 | { |
| 16282 | if (p->error_indicator) { |
| 16283 | return NULL; |
| 16284 | } |
| 16285 | void *res = NULL; |
| 16286 | int mark = p->mark; |
| 16287 | int start_mark = p->mark; |
| 16288 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16289 | if (!children) { |
| 16290 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16291 | return NULL; |
| 16292 | } |
| 16293 | ssize_t children_capacity = 1; |
| 16294 | ssize_t n = 0; |
| 16295 | { // ',' target |
| 16296 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16297 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16298 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16299 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16300 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16301 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16302 | ) |
| 16303 | { |
| 16304 | res = elem; |
| 16305 | if (res == NULL && PyErr_Occurred()) { |
| 16306 | p->error_indicator = 1; |
| 16307 | PyMem_Free(children); |
| 16308 | return NULL; |
| 16309 | } |
| 16310 | if (n == children_capacity) { |
| 16311 | children_capacity *= 2; |
| 16312 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16313 | if (!children) { |
| 16314 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16315 | return NULL; |
| 16316 | } |
| 16317 | } |
| 16318 | children[n++] = res; |
| 16319 | mark = p->mark; |
| 16320 | } |
| 16321 | p->mark = mark; |
| 16322 | } |
| 16323 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16324 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16325 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16326 | PyMem_Free(children); |
| 16327 | return NULL; |
| 16328 | } |
| 16329 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16330 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16331 | _PyPegen_insert_memo(p, start_mark, _loop0_124_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16332 | return seq; |
| 16333 | } |
| 16334 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16335 | // _gather_123: target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16336 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16337 | _gather_123_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16338 | { |
| 16339 | if (p->error_indicator) { |
| 16340 | return NULL; |
| 16341 | } |
| 16342 | asdl_seq * res = NULL; |
| 16343 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16344 | { // target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16345 | expr_ty elem; |
| 16346 | asdl_seq * seq; |
| 16347 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16348 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16349 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16350 | (seq = _loop0_124_rule(p)) // _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16351 | ) |
| 16352 | { |
| 16353 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16354 | goto done; |
| 16355 | } |
| 16356 | p->mark = mark; |
| 16357 | } |
| 16358 | res = NULL; |
| 16359 | done: |
| 16360 | return res; |
| 16361 | } |
| 16362 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16363 | // _tmp_125: args | expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16364 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16365 | _tmp_125_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16366 | { |
| 16367 | if (p->error_indicator) { |
| 16368 | return NULL; |
| 16369 | } |
| 16370 | void * res = NULL; |
| 16371 | int mark = p->mark; |
| 16372 | { // args |
| 16373 | expr_ty args_var; |
| 16374 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16375 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16376 | ) |
| 16377 | { |
| 16378 | res = args_var; |
| 16379 | goto done; |
| 16380 | } |
| 16381 | p->mark = mark; |
| 16382 | } |
| 16383 | { // expression for_if_clauses |
| 16384 | expr_ty expression_var; |
| 16385 | asdl_seq* for_if_clauses_var; |
| 16386 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16387 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16388 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16389 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16390 | ) |
| 16391 | { |
| 16392 | res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); |
| 16393 | goto done; |
| 16394 | } |
| 16395 | p->mark = mark; |
| 16396 | } |
| 16397 | res = NULL; |
| 16398 | done: |
| 16399 | return res; |
| 16400 | } |
| 16401 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16402 | // _tmp_126: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16403 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16404 | _tmp_126_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16405 | { |
| 16406 | if (p->error_indicator) { |
| 16407 | return NULL; |
| 16408 | } |
| 16409 | void * res = NULL; |
| 16410 | int mark = p->mark; |
| 16411 | { // '=' annotated_rhs |
| 16412 | expr_ty annotated_rhs_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16413 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16414 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16415 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16416 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16417 | (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16418 | ) |
| 16419 | { |
| 16420 | res = _PyPegen_dummy_name(p, literal, annotated_rhs_var); |
| 16421 | goto done; |
| 16422 | } |
| 16423 | p->mark = mark; |
| 16424 | } |
| 16425 | res = NULL; |
| 16426 | done: |
| 16427 | return res; |
| 16428 | } |
| 16429 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16430 | // _tmp_127: '=' | augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16431 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16432 | _tmp_127_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16433 | { |
| 16434 | if (p->error_indicator) { |
| 16435 | return NULL; |
| 16436 | } |
| 16437 | void * res = NULL; |
| 16438 | int mark = p->mark; |
| 16439 | { // '=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16440 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16441 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16442 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16443 | ) |
| 16444 | { |
| 16445 | res = literal; |
| 16446 | goto done; |
| 16447 | } |
| 16448 | p->mark = mark; |
| 16449 | } |
| 16450 | { // augassign |
| 16451 | AugOperator* augassign_var; |
| 16452 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16453 | (augassign_var = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16454 | ) |
| 16455 | { |
| 16456 | res = augassign_var; |
| 16457 | goto done; |
| 16458 | } |
| 16459 | p->mark = mark; |
| 16460 | } |
| 16461 | res = NULL; |
| 16462 | done: |
| 16463 | return res; |
| 16464 | } |
| 16465 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16466 | // _tmp_128: yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16467 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16468 | _tmp_128_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16469 | { |
| 16470 | if (p->error_indicator) { |
| 16471 | return NULL; |
| 16472 | } |
| 16473 | void * res = NULL; |
| 16474 | int mark = p->mark; |
| 16475 | { // yield_expr |
| 16476 | expr_ty yield_expr_var; |
| 16477 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16478 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16479 | ) |
| 16480 | { |
| 16481 | res = yield_expr_var; |
| 16482 | goto done; |
| 16483 | } |
| 16484 | p->mark = mark; |
| 16485 | } |
| 16486 | { // star_expressions |
| 16487 | expr_ty star_expressions_var; |
| 16488 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16489 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16490 | ) |
| 16491 | { |
| 16492 | res = star_expressions_var; |
| 16493 | goto done; |
| 16494 | } |
| 16495 | p->mark = mark; |
| 16496 | } |
| 16497 | res = NULL; |
| 16498 | done: |
| 16499 | return res; |
| 16500 | } |
| 16501 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16502 | // _tmp_129: '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16503 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16504 | _tmp_129_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16505 | { |
| 16506 | if (p->error_indicator) { |
| 16507 | return NULL; |
| 16508 | } |
| 16509 | void * res = NULL; |
| 16510 | int mark = p->mark; |
| 16511 | { // '[' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16512 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16513 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16514 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16515 | ) |
| 16516 | { |
| 16517 | res = literal; |
| 16518 | goto done; |
| 16519 | } |
| 16520 | p->mark = mark; |
| 16521 | } |
| 16522 | { // '(' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16523 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16524 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16525 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16526 | ) |
| 16527 | { |
| 16528 | res = literal; |
| 16529 | goto done; |
| 16530 | } |
| 16531 | p->mark = mark; |
| 16532 | } |
| 16533 | { // '{' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16534 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16535 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16536 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16537 | ) |
| 16538 | { |
| 16539 | res = literal; |
| 16540 | goto done; |
| 16541 | } |
| 16542 | p->mark = mark; |
| 16543 | } |
| 16544 | res = NULL; |
| 16545 | done: |
| 16546 | return res; |
| 16547 | } |
| 16548 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16549 | // _loop0_130: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16550 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16551 | _loop0_130_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16552 | { |
| 16553 | if (p->error_indicator) { |
| 16554 | return NULL; |
| 16555 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16556 | void *res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16557 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16558 | int start_mark = p->mark; |
| 16559 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16560 | if (!children) { |
| 16561 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16562 | return NULL; |
| 16563 | } |
| 16564 | ssize_t children_capacity = 1; |
| 16565 | ssize_t n = 0; |
| 16566 | { // param_no_default |
| 16567 | arg_ty param_no_default_var; |
| 16568 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16569 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16570 | ) |
| 16571 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16572 | res = param_no_default_var; |
| 16573 | if (n == children_capacity) { |
| 16574 | children_capacity *= 2; |
| 16575 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16576 | if (!children) { |
| 16577 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16578 | return NULL; |
| 16579 | } |
| 16580 | } |
| 16581 | children[n++] = res; |
| 16582 | mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16583 | } |
| 16584 | p->mark = mark; |
| 16585 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16586 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16587 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16588 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_130"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16589 | PyMem_Free(children); |
| 16590 | return NULL; |
| 16591 | } |
| 16592 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16593 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16594 | _PyPegen_insert_memo(p, start_mark, _loop0_130_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16595 | return seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16596 | } |
| 16597 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16598 | // _tmp_131: slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16599 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16600 | _tmp_131_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16601 | { |
| 16602 | if (p->error_indicator) { |
| 16603 | return NULL; |
| 16604 | } |
| 16605 | void * res = NULL; |
| 16606 | int mark = p->mark; |
| 16607 | { // slash_with_default |
| 16608 | SlashWithDefault* slash_with_default_var; |
| 16609 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16610 | (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16611 | ) |
| 16612 | { |
| 16613 | res = slash_with_default_var; |
| 16614 | goto done; |
| 16615 | } |
| 16616 | p->mark = mark; |
| 16617 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16618 | { // param_with_default+ |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16619 | asdl_seq * _loop1_145_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16620 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16621 | (_loop1_145_var = _loop1_145_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16622 | ) |
| 16623 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16624 | res = _loop1_145_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16625 | goto done; |
| 16626 | } |
| 16627 | p->mark = mark; |
| 16628 | } |
| 16629 | res = NULL; |
| 16630 | done: |
| 16631 | return res; |
| 16632 | } |
| 16633 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16634 | // _tmp_132: ')' | ',' (')' | '**') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16635 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16636 | _tmp_132_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16637 | { |
| 16638 | if (p->error_indicator) { |
| 16639 | return NULL; |
| 16640 | } |
| 16641 | void * res = NULL; |
| 16642 | int mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16643 | { // ')' |
| 16644 | Token * literal; |
| 16645 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16646 | (literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16647 | ) |
| 16648 | { |
| 16649 | res = literal; |
| 16650 | goto done; |
| 16651 | } |
| 16652 | p->mark = mark; |
| 16653 | } |
| 16654 | { // ',' (')' | '**') |
| 16655 | void *_tmp_146_var; |
| 16656 | Token * literal; |
| 16657 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16658 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16659 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16660 | (_tmp_146_var = _tmp_146_rule(p)) // ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16661 | ) |
| 16662 | { |
| 16663 | res = _PyPegen_dummy_name(p, literal, _tmp_146_var); |
| 16664 | goto done; |
| 16665 | } |
| 16666 | p->mark = mark; |
| 16667 | } |
| 16668 | res = NULL; |
| 16669 | done: |
| 16670 | return res; |
| 16671 | } |
| 16672 | |
| 16673 | // _tmp_133: ':' | ',' (':' | '**') |
| 16674 | static void * |
| 16675 | _tmp_133_rule(Parser *p) |
| 16676 | { |
| 16677 | if (p->error_indicator) { |
| 16678 | return NULL; |
| 16679 | } |
| 16680 | void * res = NULL; |
| 16681 | int mark = p->mark; |
| 16682 | { // ':' |
| 16683 | Token * literal; |
| 16684 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16685 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16686 | ) |
| 16687 | { |
| 16688 | res = literal; |
| 16689 | goto done; |
| 16690 | } |
| 16691 | p->mark = mark; |
| 16692 | } |
| 16693 | { // ',' (':' | '**') |
| 16694 | void *_tmp_147_var; |
| 16695 | Token * literal; |
| 16696 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16697 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16698 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16699 | (_tmp_147_var = _tmp_147_rule(p)) // ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16700 | ) |
| 16701 | { |
| 16702 | res = _PyPegen_dummy_name(p, literal, _tmp_147_var); |
| 16703 | goto done; |
| 16704 | } |
| 16705 | p->mark = mark; |
| 16706 | } |
| 16707 | res = NULL; |
| 16708 | done: |
| 16709 | return res; |
| 16710 | } |
| 16711 | |
| 16712 | // _tmp_134: star_targets '=' |
| 16713 | static void * |
| 16714 | _tmp_134_rule(Parser *p) |
| 16715 | { |
| 16716 | if (p->error_indicator) { |
| 16717 | return NULL; |
| 16718 | } |
| 16719 | void * res = NULL; |
| 16720 | int mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16721 | { // star_targets '=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16722 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16723 | expr_ty z; |
| 16724 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16725 | (z = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16726 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16727 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16728 | ) |
| 16729 | { |
| 16730 | res = z; |
| 16731 | if (res == NULL && PyErr_Occurred()) { |
| 16732 | p->error_indicator = 1; |
| 16733 | return NULL; |
| 16734 | } |
| 16735 | goto done; |
| 16736 | } |
| 16737 | p->mark = mark; |
| 16738 | } |
| 16739 | res = NULL; |
| 16740 | done: |
| 16741 | return res; |
| 16742 | } |
| 16743 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16744 | // _tmp_135: '.' | '...' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16745 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16746 | _tmp_135_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16747 | { |
| 16748 | if (p->error_indicator) { |
| 16749 | return NULL; |
| 16750 | } |
| 16751 | void * res = NULL; |
| 16752 | int mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16753 | { // '.' |
| 16754 | Token * literal; |
| 16755 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16756 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16757 | ) |
| 16758 | { |
| 16759 | res = literal; |
| 16760 | goto done; |
| 16761 | } |
| 16762 | p->mark = mark; |
| 16763 | } |
| 16764 | { // '...' |
| 16765 | Token * literal; |
| 16766 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16767 | (literal = _PyPegen_expect_token(p, 52)) // token='...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16768 | ) |
| 16769 | { |
| 16770 | res = literal; |
| 16771 | goto done; |
| 16772 | } |
| 16773 | p->mark = mark; |
| 16774 | } |
| 16775 | res = NULL; |
| 16776 | done: |
| 16777 | return res; |
| 16778 | } |
| 16779 | |
| 16780 | // _tmp_136: '.' | '...' |
| 16781 | static void * |
| 16782 | _tmp_136_rule(Parser *p) |
| 16783 | { |
| 16784 | if (p->error_indicator) { |
| 16785 | return NULL; |
| 16786 | } |
| 16787 | void * res = NULL; |
| 16788 | int mark = p->mark; |
| 16789 | { // '.' |
| 16790 | Token * literal; |
| 16791 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16792 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16793 | ) |
| 16794 | { |
| 16795 | res = literal; |
| 16796 | goto done; |
| 16797 | } |
| 16798 | p->mark = mark; |
| 16799 | } |
| 16800 | { // '...' |
| 16801 | Token * literal; |
| 16802 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16803 | (literal = _PyPegen_expect_token(p, 52)) // token='...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16804 | ) |
| 16805 | { |
| 16806 | res = literal; |
| 16807 | goto done; |
| 16808 | } |
| 16809 | p->mark = mark; |
| 16810 | } |
| 16811 | res = NULL; |
| 16812 | done: |
| 16813 | return res; |
| 16814 | } |
| 16815 | |
| 16816 | // _tmp_137: '@' named_expression NEWLINE |
| 16817 | static void * |
| 16818 | _tmp_137_rule(Parser *p) |
| 16819 | { |
| 16820 | if (p->error_indicator) { |
| 16821 | return NULL; |
| 16822 | } |
| 16823 | void * res = NULL; |
| 16824 | int mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16825 | { // '@' named_expression NEWLINE |
| 16826 | expr_ty f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16827 | Token * literal; |
| 16828 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16829 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16830 | (literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16831 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16832 | (f = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16833 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16834 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16835 | ) |
| 16836 | { |
| 16837 | res = f; |
| 16838 | if (res == NULL && PyErr_Occurred()) { |
| 16839 | p->error_indicator = 1; |
| 16840 | return NULL; |
| 16841 | } |
| 16842 | goto done; |
| 16843 | } |
| 16844 | p->mark = mark; |
| 16845 | } |
| 16846 | res = NULL; |
| 16847 | done: |
| 16848 | return res; |
| 16849 | } |
| 16850 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16851 | // _tmp_138: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16852 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16853 | _tmp_138_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16854 | { |
| 16855 | if (p->error_indicator) { |
| 16856 | return NULL; |
| 16857 | } |
| 16858 | void * res = NULL; |
| 16859 | int mark = p->mark; |
| 16860 | { // ',' star_expression |
| 16861 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16862 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16863 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16864 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16865 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16866 | (c = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16867 | ) |
| 16868 | { |
| 16869 | res = c; |
| 16870 | if (res == NULL && PyErr_Occurred()) { |
| 16871 | p->error_indicator = 1; |
| 16872 | return NULL; |
| 16873 | } |
| 16874 | goto done; |
| 16875 | } |
| 16876 | p->mark = mark; |
| 16877 | } |
| 16878 | res = NULL; |
| 16879 | done: |
| 16880 | return res; |
| 16881 | } |
| 16882 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16883 | // _tmp_139: ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16884 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16885 | _tmp_139_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16886 | { |
| 16887 | if (p->error_indicator) { |
| 16888 | return NULL; |
| 16889 | } |
| 16890 | void * res = NULL; |
| 16891 | int mark = p->mark; |
| 16892 | { // ',' expression |
| 16893 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16894 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16895 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16896 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16897 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16898 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16899 | ) |
| 16900 | { |
| 16901 | res = c; |
| 16902 | if (res == NULL && PyErr_Occurred()) { |
| 16903 | p->error_indicator = 1; |
| 16904 | return NULL; |
| 16905 | } |
| 16906 | goto done; |
| 16907 | } |
| 16908 | p->mark = mark; |
| 16909 | } |
| 16910 | res = NULL; |
| 16911 | done: |
| 16912 | return res; |
| 16913 | } |
| 16914 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16915 | // _tmp_140: 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16916 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16917 | _tmp_140_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16918 | { |
| 16919 | if (p->error_indicator) { |
| 16920 | return NULL; |
| 16921 | } |
| 16922 | void * res = NULL; |
| 16923 | int mark = p->mark; |
| 16924 | { // 'or' conjunction |
| 16925 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16926 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16927 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16928 | (keyword = _PyPegen_expect_token(p, 532)) // token='or' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16929 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16930 | (c = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16931 | ) |
| 16932 | { |
| 16933 | res = c; |
| 16934 | if (res == NULL && PyErr_Occurred()) { |
| 16935 | p->error_indicator = 1; |
| 16936 | return NULL; |
| 16937 | } |
| 16938 | goto done; |
| 16939 | } |
| 16940 | p->mark = mark; |
| 16941 | } |
| 16942 | res = NULL; |
| 16943 | done: |
| 16944 | return res; |
| 16945 | } |
| 16946 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16947 | // _tmp_141: 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16948 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16949 | _tmp_141_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16950 | { |
| 16951 | if (p->error_indicator) { |
| 16952 | return NULL; |
| 16953 | } |
| 16954 | void * res = NULL; |
| 16955 | int mark = p->mark; |
| 16956 | { // 'and' inversion |
| 16957 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16958 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16959 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16960 | (keyword = _PyPegen_expect_token(p, 533)) // token='and' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16961 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16962 | (c = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16963 | ) |
| 16964 | { |
| 16965 | res = c; |
| 16966 | if (res == NULL && PyErr_Occurred()) { |
| 16967 | p->error_indicator = 1; |
| 16968 | return NULL; |
| 16969 | } |
| 16970 | goto done; |
| 16971 | } |
| 16972 | p->mark = mark; |
| 16973 | } |
| 16974 | res = NULL; |
| 16975 | done: |
| 16976 | return res; |
| 16977 | } |
| 16978 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16979 | // _tmp_142: 'if' disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16980 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16981 | _tmp_142_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16982 | { |
| 16983 | if (p->error_indicator) { |
| 16984 | return NULL; |
| 16985 | } |
| 16986 | void * res = NULL; |
| 16987 | int mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16988 | { // 'if' disjunction |
| 16989 | Token * keyword; |
| 16990 | expr_ty z; |
| 16991 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16992 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16993 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 16994 | (z = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16995 | ) |
| 16996 | { |
| 16997 | res = z; |
| 16998 | if (res == NULL && PyErr_Occurred()) { |
| 16999 | p->error_indicator = 1; |
| 17000 | return NULL; |
| 17001 | } |
| 17002 | goto done; |
| 17003 | } |
| 17004 | p->mark = mark; |
| 17005 | } |
| 17006 | res = NULL; |
| 17007 | done: |
| 17008 | return res; |
| 17009 | } |
| 17010 | |
| 17011 | // _tmp_143: 'if' disjunction |
| 17012 | static void * |
| 17013 | _tmp_143_rule(Parser *p) |
| 17014 | { |
| 17015 | if (p->error_indicator) { |
| 17016 | return NULL; |
| 17017 | } |
| 17018 | void * res = NULL; |
| 17019 | int mark = p->mark; |
| 17020 | { // 'if' disjunction |
| 17021 | Token * keyword; |
| 17022 | expr_ty z; |
| 17023 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17024 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17025 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17026 | (z = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17027 | ) |
| 17028 | { |
| 17029 | res = z; |
| 17030 | if (res == NULL && PyErr_Occurred()) { |
| 17031 | p->error_indicator = 1; |
| 17032 | return NULL; |
| 17033 | } |
| 17034 | goto done; |
| 17035 | } |
| 17036 | p->mark = mark; |
| 17037 | } |
| 17038 | res = NULL; |
| 17039 | done: |
| 17040 | return res; |
| 17041 | } |
| 17042 | |
| 17043 | // _tmp_144: ',' star_target |
| 17044 | static void * |
| 17045 | _tmp_144_rule(Parser *p) |
| 17046 | { |
| 17047 | if (p->error_indicator) { |
| 17048 | return NULL; |
| 17049 | } |
| 17050 | void * res = NULL; |
| 17051 | int mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17052 | { // ',' star_target |
| 17053 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 17054 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17055 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17056 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17057 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17058 | (c = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17059 | ) |
| 17060 | { |
| 17061 | res = c; |
| 17062 | if (res == NULL && PyErr_Occurred()) { |
| 17063 | p->error_indicator = 1; |
| 17064 | return NULL; |
| 17065 | } |
| 17066 | goto done; |
| 17067 | } |
| 17068 | p->mark = mark; |
| 17069 | } |
| 17070 | res = NULL; |
| 17071 | done: |
| 17072 | return res; |
| 17073 | } |
| 17074 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17075 | // _loop1_145: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17076 | static asdl_seq * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17077 | _loop1_145_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17078 | { |
| 17079 | if (p->error_indicator) { |
| 17080 | return NULL; |
| 17081 | } |
| 17082 | void *res = NULL; |
| 17083 | int mark = p->mark; |
| 17084 | int start_mark = p->mark; |
| 17085 | void **children = PyMem_Malloc(sizeof(void *)); |
| 17086 | if (!children) { |
| 17087 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 17088 | return NULL; |
| 17089 | } |
| 17090 | ssize_t children_capacity = 1; |
| 17091 | ssize_t n = 0; |
| 17092 | { // param_with_default |
| 17093 | NameDefaultPair* param_with_default_var; |
| 17094 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17095 | (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] | 17096 | ) |
| 17097 | { |
| 17098 | res = param_with_default_var; |
| 17099 | if (n == children_capacity) { |
| 17100 | children_capacity *= 2; |
| 17101 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 17102 | if (!children) { |
| 17103 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 17104 | return NULL; |
| 17105 | } |
| 17106 | } |
| 17107 | children[n++] = res; |
| 17108 | mark = p->mark; |
| 17109 | } |
| 17110 | p->mark = mark; |
| 17111 | } |
| 17112 | if (n == 0) { |
| 17113 | PyMem_Free(children); |
| 17114 | return NULL; |
| 17115 | } |
| 17116 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 17117 | if (!seq) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17118 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_145"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17119 | PyMem_Free(children); |
| 17120 | return NULL; |
| 17121 | } |
| 17122 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 17123 | PyMem_Free(children); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17124 | _PyPegen_insert_memo(p, start_mark, _loop1_145_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17125 | return seq; |
| 17126 | } |
| 17127 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17128 | // _tmp_146: ')' | '**' |
| 17129 | static void * |
| 17130 | _tmp_146_rule(Parser *p) |
| 17131 | { |
| 17132 | if (p->error_indicator) { |
| 17133 | return NULL; |
| 17134 | } |
| 17135 | void * res = NULL; |
| 17136 | int mark = p->mark; |
| 17137 | { // ')' |
| 17138 | Token * literal; |
| 17139 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17140 | (literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17141 | ) |
| 17142 | { |
| 17143 | res = literal; |
| 17144 | goto done; |
| 17145 | } |
| 17146 | p->mark = mark; |
| 17147 | } |
| 17148 | { // '**' |
| 17149 | Token * literal; |
| 17150 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17151 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17152 | ) |
| 17153 | { |
| 17154 | res = literal; |
| 17155 | goto done; |
| 17156 | } |
| 17157 | p->mark = mark; |
| 17158 | } |
| 17159 | res = NULL; |
| 17160 | done: |
| 17161 | return res; |
| 17162 | } |
| 17163 | |
| 17164 | // _tmp_147: ':' | '**' |
| 17165 | static void * |
| 17166 | _tmp_147_rule(Parser *p) |
| 17167 | { |
| 17168 | if (p->error_indicator) { |
| 17169 | return NULL; |
| 17170 | } |
| 17171 | void * res = NULL; |
| 17172 | int mark = p->mark; |
| 17173 | { // ':' |
| 17174 | Token * literal; |
| 17175 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17176 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17177 | ) |
| 17178 | { |
| 17179 | res = literal; |
| 17180 | goto done; |
| 17181 | } |
| 17182 | p->mark = mark; |
| 17183 | } |
| 17184 | { // '**' |
| 17185 | Token * literal; |
| 17186 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame^] | 17187 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17188 | ) |
| 17189 | { |
| 17190 | res = literal; |
| 17191 | goto done; |
| 17192 | } |
| 17193 | p->mark = mark; |
| 17194 | } |
| 17195 | res = NULL; |
| 17196 | done: |
| 17197 | return res; |
| 17198 | } |
| 17199 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17200 | void * |
| 17201 | _PyPegen_parse(Parser *p) |
| 17202 | { |
| 17203 | // Initialize keywords |
| 17204 | p->keywords = reserved_keywords; |
| 17205 | p->n_keyword_lists = n_keyword_lists; |
| 17206 | |
| 17207 | // Run parser |
| 17208 | void *result = NULL; |
| 17209 | if (p->start_rule == Py_file_input) { |
| 17210 | result = file_rule(p); |
| 17211 | } else if (p->start_rule == Py_single_input) { |
| 17212 | result = interactive_rule(p); |
| 17213 | } else if (p->start_rule == Py_eval_input) { |
| 17214 | result = eval_rule(p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17215 | } else if (p->start_rule == Py_func_type_input) { |
| 17216 | result = func_type_rule(p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17217 | } else if (p->start_rule == Py_fstring_input) { |
| 17218 | result = fstring_rule(p); |
| 17219 | } |
| 17220 | |
| 17221 | return result; |
| 17222 | } |
| 17223 | |
| 17224 | // The end |