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 |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame^] | 213 | #define invalid_kwarg_type 1142 |
| 214 | #define invalid_named_expression_type 1143 |
| 215 | #define invalid_assignment_type 1144 |
| 216 | #define invalid_block_type 1145 |
| 217 | #define invalid_comprehension_type 1146 |
| 218 | #define invalid_parameters_type 1147 |
| 219 | #define invalid_star_etc_type 1148 |
| 220 | #define invalid_lambda_star_etc_type 1149 |
| 221 | #define invalid_double_type_comments_type 1150 |
| 222 | #define _loop0_1_type 1151 |
| 223 | #define _loop0_2_type 1152 |
| 224 | #define _loop0_4_type 1153 |
| 225 | #define _gather_3_type 1154 |
| 226 | #define _loop0_6_type 1155 |
| 227 | #define _gather_5_type 1156 |
| 228 | #define _loop0_8_type 1157 |
| 229 | #define _gather_7_type 1158 |
| 230 | #define _loop0_10_type 1159 |
| 231 | #define _gather_9_type 1160 |
| 232 | #define _loop1_11_type 1161 |
| 233 | #define _loop0_13_type 1162 |
| 234 | #define _gather_12_type 1163 |
| 235 | #define _tmp_14_type 1164 |
| 236 | #define _tmp_15_type 1165 |
| 237 | #define _tmp_16_type 1166 |
| 238 | #define _tmp_17_type 1167 |
| 239 | #define _tmp_18_type 1168 |
| 240 | #define _tmp_19_type 1169 |
| 241 | #define _tmp_20_type 1170 |
| 242 | #define _tmp_21_type 1171 |
| 243 | #define _loop1_22_type 1172 |
| 244 | #define _tmp_23_type 1173 |
| 245 | #define _tmp_24_type 1174 |
| 246 | #define _loop0_26_type 1175 |
| 247 | #define _gather_25_type 1176 |
| 248 | #define _loop0_28_type 1177 |
| 249 | #define _gather_27_type 1178 |
| 250 | #define _tmp_29_type 1179 |
| 251 | #define _loop0_30_type 1180 |
| 252 | #define _loop1_31_type 1181 |
| 253 | #define _loop0_33_type 1182 |
| 254 | #define _gather_32_type 1183 |
| 255 | #define _tmp_34_type 1184 |
| 256 | #define _loop0_36_type 1185 |
| 257 | #define _gather_35_type 1186 |
| 258 | #define _tmp_37_type 1187 |
| 259 | #define _loop0_39_type 1188 |
| 260 | #define _gather_38_type 1189 |
| 261 | #define _loop0_41_type 1190 |
| 262 | #define _gather_40_type 1191 |
| 263 | #define _loop0_43_type 1192 |
| 264 | #define _gather_42_type 1193 |
| 265 | #define _loop0_45_type 1194 |
| 266 | #define _gather_44_type 1195 |
| 267 | #define _tmp_46_type 1196 |
| 268 | #define _loop1_47_type 1197 |
| 269 | #define _tmp_48_type 1198 |
| 270 | #define _tmp_49_type 1199 |
| 271 | #define _tmp_50_type 1200 |
| 272 | #define _tmp_51_type 1201 |
| 273 | #define _tmp_52_type 1202 |
| 274 | #define _loop0_53_type 1203 |
| 275 | #define _loop0_54_type 1204 |
| 276 | #define _loop0_55_type 1205 |
| 277 | #define _loop1_56_type 1206 |
| 278 | #define _loop0_57_type 1207 |
| 279 | #define _loop1_58_type 1208 |
| 280 | #define _loop1_59_type 1209 |
| 281 | #define _loop1_60_type 1210 |
| 282 | #define _loop0_61_type 1211 |
| 283 | #define _loop1_62_type 1212 |
| 284 | #define _loop0_63_type 1213 |
| 285 | #define _loop1_64_type 1214 |
| 286 | #define _loop0_65_type 1215 |
| 287 | #define _loop1_66_type 1216 |
| 288 | #define _loop1_67_type 1217 |
| 289 | #define _tmp_68_type 1218 |
| 290 | #define _loop0_70_type 1219 |
| 291 | #define _gather_69_type 1220 |
| 292 | #define _loop1_71_type 1221 |
| 293 | #define _loop0_73_type 1222 |
| 294 | #define _gather_72_type 1223 |
| 295 | #define _loop1_74_type 1224 |
| 296 | #define _loop0_75_type 1225 |
| 297 | #define _loop0_76_type 1226 |
| 298 | #define _loop0_77_type 1227 |
| 299 | #define _loop1_78_type 1228 |
| 300 | #define _loop0_79_type 1229 |
| 301 | #define _loop1_80_type 1230 |
| 302 | #define _loop1_81_type 1231 |
| 303 | #define _loop1_82_type 1232 |
| 304 | #define _loop0_83_type 1233 |
| 305 | #define _loop1_84_type 1234 |
| 306 | #define _loop0_85_type 1235 |
| 307 | #define _loop1_86_type 1236 |
| 308 | #define _loop0_87_type 1237 |
| 309 | #define _loop1_88_type 1238 |
| 310 | #define _loop1_89_type 1239 |
| 311 | #define _loop1_90_type 1240 |
| 312 | #define _loop1_91_type 1241 |
| 313 | #define _tmp_92_type 1242 |
| 314 | #define _loop0_94_type 1243 |
| 315 | #define _gather_93_type 1244 |
| 316 | #define _tmp_95_type 1245 |
| 317 | #define _tmp_96_type 1246 |
| 318 | #define _tmp_97_type 1247 |
| 319 | #define _tmp_98_type 1248 |
| 320 | #define _loop1_99_type 1249 |
| 321 | #define _tmp_100_type 1250 |
| 322 | #define _tmp_101_type 1251 |
| 323 | #define _loop0_103_type 1252 |
| 324 | #define _gather_102_type 1253 |
| 325 | #define _loop1_104_type 1254 |
| 326 | #define _loop0_105_type 1255 |
| 327 | #define _loop0_106_type 1256 |
| 328 | #define _tmp_107_type 1257 |
| 329 | #define _tmp_108_type 1258 |
| 330 | #define _loop0_110_type 1259 |
| 331 | #define _gather_109_type 1260 |
| 332 | #define _loop0_112_type 1261 |
| 333 | #define _gather_111_type 1262 |
| 334 | #define _loop0_114_type 1263 |
| 335 | #define _gather_113_type 1264 |
| 336 | #define _loop0_116_type 1265 |
| 337 | #define _gather_115_type 1266 |
| 338 | #define _loop0_117_type 1267 |
| 339 | #define _loop0_119_type 1268 |
| 340 | #define _gather_118_type 1269 |
| 341 | #define _tmp_120_type 1270 |
| 342 | #define _loop0_122_type 1271 |
| 343 | #define _gather_121_type 1272 |
| 344 | #define _loop0_124_type 1273 |
| 345 | #define _gather_123_type 1274 |
| 346 | #define _tmp_125_type 1275 |
| 347 | #define _tmp_126_type 1276 |
| 348 | #define _tmp_127_type 1277 |
| 349 | #define _tmp_128_type 1278 |
| 350 | #define _tmp_129_type 1279 |
| 351 | #define _loop0_130_type 1280 |
| 352 | #define _tmp_131_type 1281 |
| 353 | #define _tmp_132_type 1282 |
| 354 | #define _tmp_133_type 1283 |
| 355 | #define _tmp_134_type 1284 |
| 356 | #define _tmp_135_type 1285 |
| 357 | #define _tmp_136_type 1286 |
| 358 | #define _tmp_137_type 1287 |
| 359 | #define _tmp_138_type 1288 |
| 360 | #define _tmp_139_type 1289 |
| 361 | #define _tmp_140_type 1290 |
| 362 | #define _tmp_141_type 1291 |
| 363 | #define _tmp_142_type 1292 |
| 364 | #define _tmp_143_type 1293 |
| 365 | #define _tmp_144_type 1294 |
| 366 | #define _loop1_145_type 1295 |
| 367 | #define _tmp_146_type 1296 |
| 368 | #define _tmp_147_type 1297 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 369 | |
| 370 | static mod_ty file_rule(Parser *p); |
| 371 | static mod_ty interactive_rule(Parser *p); |
| 372 | static mod_ty eval_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 373 | static mod_ty func_type_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 374 | static expr_ty fstring_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 375 | static asdl_seq* type_expressions_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 376 | static asdl_seq* statements_rule(Parser *p); |
| 377 | static asdl_seq* statement_rule(Parser *p); |
| 378 | static asdl_seq* statement_newline_rule(Parser *p); |
| 379 | static asdl_seq* simple_stmt_rule(Parser *p); |
| 380 | static stmt_ty small_stmt_rule(Parser *p); |
| 381 | static stmt_ty compound_stmt_rule(Parser *p); |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 382 | static stmt_ty assignment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 383 | static AugOperator* augassign_rule(Parser *p); |
| 384 | static stmt_ty global_stmt_rule(Parser *p); |
| 385 | static stmt_ty nonlocal_stmt_rule(Parser *p); |
| 386 | static stmt_ty yield_stmt_rule(Parser *p); |
| 387 | static stmt_ty assert_stmt_rule(Parser *p); |
| 388 | static stmt_ty del_stmt_rule(Parser *p); |
| 389 | static stmt_ty import_stmt_rule(Parser *p); |
| 390 | static stmt_ty import_name_rule(Parser *p); |
| 391 | static stmt_ty import_from_rule(Parser *p); |
| 392 | static asdl_seq* import_from_targets_rule(Parser *p); |
| 393 | static asdl_seq* import_from_as_names_rule(Parser *p); |
| 394 | static alias_ty import_from_as_name_rule(Parser *p); |
| 395 | static asdl_seq* dotted_as_names_rule(Parser *p); |
| 396 | static alias_ty dotted_as_name_rule(Parser *p); |
| 397 | static expr_ty dotted_name_rule(Parser *p); |
| 398 | static stmt_ty if_stmt_rule(Parser *p); |
| 399 | static stmt_ty elif_stmt_rule(Parser *p); |
| 400 | static asdl_seq* else_block_rule(Parser *p); |
| 401 | static stmt_ty while_stmt_rule(Parser *p); |
| 402 | static stmt_ty for_stmt_rule(Parser *p); |
| 403 | static stmt_ty with_stmt_rule(Parser *p); |
| 404 | static withitem_ty with_item_rule(Parser *p); |
| 405 | static stmt_ty try_stmt_rule(Parser *p); |
| 406 | static excepthandler_ty except_block_rule(Parser *p); |
| 407 | static asdl_seq* finally_block_rule(Parser *p); |
| 408 | static stmt_ty return_stmt_rule(Parser *p); |
| 409 | static stmt_ty raise_stmt_rule(Parser *p); |
| 410 | static stmt_ty function_def_rule(Parser *p); |
| 411 | static stmt_ty function_def_raw_rule(Parser *p); |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 412 | static Token* func_type_comment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 413 | static arguments_ty params_rule(Parser *p); |
| 414 | static arguments_ty parameters_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 415 | static asdl_seq* slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 416 | static SlashWithDefault* slash_with_default_rule(Parser *p); |
| 417 | static StarEtc* star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 418 | static arg_ty kwds_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 419 | static arg_ty param_no_default_rule(Parser *p); |
| 420 | static NameDefaultPair* param_with_default_rule(Parser *p); |
| 421 | static NameDefaultPair* param_maybe_default_rule(Parser *p); |
| 422 | static arg_ty param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 423 | static expr_ty annotation_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 424 | static expr_ty default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 425 | static asdl_seq* decorators_rule(Parser *p); |
| 426 | static stmt_ty class_def_rule(Parser *p); |
| 427 | static stmt_ty class_def_raw_rule(Parser *p); |
| 428 | static asdl_seq* block_rule(Parser *p); |
| 429 | static asdl_seq* expressions_list_rule(Parser *p); |
| 430 | static expr_ty star_expressions_rule(Parser *p); |
| 431 | static expr_ty star_expression_rule(Parser *p); |
| 432 | static asdl_seq* star_named_expressions_rule(Parser *p); |
| 433 | static expr_ty star_named_expression_rule(Parser *p); |
| 434 | static expr_ty named_expression_rule(Parser *p); |
| 435 | static expr_ty annotated_rhs_rule(Parser *p); |
| 436 | static expr_ty expressions_rule(Parser *p); |
| 437 | static expr_ty expression_rule(Parser *p); |
| 438 | static expr_ty lambdef_rule(Parser *p); |
| 439 | static arguments_ty lambda_parameters_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 440 | static asdl_seq* lambda_slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 441 | static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); |
| 442 | static StarEtc* lambda_star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 443 | static arg_ty lambda_kwds_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 444 | static arg_ty lambda_param_no_default_rule(Parser *p); |
| 445 | static NameDefaultPair* lambda_param_with_default_rule(Parser *p); |
| 446 | static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); |
| 447 | static arg_ty lambda_param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 448 | static expr_ty disjunction_rule(Parser *p); |
| 449 | static expr_ty conjunction_rule(Parser *p); |
| 450 | static expr_ty inversion_rule(Parser *p); |
| 451 | static expr_ty comparison_rule(Parser *p); |
| 452 | static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); |
| 453 | static CmpopExprPair* eq_bitwise_or_rule(Parser *p); |
| 454 | static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); |
| 455 | static CmpopExprPair* lte_bitwise_or_rule(Parser *p); |
| 456 | static CmpopExprPair* lt_bitwise_or_rule(Parser *p); |
| 457 | static CmpopExprPair* gte_bitwise_or_rule(Parser *p); |
| 458 | static CmpopExprPair* gt_bitwise_or_rule(Parser *p); |
| 459 | static CmpopExprPair* notin_bitwise_or_rule(Parser *p); |
| 460 | static CmpopExprPair* in_bitwise_or_rule(Parser *p); |
| 461 | static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); |
| 462 | static CmpopExprPair* is_bitwise_or_rule(Parser *p); |
| 463 | static expr_ty bitwise_or_rule(Parser *p); |
| 464 | static expr_ty bitwise_xor_rule(Parser *p); |
| 465 | static expr_ty bitwise_and_rule(Parser *p); |
| 466 | static expr_ty shift_expr_rule(Parser *p); |
| 467 | static expr_ty sum_rule(Parser *p); |
| 468 | static expr_ty term_rule(Parser *p); |
| 469 | static expr_ty factor_rule(Parser *p); |
| 470 | static expr_ty power_rule(Parser *p); |
| 471 | static expr_ty await_primary_rule(Parser *p); |
| 472 | static expr_ty primary_rule(Parser *p); |
| 473 | static expr_ty slices_rule(Parser *p); |
| 474 | static expr_ty slice_rule(Parser *p); |
| 475 | static expr_ty atom_rule(Parser *p); |
| 476 | static expr_ty strings_rule(Parser *p); |
| 477 | static expr_ty list_rule(Parser *p); |
| 478 | static expr_ty listcomp_rule(Parser *p); |
| 479 | static expr_ty tuple_rule(Parser *p); |
| 480 | static expr_ty group_rule(Parser *p); |
| 481 | static expr_ty genexp_rule(Parser *p); |
| 482 | static expr_ty set_rule(Parser *p); |
| 483 | static expr_ty setcomp_rule(Parser *p); |
| 484 | static expr_ty dict_rule(Parser *p); |
| 485 | static expr_ty dictcomp_rule(Parser *p); |
| 486 | static asdl_seq* kvpairs_rule(Parser *p); |
| 487 | static KeyValuePair* kvpair_rule(Parser *p); |
| 488 | static asdl_seq* for_if_clauses_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 489 | static comprehension_ty for_if_clause_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 490 | static expr_ty yield_expr_rule(Parser *p); |
| 491 | static expr_ty arguments_rule(Parser *p); |
| 492 | static expr_ty args_rule(Parser *p); |
| 493 | static asdl_seq* kwargs_rule(Parser *p); |
| 494 | static expr_ty starred_expression_rule(Parser *p); |
| 495 | static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); |
| 496 | static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); |
| 497 | static expr_ty star_targets_rule(Parser *p); |
| 498 | static asdl_seq* star_targets_seq_rule(Parser *p); |
| 499 | static expr_ty star_target_rule(Parser *p); |
| 500 | static expr_ty star_atom_rule(Parser *p); |
| 501 | static expr_ty inside_paren_ann_assign_target_rule(Parser *p); |
| 502 | static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p); |
| 503 | static asdl_seq* del_targets_rule(Parser *p); |
| 504 | static expr_ty del_target_rule(Parser *p); |
| 505 | static expr_ty del_t_atom_rule(Parser *p); |
| 506 | static asdl_seq* targets_rule(Parser *p); |
| 507 | static expr_ty target_rule(Parser *p); |
| 508 | static expr_ty t_primary_rule(Parser *p); |
| 509 | static void *t_lookahead_rule(Parser *p); |
| 510 | static expr_ty t_atom_rule(Parser *p); |
| 511 | static void *incorrect_arguments_rule(Parser *p); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame^] | 512 | static void *invalid_kwarg_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 513 | static void *invalid_named_expression_rule(Parser *p); |
| 514 | static void *invalid_assignment_rule(Parser *p); |
| 515 | static void *invalid_block_rule(Parser *p); |
| 516 | static void *invalid_comprehension_rule(Parser *p); |
| 517 | static void *invalid_parameters_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 518 | static void *invalid_star_etc_rule(Parser *p); |
| 519 | static void *invalid_lambda_star_etc_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 520 | static void *invalid_double_type_comments_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 521 | static asdl_seq *_loop0_1_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 522 | static asdl_seq *_loop0_2_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 523 | static asdl_seq *_loop0_4_rule(Parser *p); |
| 524 | static asdl_seq *_gather_3_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 525 | static asdl_seq *_loop0_6_rule(Parser *p); |
| 526 | static asdl_seq *_gather_5_rule(Parser *p); |
| 527 | static asdl_seq *_loop0_8_rule(Parser *p); |
| 528 | static asdl_seq *_gather_7_rule(Parser *p); |
| 529 | static asdl_seq *_loop0_10_rule(Parser *p); |
| 530 | static asdl_seq *_gather_9_rule(Parser *p); |
| 531 | static asdl_seq *_loop1_11_rule(Parser *p); |
| 532 | static asdl_seq *_loop0_13_rule(Parser *p); |
| 533 | static asdl_seq *_gather_12_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 534 | static void *_tmp_14_rule(Parser *p); |
| 535 | static void *_tmp_15_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 536 | static void *_tmp_16_rule(Parser *p); |
| 537 | static void *_tmp_17_rule(Parser *p); |
| 538 | static void *_tmp_18_rule(Parser *p); |
| 539 | static void *_tmp_19_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 540 | static void *_tmp_20_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 541 | static void *_tmp_21_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 542 | static asdl_seq *_loop1_22_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 543 | static void *_tmp_23_rule(Parser *p); |
| 544 | static void *_tmp_24_rule(Parser *p); |
| 545 | static asdl_seq *_loop0_26_rule(Parser *p); |
| 546 | static asdl_seq *_gather_25_rule(Parser *p); |
| 547 | static asdl_seq *_loop0_28_rule(Parser *p); |
| 548 | static asdl_seq *_gather_27_rule(Parser *p); |
| 549 | static void *_tmp_29_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 550 | static asdl_seq *_loop0_30_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 551 | static asdl_seq *_loop1_31_rule(Parser *p); |
| 552 | static asdl_seq *_loop0_33_rule(Parser *p); |
| 553 | static asdl_seq *_gather_32_rule(Parser *p); |
| 554 | static void *_tmp_34_rule(Parser *p); |
| 555 | static asdl_seq *_loop0_36_rule(Parser *p); |
| 556 | static asdl_seq *_gather_35_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 557 | static void *_tmp_37_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 558 | static asdl_seq *_loop0_39_rule(Parser *p); |
| 559 | static asdl_seq *_gather_38_rule(Parser *p); |
| 560 | static asdl_seq *_loop0_41_rule(Parser *p); |
| 561 | static asdl_seq *_gather_40_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 562 | static asdl_seq *_loop0_43_rule(Parser *p); |
| 563 | static asdl_seq *_gather_42_rule(Parser *p); |
| 564 | static asdl_seq *_loop0_45_rule(Parser *p); |
| 565 | static asdl_seq *_gather_44_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 566 | static void *_tmp_46_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 567 | static asdl_seq *_loop1_47_rule(Parser *p); |
| 568 | static void *_tmp_48_rule(Parser *p); |
| 569 | static void *_tmp_49_rule(Parser *p); |
| 570 | static void *_tmp_50_rule(Parser *p); |
| 571 | static void *_tmp_51_rule(Parser *p); |
| 572 | static void *_tmp_52_rule(Parser *p); |
| 573 | static asdl_seq *_loop0_53_rule(Parser *p); |
| 574 | static asdl_seq *_loop0_54_rule(Parser *p); |
| 575 | static asdl_seq *_loop0_55_rule(Parser *p); |
| 576 | static asdl_seq *_loop1_56_rule(Parser *p); |
| 577 | static asdl_seq *_loop0_57_rule(Parser *p); |
| 578 | static asdl_seq *_loop1_58_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 579 | static asdl_seq *_loop1_59_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 580 | static asdl_seq *_loop1_60_rule(Parser *p); |
| 581 | static asdl_seq *_loop0_61_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 582 | static asdl_seq *_loop1_62_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 583 | static asdl_seq *_loop0_63_rule(Parser *p); |
| 584 | static asdl_seq *_loop1_64_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 585 | static asdl_seq *_loop0_65_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 586 | static asdl_seq *_loop1_66_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 587 | static asdl_seq *_loop1_67_rule(Parser *p); |
| 588 | static void *_tmp_68_rule(Parser *p); |
| 589 | static asdl_seq *_loop0_70_rule(Parser *p); |
| 590 | static asdl_seq *_gather_69_rule(Parser *p); |
| 591 | static asdl_seq *_loop1_71_rule(Parser *p); |
| 592 | static asdl_seq *_loop0_73_rule(Parser *p); |
| 593 | static asdl_seq *_gather_72_rule(Parser *p); |
| 594 | static asdl_seq *_loop1_74_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 595 | static asdl_seq *_loop0_75_rule(Parser *p); |
| 596 | static asdl_seq *_loop0_76_rule(Parser *p); |
| 597 | static asdl_seq *_loop0_77_rule(Parser *p); |
| 598 | static asdl_seq *_loop1_78_rule(Parser *p); |
| 599 | static asdl_seq *_loop0_79_rule(Parser *p); |
| 600 | static asdl_seq *_loop1_80_rule(Parser *p); |
| 601 | static asdl_seq *_loop1_81_rule(Parser *p); |
| 602 | static asdl_seq *_loop1_82_rule(Parser *p); |
| 603 | static asdl_seq *_loop0_83_rule(Parser *p); |
| 604 | static asdl_seq *_loop1_84_rule(Parser *p); |
| 605 | static asdl_seq *_loop0_85_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 606 | static asdl_seq *_loop1_86_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 607 | static asdl_seq *_loop0_87_rule(Parser *p); |
| 608 | static asdl_seq *_loop1_88_rule(Parser *p); |
| 609 | static asdl_seq *_loop1_89_rule(Parser *p); |
| 610 | static asdl_seq *_loop1_90_rule(Parser *p); |
| 611 | static asdl_seq *_loop1_91_rule(Parser *p); |
| 612 | static void *_tmp_92_rule(Parser *p); |
| 613 | static asdl_seq *_loop0_94_rule(Parser *p); |
| 614 | static asdl_seq *_gather_93_rule(Parser *p); |
| 615 | static void *_tmp_95_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 616 | static void *_tmp_96_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 617 | static void *_tmp_97_rule(Parser *p); |
| 618 | static void *_tmp_98_rule(Parser *p); |
| 619 | static asdl_seq *_loop1_99_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 620 | static void *_tmp_100_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 621 | static void *_tmp_101_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 622 | static asdl_seq *_loop0_103_rule(Parser *p); |
| 623 | static asdl_seq *_gather_102_rule(Parser *p); |
| 624 | static asdl_seq *_loop1_104_rule(Parser *p); |
| 625 | static asdl_seq *_loop0_105_rule(Parser *p); |
| 626 | static asdl_seq *_loop0_106_rule(Parser *p); |
| 627 | static void *_tmp_107_rule(Parser *p); |
| 628 | static void *_tmp_108_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 629 | static asdl_seq *_loop0_110_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 630 | static asdl_seq *_gather_109_rule(Parser *p); |
| 631 | static asdl_seq *_loop0_112_rule(Parser *p); |
| 632 | static asdl_seq *_gather_111_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 633 | static asdl_seq *_loop0_114_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 634 | static asdl_seq *_gather_113_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 635 | static asdl_seq *_loop0_116_rule(Parser *p); |
| 636 | static asdl_seq *_gather_115_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 637 | static asdl_seq *_loop0_117_rule(Parser *p); |
| 638 | static asdl_seq *_loop0_119_rule(Parser *p); |
| 639 | static asdl_seq *_gather_118_rule(Parser *p); |
| 640 | static void *_tmp_120_rule(Parser *p); |
| 641 | static asdl_seq *_loop0_122_rule(Parser *p); |
| 642 | static asdl_seq *_gather_121_rule(Parser *p); |
| 643 | static asdl_seq *_loop0_124_rule(Parser *p); |
| 644 | static asdl_seq *_gather_123_rule(Parser *p); |
| 645 | static void *_tmp_125_rule(Parser *p); |
| 646 | static void *_tmp_126_rule(Parser *p); |
| 647 | static void *_tmp_127_rule(Parser *p); |
| 648 | static void *_tmp_128_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 649 | static void *_tmp_129_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 650 | static asdl_seq *_loop0_130_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 651 | static void *_tmp_131_rule(Parser *p); |
| 652 | static void *_tmp_132_rule(Parser *p); |
| 653 | static void *_tmp_133_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 654 | static void *_tmp_134_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 655 | static void *_tmp_135_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 656 | static void *_tmp_136_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 657 | static void *_tmp_137_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 658 | static void *_tmp_138_rule(Parser *p); |
| 659 | static void *_tmp_139_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 660 | static void *_tmp_140_rule(Parser *p); |
| 661 | static void *_tmp_141_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 662 | static void *_tmp_142_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 663 | static void *_tmp_143_rule(Parser *p); |
| 664 | static void *_tmp_144_rule(Parser *p); |
| 665 | static asdl_seq *_loop1_145_rule(Parser *p); |
| 666 | static void *_tmp_146_rule(Parser *p); |
| 667 | static void *_tmp_147_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 668 | |
| 669 | |
| 670 | // file: statements? $ |
| 671 | static mod_ty |
| 672 | file_rule(Parser *p) |
| 673 | { |
| 674 | if (p->error_indicator) { |
| 675 | return NULL; |
| 676 | } |
| 677 | mod_ty res = NULL; |
| 678 | int mark = p->mark; |
| 679 | { // statements? $ |
| 680 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 681 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 682 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 683 | (a = statements_rule(p), 1) // statements? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 684 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 685 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 686 | ) |
| 687 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 688 | res = _PyPegen_make_module ( p , a ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 689 | if (res == NULL && PyErr_Occurred()) { |
| 690 | p->error_indicator = 1; |
| 691 | return NULL; |
| 692 | } |
| 693 | goto done; |
| 694 | } |
| 695 | p->mark = mark; |
| 696 | } |
| 697 | res = NULL; |
| 698 | done: |
| 699 | return res; |
| 700 | } |
| 701 | |
| 702 | // interactive: statement_newline |
| 703 | static mod_ty |
| 704 | interactive_rule(Parser *p) |
| 705 | { |
| 706 | if (p->error_indicator) { |
| 707 | return NULL; |
| 708 | } |
| 709 | mod_ty res = NULL; |
| 710 | int mark = p->mark; |
| 711 | { // statement_newline |
| 712 | asdl_seq* a; |
| 713 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 714 | (a = statement_newline_rule(p)) // statement_newline |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 715 | ) |
| 716 | { |
| 717 | res = Interactive ( a , p -> arena ); |
| 718 | if (res == NULL && PyErr_Occurred()) { |
| 719 | p->error_indicator = 1; |
| 720 | return NULL; |
| 721 | } |
| 722 | goto done; |
| 723 | } |
| 724 | p->mark = mark; |
| 725 | } |
| 726 | res = NULL; |
| 727 | done: |
| 728 | return res; |
| 729 | } |
| 730 | |
| 731 | // eval: expressions NEWLINE* $ |
| 732 | static mod_ty |
| 733 | eval_rule(Parser *p) |
| 734 | { |
| 735 | if (p->error_indicator) { |
| 736 | return NULL; |
| 737 | } |
| 738 | mod_ty res = NULL; |
| 739 | int mark = p->mark; |
| 740 | { // expressions NEWLINE* $ |
| 741 | asdl_seq * _loop0_1_var; |
| 742 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 743 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 744 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 745 | (a = expressions_rule(p)) // expressions |
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 | (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 748 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 749 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 750 | ) |
| 751 | { |
| 752 | res = Expression ( a , p -> arena ); |
| 753 | if (res == NULL && PyErr_Occurred()) { |
| 754 | p->error_indicator = 1; |
| 755 | return NULL; |
| 756 | } |
| 757 | goto done; |
| 758 | } |
| 759 | p->mark = mark; |
| 760 | } |
| 761 | res = NULL; |
| 762 | done: |
| 763 | return res; |
| 764 | } |
| 765 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 766 | // func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 767 | static mod_ty |
| 768 | func_type_rule(Parser *p) |
| 769 | { |
| 770 | if (p->error_indicator) { |
| 771 | return NULL; |
| 772 | } |
| 773 | mod_ty res = NULL; |
| 774 | int mark = p->mark; |
| 775 | { // '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 776 | asdl_seq * _loop0_2_var; |
| 777 | void *a; |
| 778 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 779 | Token * endmarker_var; |
| 780 | Token * literal; |
| 781 | Token * literal_1; |
| 782 | Token * literal_2; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 783 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 784 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (a = type_expressions_rule(p), 1) // type_expressions? |
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_1 = _PyPegen_expect_token(p, 8)) // 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 | (literal_2 = _PyPegen_expect_token(p, 51)) // token='->' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 791 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 792 | (b = expression_rule(p)) // expression |
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 | (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 795 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 796 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 797 | ) |
| 798 | { |
| 799 | res = FunctionType ( a , b , p -> arena ); |
| 800 | if (res == NULL && PyErr_Occurred()) { |
| 801 | p->error_indicator = 1; |
| 802 | return NULL; |
| 803 | } |
| 804 | goto done; |
| 805 | } |
| 806 | p->mark = mark; |
| 807 | } |
| 808 | res = NULL; |
| 809 | done: |
| 810 | return res; |
| 811 | } |
| 812 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 813 | // fstring: star_expressions |
| 814 | static expr_ty |
| 815 | fstring_rule(Parser *p) |
| 816 | { |
| 817 | if (p->error_indicator) { |
| 818 | return NULL; |
| 819 | } |
| 820 | expr_ty res = NULL; |
| 821 | int mark = p->mark; |
| 822 | { // star_expressions |
| 823 | expr_ty star_expressions_var; |
| 824 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 825 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 826 | ) |
| 827 | { |
| 828 | res = star_expressions_var; |
| 829 | goto done; |
| 830 | } |
| 831 | p->mark = mark; |
| 832 | } |
| 833 | res = NULL; |
| 834 | done: |
| 835 | return res; |
| 836 | } |
| 837 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 838 | // type_expressions: |
| 839 | // | ','.expression+ ',' '*' expression ',' '**' expression |
| 840 | // | ','.expression+ ',' '*' expression |
| 841 | // | ','.expression+ ',' '**' expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 842 | // | '*' expression ',' '**' expression |
| 843 | // | '*' expression |
| 844 | // | '**' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 845 | // | ','.expression+ |
| 846 | static asdl_seq* |
| 847 | type_expressions_rule(Parser *p) |
| 848 | { |
| 849 | if (p->error_indicator) { |
| 850 | return NULL; |
| 851 | } |
| 852 | asdl_seq* res = NULL; |
| 853 | int mark = p->mark; |
| 854 | { // ','.expression+ ',' '*' expression ',' '**' expression |
| 855 | asdl_seq * a; |
| 856 | expr_ty b; |
| 857 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 858 | Token * literal; |
| 859 | Token * literal_1; |
| 860 | Token * literal_2; |
| 861 | Token * literal_3; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 862 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 863 | (a = _gather_3_rule(p)) // ','.expression+ |
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 = _PyPegen_expect_token(p, 12)) // 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 | (literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
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 | (b = expression_rule(p)) // expression |
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_2 = _PyPegen_expect_token(p, 12)) // 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 | (literal_3 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 874 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 875 | (c = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 876 | ) |
| 877 | { |
| 878 | res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); |
| 879 | if (res == NULL && PyErr_Occurred()) { |
| 880 | p->error_indicator = 1; |
| 881 | return NULL; |
| 882 | } |
| 883 | goto done; |
| 884 | } |
| 885 | p->mark = mark; |
| 886 | } |
| 887 | { // ','.expression+ ',' '*' expression |
| 888 | asdl_seq * a; |
| 889 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 890 | Token * literal; |
| 891 | Token * literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 892 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 893 | (a = _gather_5_rule(p)) // ','.expression+ |
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 = _PyPegen_expect_token(p, 12)) // 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 | (literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 898 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 899 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 900 | ) |
| 901 | { |
| 902 | res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 903 | if (res == NULL && PyErr_Occurred()) { |
| 904 | p->error_indicator = 1; |
| 905 | return NULL; |
| 906 | } |
| 907 | goto done; |
| 908 | } |
| 909 | p->mark = mark; |
| 910 | } |
| 911 | { // ','.expression+ ',' '**' expression |
| 912 | asdl_seq * a; |
| 913 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 914 | Token * literal; |
| 915 | Token * literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 916 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 917 | (a = _gather_7_rule(p)) // ','.expression+ |
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 = _PyPegen_expect_token(p, 12)) // 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 | (literal_1 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 922 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 923 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 924 | ) |
| 925 | { |
| 926 | res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 927 | if (res == NULL && PyErr_Occurred()) { |
| 928 | p->error_indicator = 1; |
| 929 | return NULL; |
| 930 | } |
| 931 | goto done; |
| 932 | } |
| 933 | p->mark = mark; |
| 934 | } |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 935 | { // '*' expression ',' '**' expression |
| 936 | expr_ty a; |
| 937 | expr_ty b; |
| 938 | Token * literal; |
| 939 | Token * literal_1; |
| 940 | Token * literal_2; |
| 941 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 942 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
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 | (a = expression_rule(p)) // expression |
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_1 = _PyPegen_expect_token(p, 12)) // 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 | (literal_2 = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 949 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 950 | (b = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 951 | ) |
| 952 | { |
| 953 | res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b ); |
| 954 | if (res == NULL && PyErr_Occurred()) { |
| 955 | p->error_indicator = 1; |
| 956 | return NULL; |
| 957 | } |
| 958 | goto done; |
| 959 | } |
| 960 | p->mark = mark; |
| 961 | } |
| 962 | { // '*' expression |
| 963 | expr_ty a; |
| 964 | Token * literal; |
| 965 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 966 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 967 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 968 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 969 | ) |
| 970 | { |
| 971 | res = _PyPegen_singleton_seq ( p , a ); |
| 972 | if (res == NULL && PyErr_Occurred()) { |
| 973 | p->error_indicator = 1; |
| 974 | return NULL; |
| 975 | } |
| 976 | goto done; |
| 977 | } |
| 978 | p->mark = mark; |
| 979 | } |
| 980 | { // '**' expression |
| 981 | expr_ty a; |
| 982 | Token * literal; |
| 983 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 984 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 985 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 986 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 987 | ) |
| 988 | { |
| 989 | res = _PyPegen_singleton_seq ( p , a ); |
| 990 | if (res == NULL && PyErr_Occurred()) { |
| 991 | p->error_indicator = 1; |
| 992 | return NULL; |
| 993 | } |
| 994 | goto done; |
| 995 | } |
| 996 | p->mark = mark; |
| 997 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 998 | { // ','.expression+ |
| 999 | asdl_seq * _gather_9_var; |
| 1000 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1001 | (_gather_9_var = _gather_9_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1002 | ) |
| 1003 | { |
| 1004 | res = _gather_9_var; |
| 1005 | goto done; |
| 1006 | } |
| 1007 | p->mark = mark; |
| 1008 | } |
| 1009 | res = NULL; |
| 1010 | done: |
| 1011 | return res; |
| 1012 | } |
| 1013 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1014 | // statements: statement+ |
| 1015 | static asdl_seq* |
| 1016 | statements_rule(Parser *p) |
| 1017 | { |
| 1018 | if (p->error_indicator) { |
| 1019 | return NULL; |
| 1020 | } |
| 1021 | asdl_seq* res = NULL; |
| 1022 | int mark = p->mark; |
| 1023 | { // statement+ |
| 1024 | asdl_seq * a; |
| 1025 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1026 | (a = _loop1_11_rule(p)) // statement+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1027 | ) |
| 1028 | { |
| 1029 | res = _PyPegen_seq_flatten ( p , a ); |
| 1030 | if (res == NULL && PyErr_Occurred()) { |
| 1031 | p->error_indicator = 1; |
| 1032 | return NULL; |
| 1033 | } |
| 1034 | goto done; |
| 1035 | } |
| 1036 | p->mark = mark; |
| 1037 | } |
| 1038 | res = NULL; |
| 1039 | done: |
| 1040 | return res; |
| 1041 | } |
| 1042 | |
| 1043 | // statement: compound_stmt | simple_stmt |
| 1044 | static asdl_seq* |
| 1045 | statement_rule(Parser *p) |
| 1046 | { |
| 1047 | if (p->error_indicator) { |
| 1048 | return NULL; |
| 1049 | } |
| 1050 | asdl_seq* res = NULL; |
| 1051 | int mark = p->mark; |
| 1052 | { // compound_stmt |
| 1053 | stmt_ty a; |
| 1054 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1055 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1056 | ) |
| 1057 | { |
| 1058 | res = _PyPegen_singleton_seq ( p , a ); |
| 1059 | if (res == NULL && PyErr_Occurred()) { |
| 1060 | p->error_indicator = 1; |
| 1061 | return NULL; |
| 1062 | } |
| 1063 | goto done; |
| 1064 | } |
| 1065 | p->mark = mark; |
| 1066 | } |
| 1067 | { // simple_stmt |
| 1068 | asdl_seq* simple_stmt_var; |
| 1069 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1070 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1071 | ) |
| 1072 | { |
| 1073 | res = simple_stmt_var; |
| 1074 | goto done; |
| 1075 | } |
| 1076 | p->mark = mark; |
| 1077 | } |
| 1078 | res = NULL; |
| 1079 | done: |
| 1080 | return res; |
| 1081 | } |
| 1082 | |
| 1083 | // statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $ |
| 1084 | static asdl_seq* |
| 1085 | statement_newline_rule(Parser *p) |
| 1086 | { |
| 1087 | if (p->error_indicator) { |
| 1088 | return NULL; |
| 1089 | } |
| 1090 | asdl_seq* res = NULL; |
| 1091 | int mark = p->mark; |
| 1092 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1093 | p->error_indicator = 1; |
| 1094 | return NULL; |
| 1095 | } |
| 1096 | int start_lineno = p->tokens[mark]->lineno; |
| 1097 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1098 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1099 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1100 | { // compound_stmt NEWLINE |
| 1101 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1102 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1103 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1104 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1105 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1106 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1107 | ) |
| 1108 | { |
| 1109 | res = _PyPegen_singleton_seq ( p , a ); |
| 1110 | if (res == NULL && PyErr_Occurred()) { |
| 1111 | p->error_indicator = 1; |
| 1112 | return NULL; |
| 1113 | } |
| 1114 | goto done; |
| 1115 | } |
| 1116 | p->mark = mark; |
| 1117 | } |
| 1118 | { // simple_stmt |
| 1119 | asdl_seq* simple_stmt_var; |
| 1120 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1121 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1122 | ) |
| 1123 | { |
| 1124 | res = simple_stmt_var; |
| 1125 | goto done; |
| 1126 | } |
| 1127 | p->mark = mark; |
| 1128 | } |
| 1129 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1130 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1131 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1132 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1133 | ) |
| 1134 | { |
| 1135 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1136 | if (token == NULL) { |
| 1137 | return NULL; |
| 1138 | } |
| 1139 | int end_lineno = token->end_lineno; |
| 1140 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1141 | int end_col_offset = token->end_col_offset; |
| 1142 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1143 | res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) ); |
| 1144 | if (res == NULL && PyErr_Occurred()) { |
| 1145 | p->error_indicator = 1; |
| 1146 | return NULL; |
| 1147 | } |
| 1148 | goto done; |
| 1149 | } |
| 1150 | p->mark = mark; |
| 1151 | } |
| 1152 | { // $ |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1153 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1154 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1155 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1156 | ) |
| 1157 | { |
| 1158 | res = _PyPegen_interactive_exit ( p ); |
| 1159 | if (res == NULL && PyErr_Occurred()) { |
| 1160 | p->error_indicator = 1; |
| 1161 | return NULL; |
| 1162 | } |
| 1163 | goto done; |
| 1164 | } |
| 1165 | p->mark = mark; |
| 1166 | } |
| 1167 | res = NULL; |
| 1168 | done: |
| 1169 | return res; |
| 1170 | } |
| 1171 | |
| 1172 | // simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE |
| 1173 | static asdl_seq* |
| 1174 | simple_stmt_rule(Parser *p) |
| 1175 | { |
| 1176 | if (p->error_indicator) { |
| 1177 | return NULL; |
| 1178 | } |
| 1179 | asdl_seq* res = NULL; |
| 1180 | int mark = p->mark; |
| 1181 | { // small_stmt !';' NEWLINE |
| 1182 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1183 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1184 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1185 | (a = small_stmt_rule(p)) // small_stmt |
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 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1188 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1189 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1190 | ) |
| 1191 | { |
| 1192 | res = _PyPegen_singleton_seq ( p , a ); |
| 1193 | if (res == NULL && PyErr_Occurred()) { |
| 1194 | p->error_indicator = 1; |
| 1195 | return NULL; |
| 1196 | } |
| 1197 | goto done; |
| 1198 | } |
| 1199 | p->mark = mark; |
| 1200 | } |
| 1201 | { // ';'.small_stmt+ ';'? NEWLINE |
| 1202 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1203 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1204 | void *opt_var; |
| 1205 | UNUSED(opt_var); // Silence compiler warnings |
| 1206 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1207 | (a = _gather_12_rule(p)) // ';'.small_stmt+ |
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 | (opt_var = _PyPegen_expect_token(p, 13), 1) // ';'? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1210 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1211 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1212 | ) |
| 1213 | { |
| 1214 | res = a; |
| 1215 | if (res == NULL && PyErr_Occurred()) { |
| 1216 | p->error_indicator = 1; |
| 1217 | return NULL; |
| 1218 | } |
| 1219 | goto done; |
| 1220 | } |
| 1221 | p->mark = mark; |
| 1222 | } |
| 1223 | res = NULL; |
| 1224 | done: |
| 1225 | return res; |
| 1226 | } |
| 1227 | |
| 1228 | // small_stmt: |
| 1229 | // | assignment |
| 1230 | // | star_expressions |
| 1231 | // | &'return' return_stmt |
| 1232 | // | &('import' | 'from') import_stmt |
| 1233 | // | &'raise' raise_stmt |
| 1234 | // | 'pass' |
| 1235 | // | &'del' del_stmt |
| 1236 | // | &'yield' yield_stmt |
| 1237 | // | &'assert' assert_stmt |
| 1238 | // | 'break' |
| 1239 | // | 'continue' |
| 1240 | // | &'global' global_stmt |
| 1241 | // | &'nonlocal' nonlocal_stmt |
| 1242 | static stmt_ty |
| 1243 | small_stmt_rule(Parser *p) |
| 1244 | { |
| 1245 | if (p->error_indicator) { |
| 1246 | return NULL; |
| 1247 | } |
| 1248 | stmt_ty res = NULL; |
| 1249 | if (_PyPegen_is_memoized(p, small_stmt_type, &res)) |
| 1250 | return res; |
| 1251 | int mark = p->mark; |
| 1252 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1253 | p->error_indicator = 1; |
| 1254 | return NULL; |
| 1255 | } |
| 1256 | int start_lineno = p->tokens[mark]->lineno; |
| 1257 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1258 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1259 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1260 | { // assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1261 | stmt_ty assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1262 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1263 | (assignment_var = assignment_rule(p)) // assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1264 | ) |
| 1265 | { |
| 1266 | res = assignment_var; |
| 1267 | goto done; |
| 1268 | } |
| 1269 | p->mark = mark; |
| 1270 | } |
| 1271 | { // star_expressions |
| 1272 | expr_ty e; |
| 1273 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1274 | (e = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1275 | ) |
| 1276 | { |
| 1277 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1278 | if (token == NULL) { |
| 1279 | return NULL; |
| 1280 | } |
| 1281 | int end_lineno = token->end_lineno; |
| 1282 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1283 | int end_col_offset = token->end_col_offset; |
| 1284 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1285 | res = _Py_Expr ( e , EXTRA ); |
| 1286 | if (res == NULL && PyErr_Occurred()) { |
| 1287 | p->error_indicator = 1; |
| 1288 | return NULL; |
| 1289 | } |
| 1290 | goto done; |
| 1291 | } |
| 1292 | p->mark = mark; |
| 1293 | } |
| 1294 | { // &'return' return_stmt |
| 1295 | stmt_ty return_stmt_var; |
| 1296 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1297 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1298 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1299 | (return_stmt_var = return_stmt_rule(p)) // return_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1300 | ) |
| 1301 | { |
| 1302 | res = return_stmt_var; |
| 1303 | goto done; |
| 1304 | } |
| 1305 | p->mark = mark; |
| 1306 | } |
| 1307 | { // &('import' | 'from') import_stmt |
| 1308 | stmt_ty import_stmt_var; |
| 1309 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1310 | _PyPegen_lookahead(1, _tmp_14_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1311 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1312 | (import_stmt_var = import_stmt_rule(p)) // import_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1313 | ) |
| 1314 | { |
| 1315 | res = import_stmt_var; |
| 1316 | goto done; |
| 1317 | } |
| 1318 | p->mark = mark; |
| 1319 | } |
| 1320 | { // &'raise' raise_stmt |
| 1321 | stmt_ty raise_stmt_var; |
| 1322 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1323 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1324 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1325 | (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1326 | ) |
| 1327 | { |
| 1328 | res = raise_stmt_var; |
| 1329 | goto done; |
| 1330 | } |
| 1331 | p->mark = mark; |
| 1332 | } |
| 1333 | { // 'pass' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1334 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1335 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1336 | (keyword = _PyPegen_expect_token(p, 502)) // token='pass' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1337 | ) |
| 1338 | { |
| 1339 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1340 | if (token == NULL) { |
| 1341 | return NULL; |
| 1342 | } |
| 1343 | int end_lineno = token->end_lineno; |
| 1344 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1345 | int end_col_offset = token->end_col_offset; |
| 1346 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1347 | res = _Py_Pass ( EXTRA ); |
| 1348 | if (res == NULL && PyErr_Occurred()) { |
| 1349 | p->error_indicator = 1; |
| 1350 | return NULL; |
| 1351 | } |
| 1352 | goto done; |
| 1353 | } |
| 1354 | p->mark = mark; |
| 1355 | } |
| 1356 | { // &'del' del_stmt |
| 1357 | stmt_ty del_stmt_var; |
| 1358 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1359 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1360 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1361 | (del_stmt_var = del_stmt_rule(p)) // del_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1362 | ) |
| 1363 | { |
| 1364 | res = del_stmt_var; |
| 1365 | goto done; |
| 1366 | } |
| 1367 | p->mark = mark; |
| 1368 | } |
| 1369 | { // &'yield' yield_stmt |
| 1370 | stmt_ty yield_stmt_var; |
| 1371 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1372 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1373 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1374 | (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1375 | ) |
| 1376 | { |
| 1377 | res = yield_stmt_var; |
| 1378 | goto done; |
| 1379 | } |
| 1380 | p->mark = mark; |
| 1381 | } |
| 1382 | { // &'assert' assert_stmt |
| 1383 | stmt_ty assert_stmt_var; |
| 1384 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1385 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1386 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1387 | (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1388 | ) |
| 1389 | { |
| 1390 | res = assert_stmt_var; |
| 1391 | goto done; |
| 1392 | } |
| 1393 | p->mark = mark; |
| 1394 | } |
| 1395 | { // 'break' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1396 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1397 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1398 | (keyword = _PyPegen_expect_token(p, 506)) // token='break' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1399 | ) |
| 1400 | { |
| 1401 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1402 | if (token == NULL) { |
| 1403 | return NULL; |
| 1404 | } |
| 1405 | int end_lineno = token->end_lineno; |
| 1406 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1407 | int end_col_offset = token->end_col_offset; |
| 1408 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1409 | res = _Py_Break ( EXTRA ); |
| 1410 | if (res == NULL && PyErr_Occurred()) { |
| 1411 | p->error_indicator = 1; |
| 1412 | return NULL; |
| 1413 | } |
| 1414 | goto done; |
| 1415 | } |
| 1416 | p->mark = mark; |
| 1417 | } |
| 1418 | { // 'continue' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1419 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1420 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1421 | (keyword = _PyPegen_expect_token(p, 507)) // token='continue' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1422 | ) |
| 1423 | { |
| 1424 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1425 | if (token == NULL) { |
| 1426 | return NULL; |
| 1427 | } |
| 1428 | int end_lineno = token->end_lineno; |
| 1429 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1430 | int end_col_offset = token->end_col_offset; |
| 1431 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1432 | res = _Py_Continue ( EXTRA ); |
| 1433 | if (res == NULL && PyErr_Occurred()) { |
| 1434 | p->error_indicator = 1; |
| 1435 | return NULL; |
| 1436 | } |
| 1437 | goto done; |
| 1438 | } |
| 1439 | p->mark = mark; |
| 1440 | } |
| 1441 | { // &'global' global_stmt |
| 1442 | stmt_ty global_stmt_var; |
| 1443 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1444 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1445 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1446 | (global_stmt_var = global_stmt_rule(p)) // global_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1447 | ) |
| 1448 | { |
| 1449 | res = global_stmt_var; |
| 1450 | goto done; |
| 1451 | } |
| 1452 | p->mark = mark; |
| 1453 | } |
| 1454 | { // &'nonlocal' nonlocal_stmt |
| 1455 | stmt_ty nonlocal_stmt_var; |
| 1456 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1457 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1458 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1459 | (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1460 | ) |
| 1461 | { |
| 1462 | res = nonlocal_stmt_var; |
| 1463 | goto done; |
| 1464 | } |
| 1465 | p->mark = mark; |
| 1466 | } |
| 1467 | res = NULL; |
| 1468 | done: |
| 1469 | _PyPegen_insert_memo(p, mark, small_stmt_type, res); |
| 1470 | return res; |
| 1471 | } |
| 1472 | |
| 1473 | // compound_stmt: |
| 1474 | // | &('def' | '@' | ASYNC) function_def |
| 1475 | // | &'if' if_stmt |
| 1476 | // | &('class' | '@') class_def |
| 1477 | // | &('with' | ASYNC) with_stmt |
| 1478 | // | &('for' | ASYNC) for_stmt |
| 1479 | // | &'try' try_stmt |
| 1480 | // | &'while' while_stmt |
| 1481 | static stmt_ty |
| 1482 | compound_stmt_rule(Parser *p) |
| 1483 | { |
| 1484 | if (p->error_indicator) { |
| 1485 | return NULL; |
| 1486 | } |
| 1487 | stmt_ty res = NULL; |
| 1488 | int mark = p->mark; |
| 1489 | { // &('def' | '@' | ASYNC) function_def |
| 1490 | stmt_ty function_def_var; |
| 1491 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1492 | _PyPegen_lookahead(1, _tmp_15_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1493 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1494 | (function_def_var = function_def_rule(p)) // function_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1495 | ) |
| 1496 | { |
| 1497 | res = function_def_var; |
| 1498 | goto done; |
| 1499 | } |
| 1500 | p->mark = mark; |
| 1501 | } |
| 1502 | { // &'if' if_stmt |
| 1503 | stmt_ty if_stmt_var; |
| 1504 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1505 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1506 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1507 | (if_stmt_var = if_stmt_rule(p)) // if_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1508 | ) |
| 1509 | { |
| 1510 | res = if_stmt_var; |
| 1511 | goto done; |
| 1512 | } |
| 1513 | p->mark = mark; |
| 1514 | } |
| 1515 | { // &('class' | '@') class_def |
| 1516 | stmt_ty class_def_var; |
| 1517 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1518 | _PyPegen_lookahead(1, _tmp_16_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1519 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1520 | (class_def_var = class_def_rule(p)) // class_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1521 | ) |
| 1522 | { |
| 1523 | res = class_def_var; |
| 1524 | goto done; |
| 1525 | } |
| 1526 | p->mark = mark; |
| 1527 | } |
| 1528 | { // &('with' | ASYNC) with_stmt |
| 1529 | stmt_ty with_stmt_var; |
| 1530 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1531 | _PyPegen_lookahead(1, _tmp_17_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1532 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1533 | (with_stmt_var = with_stmt_rule(p)) // with_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1534 | ) |
| 1535 | { |
| 1536 | res = with_stmt_var; |
| 1537 | goto done; |
| 1538 | } |
| 1539 | p->mark = mark; |
| 1540 | } |
| 1541 | { // &('for' | ASYNC) for_stmt |
| 1542 | stmt_ty for_stmt_var; |
| 1543 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1544 | _PyPegen_lookahead(1, _tmp_18_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1545 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1546 | (for_stmt_var = for_stmt_rule(p)) // for_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1547 | ) |
| 1548 | { |
| 1549 | res = for_stmt_var; |
| 1550 | goto done; |
| 1551 | } |
| 1552 | p->mark = mark; |
| 1553 | } |
| 1554 | { // &'try' try_stmt |
| 1555 | stmt_ty try_stmt_var; |
| 1556 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1557 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1558 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1559 | (try_stmt_var = try_stmt_rule(p)) // try_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1560 | ) |
| 1561 | { |
| 1562 | res = try_stmt_var; |
| 1563 | goto done; |
| 1564 | } |
| 1565 | p->mark = mark; |
| 1566 | } |
| 1567 | { // &'while' while_stmt |
| 1568 | stmt_ty while_stmt_var; |
| 1569 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1570 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1571 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1572 | (while_stmt_var = while_stmt_rule(p)) // while_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1573 | ) |
| 1574 | { |
| 1575 | res = while_stmt_var; |
| 1576 | goto done; |
| 1577 | } |
| 1578 | p->mark = mark; |
| 1579 | } |
| 1580 | res = NULL; |
| 1581 | done: |
| 1582 | return res; |
| 1583 | } |
| 1584 | |
| 1585 | // assignment: |
| 1586 | // | NAME ':' expression ['=' annotated_rhs] |
| 1587 | // | ('(' 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] | 1588 | // | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1589 | // | target augassign (yield_expr | star_expressions) |
| 1590 | // | invalid_assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1591 | static stmt_ty |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1592 | assignment_rule(Parser *p) |
| 1593 | { |
| 1594 | if (p->error_indicator) { |
| 1595 | return NULL; |
| 1596 | } |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1597 | stmt_ty res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1598 | int mark = p->mark; |
| 1599 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1600 | p->error_indicator = 1; |
| 1601 | return NULL; |
| 1602 | } |
| 1603 | int start_lineno = p->tokens[mark]->lineno; |
| 1604 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1605 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1606 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1607 | { // NAME ':' expression ['=' annotated_rhs] |
| 1608 | expr_ty a; |
| 1609 | expr_ty b; |
| 1610 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1611 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1612 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1613 | (a = _PyPegen_name_token(p)) // NAME |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1618 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1619 | (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1620 | ) |
| 1621 | { |
| 1622 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1623 | if (token == NULL) { |
| 1624 | return NULL; |
| 1625 | } |
| 1626 | int end_lineno = token->end_lineno; |
| 1627 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1628 | int end_col_offset = token->end_col_offset; |
| 1629 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1630 | 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] | 1631 | if (res == NULL && PyErr_Occurred()) { |
| 1632 | p->error_indicator = 1; |
| 1633 | return NULL; |
| 1634 | } |
| 1635 | goto done; |
| 1636 | } |
| 1637 | p->mark = mark; |
| 1638 | } |
| 1639 | { // ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
| 1640 | void *a; |
| 1641 | expr_ty b; |
| 1642 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1643 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1644 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1645 | (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] | 1646 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1647 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1650 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1651 | (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1652 | ) |
| 1653 | { |
| 1654 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1655 | if (token == NULL) { |
| 1656 | return NULL; |
| 1657 | } |
| 1658 | int end_lineno = token->end_lineno; |
| 1659 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1660 | int end_col_offset = token->end_col_offset; |
| 1661 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1662 | 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] | 1663 | if (res == NULL && PyErr_Occurred()) { |
| 1664 | p->error_indicator = 1; |
| 1665 | return NULL; |
| 1666 | } |
| 1667 | goto done; |
| 1668 | } |
| 1669 | p->mark = mark; |
| 1670 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1671 | { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1672 | asdl_seq * a; |
| 1673 | void *b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1674 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1675 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1676 | (a = _loop1_22_rule(p)) // ((star_targets '='))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1677 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1678 | (b = _tmp_23_rule(p)) // yield_expr | star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1679 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1680 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1681 | ) |
| 1682 | { |
| 1683 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1684 | if (token == NULL) { |
| 1685 | return NULL; |
| 1686 | } |
| 1687 | int end_lineno = token->end_lineno; |
| 1688 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1689 | int end_col_offset = token->end_col_offset; |
| 1690 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1691 | res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1692 | if (res == NULL && PyErr_Occurred()) { |
| 1693 | p->error_indicator = 1; |
| 1694 | return NULL; |
| 1695 | } |
| 1696 | goto done; |
| 1697 | } |
| 1698 | p->mark = mark; |
| 1699 | } |
| 1700 | { // target augassign (yield_expr | star_expressions) |
| 1701 | expr_ty a; |
| 1702 | AugOperator* b; |
| 1703 | void *c; |
| 1704 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1705 | (a = target_rule(p)) // target |
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 | (b = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1708 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1709 | (c = _tmp_24_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1710 | ) |
| 1711 | { |
| 1712 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1713 | if (token == NULL) { |
| 1714 | return NULL; |
| 1715 | } |
| 1716 | int end_lineno = token->end_lineno; |
| 1717 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1718 | int end_col_offset = token->end_col_offset; |
| 1719 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1720 | res = _Py_AugAssign ( a , b -> kind , c , EXTRA ); |
| 1721 | if (res == NULL && PyErr_Occurred()) { |
| 1722 | p->error_indicator = 1; |
| 1723 | return NULL; |
| 1724 | } |
| 1725 | goto done; |
| 1726 | } |
| 1727 | p->mark = mark; |
| 1728 | } |
| 1729 | { // invalid_assignment |
| 1730 | void *invalid_assignment_var; |
| 1731 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1732 | (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1733 | ) |
| 1734 | { |
| 1735 | res = invalid_assignment_var; |
| 1736 | goto done; |
| 1737 | } |
| 1738 | p->mark = mark; |
| 1739 | } |
| 1740 | res = NULL; |
| 1741 | done: |
| 1742 | return res; |
| 1743 | } |
| 1744 | |
| 1745 | // augassign: |
| 1746 | // | '+=' |
| 1747 | // | '-=' |
| 1748 | // | '*=' |
| 1749 | // | '@=' |
| 1750 | // | '/=' |
| 1751 | // | '%=' |
| 1752 | // | '&=' |
| 1753 | // | '|=' |
| 1754 | // | '^=' |
| 1755 | // | '<<=' |
| 1756 | // | '>>=' |
| 1757 | // | '**=' |
| 1758 | // | '//=' |
| 1759 | static AugOperator* |
| 1760 | augassign_rule(Parser *p) |
| 1761 | { |
| 1762 | if (p->error_indicator) { |
| 1763 | return NULL; |
| 1764 | } |
| 1765 | AugOperator* res = NULL; |
| 1766 | int mark = p->mark; |
| 1767 | { // '+=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1768 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1769 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1770 | (literal = _PyPegen_expect_token(p, 36)) // token='+=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1771 | ) |
| 1772 | { |
| 1773 | res = _PyPegen_augoperator ( p , Add ); |
| 1774 | if (res == NULL && PyErr_Occurred()) { |
| 1775 | p->error_indicator = 1; |
| 1776 | return NULL; |
| 1777 | } |
| 1778 | goto done; |
| 1779 | } |
| 1780 | p->mark = mark; |
| 1781 | } |
| 1782 | { // '-=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1783 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1784 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1785 | (literal = _PyPegen_expect_token(p, 37)) // token='-=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1786 | ) |
| 1787 | { |
| 1788 | res = _PyPegen_augoperator ( p , Sub ); |
| 1789 | if (res == NULL && PyErr_Occurred()) { |
| 1790 | p->error_indicator = 1; |
| 1791 | return NULL; |
| 1792 | } |
| 1793 | goto done; |
| 1794 | } |
| 1795 | p->mark = mark; |
| 1796 | } |
| 1797 | { // '*=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1798 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1799 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1800 | (literal = _PyPegen_expect_token(p, 38)) // token='*=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1801 | ) |
| 1802 | { |
| 1803 | res = _PyPegen_augoperator ( p , Mult ); |
| 1804 | if (res == NULL && PyErr_Occurred()) { |
| 1805 | p->error_indicator = 1; |
| 1806 | return NULL; |
| 1807 | } |
| 1808 | goto done; |
| 1809 | } |
| 1810 | p->mark = mark; |
| 1811 | } |
| 1812 | { // '@=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1813 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1814 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1815 | (literal = _PyPegen_expect_token(p, 50)) // token='@=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1816 | ) |
| 1817 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1818 | res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1819 | if (res == NULL && PyErr_Occurred()) { |
| 1820 | p->error_indicator = 1; |
| 1821 | return NULL; |
| 1822 | } |
| 1823 | goto done; |
| 1824 | } |
| 1825 | p->mark = mark; |
| 1826 | } |
| 1827 | { // '/=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1828 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1829 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1830 | (literal = _PyPegen_expect_token(p, 39)) // token='/=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1831 | ) |
| 1832 | { |
| 1833 | res = _PyPegen_augoperator ( p , Div ); |
| 1834 | if (res == NULL && PyErr_Occurred()) { |
| 1835 | p->error_indicator = 1; |
| 1836 | return NULL; |
| 1837 | } |
| 1838 | goto done; |
| 1839 | } |
| 1840 | p->mark = mark; |
| 1841 | } |
| 1842 | { // '%=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1843 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1844 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1845 | (literal = _PyPegen_expect_token(p, 40)) // token='%=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1846 | ) |
| 1847 | { |
| 1848 | res = _PyPegen_augoperator ( p , Mod ); |
| 1849 | if (res == NULL && PyErr_Occurred()) { |
| 1850 | p->error_indicator = 1; |
| 1851 | return NULL; |
| 1852 | } |
| 1853 | goto done; |
| 1854 | } |
| 1855 | p->mark = mark; |
| 1856 | } |
| 1857 | { // '&=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1858 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1859 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1860 | (literal = _PyPegen_expect_token(p, 41)) // token='&=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1861 | ) |
| 1862 | { |
| 1863 | res = _PyPegen_augoperator ( p , BitAnd ); |
| 1864 | if (res == NULL && PyErr_Occurred()) { |
| 1865 | p->error_indicator = 1; |
| 1866 | return NULL; |
| 1867 | } |
| 1868 | goto done; |
| 1869 | } |
| 1870 | p->mark = mark; |
| 1871 | } |
| 1872 | { // '|=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1873 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1874 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1875 | (literal = _PyPegen_expect_token(p, 42)) // token='|=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1876 | ) |
| 1877 | { |
| 1878 | res = _PyPegen_augoperator ( p , BitOr ); |
| 1879 | if (res == NULL && PyErr_Occurred()) { |
| 1880 | p->error_indicator = 1; |
| 1881 | return NULL; |
| 1882 | } |
| 1883 | goto done; |
| 1884 | } |
| 1885 | p->mark = mark; |
| 1886 | } |
| 1887 | { // '^=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1888 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1889 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1890 | (literal = _PyPegen_expect_token(p, 43)) // token='^=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1891 | ) |
| 1892 | { |
| 1893 | res = _PyPegen_augoperator ( p , BitXor ); |
| 1894 | if (res == NULL && PyErr_Occurred()) { |
| 1895 | p->error_indicator = 1; |
| 1896 | return NULL; |
| 1897 | } |
| 1898 | goto done; |
| 1899 | } |
| 1900 | p->mark = mark; |
| 1901 | } |
| 1902 | { // '<<=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1903 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1904 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1905 | (literal = _PyPegen_expect_token(p, 44)) // token='<<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1906 | ) |
| 1907 | { |
| 1908 | res = _PyPegen_augoperator ( p , LShift ); |
| 1909 | if (res == NULL && PyErr_Occurred()) { |
| 1910 | p->error_indicator = 1; |
| 1911 | return NULL; |
| 1912 | } |
| 1913 | goto done; |
| 1914 | } |
| 1915 | p->mark = mark; |
| 1916 | } |
| 1917 | { // '>>=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1918 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1919 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1920 | (literal = _PyPegen_expect_token(p, 45)) // token='>>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1921 | ) |
| 1922 | { |
| 1923 | res = _PyPegen_augoperator ( p , RShift ); |
| 1924 | if (res == NULL && PyErr_Occurred()) { |
| 1925 | p->error_indicator = 1; |
| 1926 | return NULL; |
| 1927 | } |
| 1928 | goto done; |
| 1929 | } |
| 1930 | p->mark = mark; |
| 1931 | } |
| 1932 | { // '**=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1933 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1934 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1935 | (literal = _PyPegen_expect_token(p, 46)) // token='**=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1936 | ) |
| 1937 | { |
| 1938 | res = _PyPegen_augoperator ( p , Pow ); |
| 1939 | if (res == NULL && PyErr_Occurred()) { |
| 1940 | p->error_indicator = 1; |
| 1941 | return NULL; |
| 1942 | } |
| 1943 | goto done; |
| 1944 | } |
| 1945 | p->mark = mark; |
| 1946 | } |
| 1947 | { // '//=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1948 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1949 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1950 | (literal = _PyPegen_expect_token(p, 48)) // token='//=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1951 | ) |
| 1952 | { |
| 1953 | res = _PyPegen_augoperator ( p , FloorDiv ); |
| 1954 | if (res == NULL && PyErr_Occurred()) { |
| 1955 | p->error_indicator = 1; |
| 1956 | return NULL; |
| 1957 | } |
| 1958 | goto done; |
| 1959 | } |
| 1960 | p->mark = mark; |
| 1961 | } |
| 1962 | res = NULL; |
| 1963 | done: |
| 1964 | return res; |
| 1965 | } |
| 1966 | |
| 1967 | // global_stmt: 'global' ','.NAME+ |
| 1968 | static stmt_ty |
| 1969 | global_stmt_rule(Parser *p) |
| 1970 | { |
| 1971 | if (p->error_indicator) { |
| 1972 | return NULL; |
| 1973 | } |
| 1974 | stmt_ty res = NULL; |
| 1975 | int mark = p->mark; |
| 1976 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1977 | p->error_indicator = 1; |
| 1978 | return NULL; |
| 1979 | } |
| 1980 | int start_lineno = p->tokens[mark]->lineno; |
| 1981 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1982 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1983 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1984 | { // 'global' ','.NAME+ |
| 1985 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1986 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1987 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1988 | (keyword = _PyPegen_expect_token(p, 508)) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1989 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1990 | (a = _gather_25_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1991 | ) |
| 1992 | { |
| 1993 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1994 | if (token == NULL) { |
| 1995 | return NULL; |
| 1996 | } |
| 1997 | int end_lineno = token->end_lineno; |
| 1998 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1999 | int end_col_offset = token->end_col_offset; |
| 2000 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2001 | res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2002 | if (res == NULL && PyErr_Occurred()) { |
| 2003 | p->error_indicator = 1; |
| 2004 | return NULL; |
| 2005 | } |
| 2006 | goto done; |
| 2007 | } |
| 2008 | p->mark = mark; |
| 2009 | } |
| 2010 | res = NULL; |
| 2011 | done: |
| 2012 | return res; |
| 2013 | } |
| 2014 | |
| 2015 | // nonlocal_stmt: 'nonlocal' ','.NAME+ |
| 2016 | static stmt_ty |
| 2017 | nonlocal_stmt_rule(Parser *p) |
| 2018 | { |
| 2019 | if (p->error_indicator) { |
| 2020 | return NULL; |
| 2021 | } |
| 2022 | stmt_ty res = NULL; |
| 2023 | int mark = p->mark; |
| 2024 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2025 | p->error_indicator = 1; |
| 2026 | return NULL; |
| 2027 | } |
| 2028 | int start_lineno = p->tokens[mark]->lineno; |
| 2029 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2030 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2031 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2032 | { // 'nonlocal' ','.NAME+ |
| 2033 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2034 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2035 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2036 | (keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2037 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2038 | (a = _gather_27_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2039 | ) |
| 2040 | { |
| 2041 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2042 | if (token == NULL) { |
| 2043 | return NULL; |
| 2044 | } |
| 2045 | int end_lineno = token->end_lineno; |
| 2046 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2047 | int end_col_offset = token->end_col_offset; |
| 2048 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2049 | res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2050 | if (res == NULL && PyErr_Occurred()) { |
| 2051 | p->error_indicator = 1; |
| 2052 | return NULL; |
| 2053 | } |
| 2054 | goto done; |
| 2055 | } |
| 2056 | p->mark = mark; |
| 2057 | } |
| 2058 | res = NULL; |
| 2059 | done: |
| 2060 | return res; |
| 2061 | } |
| 2062 | |
| 2063 | // yield_stmt: yield_expr |
| 2064 | static stmt_ty |
| 2065 | yield_stmt_rule(Parser *p) |
| 2066 | { |
| 2067 | if (p->error_indicator) { |
| 2068 | return NULL; |
| 2069 | } |
| 2070 | stmt_ty res = NULL; |
| 2071 | int mark = p->mark; |
| 2072 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2073 | p->error_indicator = 1; |
| 2074 | return NULL; |
| 2075 | } |
| 2076 | int start_lineno = p->tokens[mark]->lineno; |
| 2077 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2078 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2079 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2080 | { // yield_expr |
| 2081 | expr_ty y; |
| 2082 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2083 | (y = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2084 | ) |
| 2085 | { |
| 2086 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2087 | if (token == NULL) { |
| 2088 | return NULL; |
| 2089 | } |
| 2090 | int end_lineno = token->end_lineno; |
| 2091 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2092 | int end_col_offset = token->end_col_offset; |
| 2093 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2094 | res = _Py_Expr ( y , EXTRA ); |
| 2095 | if (res == NULL && PyErr_Occurred()) { |
| 2096 | p->error_indicator = 1; |
| 2097 | return NULL; |
| 2098 | } |
| 2099 | goto done; |
| 2100 | } |
| 2101 | p->mark = mark; |
| 2102 | } |
| 2103 | res = NULL; |
| 2104 | done: |
| 2105 | return res; |
| 2106 | } |
| 2107 | |
| 2108 | // assert_stmt: 'assert' expression [',' expression] |
| 2109 | static stmt_ty |
| 2110 | assert_stmt_rule(Parser *p) |
| 2111 | { |
| 2112 | if (p->error_indicator) { |
| 2113 | return NULL; |
| 2114 | } |
| 2115 | stmt_ty res = NULL; |
| 2116 | int mark = p->mark; |
| 2117 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2118 | p->error_indicator = 1; |
| 2119 | return NULL; |
| 2120 | } |
| 2121 | int start_lineno = p->tokens[mark]->lineno; |
| 2122 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2123 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2124 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2125 | { // 'assert' expression [',' expression] |
| 2126 | expr_ty a; |
| 2127 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2128 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2129 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2130 | (keyword = _PyPegen_expect_token(p, 505)) // token='assert' |
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 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2133 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2134 | (b = _tmp_29_rule(p), 1) // [',' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2135 | ) |
| 2136 | { |
| 2137 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2138 | if (token == NULL) { |
| 2139 | return NULL; |
| 2140 | } |
| 2141 | int end_lineno = token->end_lineno; |
| 2142 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2143 | int end_col_offset = token->end_col_offset; |
| 2144 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2145 | res = _Py_Assert ( a , b , EXTRA ); |
| 2146 | if (res == NULL && PyErr_Occurred()) { |
| 2147 | p->error_indicator = 1; |
| 2148 | return NULL; |
| 2149 | } |
| 2150 | goto done; |
| 2151 | } |
| 2152 | p->mark = mark; |
| 2153 | } |
| 2154 | res = NULL; |
| 2155 | done: |
| 2156 | return res; |
| 2157 | } |
| 2158 | |
| 2159 | // del_stmt: 'del' del_targets |
| 2160 | static stmt_ty |
| 2161 | del_stmt_rule(Parser *p) |
| 2162 | { |
| 2163 | if (p->error_indicator) { |
| 2164 | return NULL; |
| 2165 | } |
| 2166 | stmt_ty res = NULL; |
| 2167 | int mark = p->mark; |
| 2168 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2169 | p->error_indicator = 1; |
| 2170 | return NULL; |
| 2171 | } |
| 2172 | int start_lineno = p->tokens[mark]->lineno; |
| 2173 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2174 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2175 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2176 | { // 'del' del_targets |
| 2177 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2178 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2179 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2180 | (keyword = _PyPegen_expect_token(p, 503)) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2181 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2182 | (a = del_targets_rule(p)) // del_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2183 | ) |
| 2184 | { |
| 2185 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2186 | if (token == NULL) { |
| 2187 | return NULL; |
| 2188 | } |
| 2189 | int end_lineno = token->end_lineno; |
| 2190 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2191 | int end_col_offset = token->end_col_offset; |
| 2192 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2193 | res = _Py_Delete ( a , EXTRA ); |
| 2194 | if (res == NULL && PyErr_Occurred()) { |
| 2195 | p->error_indicator = 1; |
| 2196 | return NULL; |
| 2197 | } |
| 2198 | goto done; |
| 2199 | } |
| 2200 | p->mark = mark; |
| 2201 | } |
| 2202 | res = NULL; |
| 2203 | done: |
| 2204 | return res; |
| 2205 | } |
| 2206 | |
| 2207 | // import_stmt: import_name | import_from |
| 2208 | static stmt_ty |
| 2209 | import_stmt_rule(Parser *p) |
| 2210 | { |
| 2211 | if (p->error_indicator) { |
| 2212 | return NULL; |
| 2213 | } |
| 2214 | stmt_ty res = NULL; |
| 2215 | int mark = p->mark; |
| 2216 | { // import_name |
| 2217 | stmt_ty import_name_var; |
| 2218 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2219 | (import_name_var = import_name_rule(p)) // import_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2220 | ) |
| 2221 | { |
| 2222 | res = import_name_var; |
| 2223 | goto done; |
| 2224 | } |
| 2225 | p->mark = mark; |
| 2226 | } |
| 2227 | { // import_from |
| 2228 | stmt_ty import_from_var; |
| 2229 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2230 | (import_from_var = import_from_rule(p)) // import_from |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2231 | ) |
| 2232 | { |
| 2233 | res = import_from_var; |
| 2234 | goto done; |
| 2235 | } |
| 2236 | p->mark = mark; |
| 2237 | } |
| 2238 | res = NULL; |
| 2239 | done: |
| 2240 | return res; |
| 2241 | } |
| 2242 | |
| 2243 | // import_name: 'import' dotted_as_names |
| 2244 | static stmt_ty |
| 2245 | import_name_rule(Parser *p) |
| 2246 | { |
| 2247 | if (p->error_indicator) { |
| 2248 | return NULL; |
| 2249 | } |
| 2250 | stmt_ty res = NULL; |
| 2251 | int mark = p->mark; |
| 2252 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2253 | p->error_indicator = 1; |
| 2254 | return NULL; |
| 2255 | } |
| 2256 | int start_lineno = p->tokens[mark]->lineno; |
| 2257 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2258 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2259 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2260 | { // 'import' dotted_as_names |
| 2261 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2262 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2263 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2264 | (keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2265 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2266 | (a = dotted_as_names_rule(p)) // dotted_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2267 | ) |
| 2268 | { |
| 2269 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2270 | if (token == NULL) { |
| 2271 | return NULL; |
| 2272 | } |
| 2273 | int end_lineno = token->end_lineno; |
| 2274 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2275 | int end_col_offset = token->end_col_offset; |
| 2276 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2277 | res = _Py_Import ( a , EXTRA ); |
| 2278 | if (res == NULL && PyErr_Occurred()) { |
| 2279 | p->error_indicator = 1; |
| 2280 | return NULL; |
| 2281 | } |
| 2282 | goto done; |
| 2283 | } |
| 2284 | p->mark = mark; |
| 2285 | } |
| 2286 | res = NULL; |
| 2287 | done: |
| 2288 | return res; |
| 2289 | } |
| 2290 | |
| 2291 | // import_from: |
| 2292 | // | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2293 | // | 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2294 | static stmt_ty |
| 2295 | import_from_rule(Parser *p) |
| 2296 | { |
| 2297 | if (p->error_indicator) { |
| 2298 | return NULL; |
| 2299 | } |
| 2300 | stmt_ty res = NULL; |
| 2301 | int mark = p->mark; |
| 2302 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2303 | p->error_indicator = 1; |
| 2304 | return NULL; |
| 2305 | } |
| 2306 | int start_lineno = p->tokens[mark]->lineno; |
| 2307 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2308 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2309 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2310 | { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2311 | asdl_seq * a; |
| 2312 | expr_ty b; |
| 2313 | asdl_seq* c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2314 | Token * keyword; |
| 2315 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2316 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2317 | (keyword = _PyPegen_expect_token(p, 514)) // token='from' |
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 | (a = _loop0_30_rule(p)) // (('.' | '...'))* |
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 | (b = dotted_name_rule(p)) // dotted_name |
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 | (keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2324 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2325 | (c = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2326 | ) |
| 2327 | { |
| 2328 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2329 | if (token == NULL) { |
| 2330 | return NULL; |
| 2331 | } |
| 2332 | int end_lineno = token->end_lineno; |
| 2333 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2334 | int end_col_offset = token->end_col_offset; |
| 2335 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2336 | res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2337 | if (res == NULL && PyErr_Occurred()) { |
| 2338 | p->error_indicator = 1; |
| 2339 | return NULL; |
| 2340 | } |
| 2341 | goto done; |
| 2342 | } |
| 2343 | p->mark = mark; |
| 2344 | } |
| 2345 | { // 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2346 | asdl_seq * a; |
| 2347 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2348 | Token * keyword; |
| 2349 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2350 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2351 | (keyword = _PyPegen_expect_token(p, 514)) // token='from' |
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 | (a = _loop1_31_rule(p)) // (('.' | '...'))+ |
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 | (keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2356 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2357 | (b = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2358 | ) |
| 2359 | { |
| 2360 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2361 | if (token == NULL) { |
| 2362 | return NULL; |
| 2363 | } |
| 2364 | int end_lineno = token->end_lineno; |
| 2365 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2366 | int end_col_offset = token->end_col_offset; |
| 2367 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2368 | res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2369 | if (res == NULL && PyErr_Occurred()) { |
| 2370 | p->error_indicator = 1; |
| 2371 | return NULL; |
| 2372 | } |
| 2373 | goto done; |
| 2374 | } |
| 2375 | p->mark = mark; |
| 2376 | } |
| 2377 | res = NULL; |
| 2378 | done: |
| 2379 | return res; |
| 2380 | } |
| 2381 | |
| 2382 | // import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*' |
| 2383 | static asdl_seq* |
| 2384 | import_from_targets_rule(Parser *p) |
| 2385 | { |
| 2386 | if (p->error_indicator) { |
| 2387 | return NULL; |
| 2388 | } |
| 2389 | asdl_seq* res = NULL; |
| 2390 | int mark = p->mark; |
| 2391 | { // '(' import_from_as_names ','? ')' |
| 2392 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2393 | Token * literal; |
| 2394 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2395 | void *opt_var; |
| 2396 | UNUSED(opt_var); // Silence compiler warnings |
| 2397 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2398 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (a = import_from_as_names_rule(p)) // import_from_as_names |
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 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2403 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2404 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2405 | ) |
| 2406 | { |
| 2407 | res = a; |
| 2408 | if (res == NULL && PyErr_Occurred()) { |
| 2409 | p->error_indicator = 1; |
| 2410 | return NULL; |
| 2411 | } |
| 2412 | goto done; |
| 2413 | } |
| 2414 | p->mark = mark; |
| 2415 | } |
| 2416 | { // import_from_as_names |
| 2417 | asdl_seq* import_from_as_names_var; |
| 2418 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2419 | (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] | 2420 | ) |
| 2421 | { |
| 2422 | res = import_from_as_names_var; |
| 2423 | goto done; |
| 2424 | } |
| 2425 | p->mark = mark; |
| 2426 | } |
| 2427 | { // '*' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2428 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2429 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2430 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2431 | ) |
| 2432 | { |
| 2433 | res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) ); |
| 2434 | if (res == NULL && PyErr_Occurred()) { |
| 2435 | p->error_indicator = 1; |
| 2436 | return NULL; |
| 2437 | } |
| 2438 | goto done; |
| 2439 | } |
| 2440 | p->mark = mark; |
| 2441 | } |
| 2442 | res = NULL; |
| 2443 | done: |
| 2444 | return res; |
| 2445 | } |
| 2446 | |
| 2447 | // import_from_as_names: ','.import_from_as_name+ |
| 2448 | static asdl_seq* |
| 2449 | import_from_as_names_rule(Parser *p) |
| 2450 | { |
| 2451 | if (p->error_indicator) { |
| 2452 | return NULL; |
| 2453 | } |
| 2454 | asdl_seq* res = NULL; |
| 2455 | int mark = p->mark; |
| 2456 | { // ','.import_from_as_name+ |
| 2457 | asdl_seq * a; |
| 2458 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2459 | (a = _gather_32_rule(p)) // ','.import_from_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2460 | ) |
| 2461 | { |
| 2462 | res = a; |
| 2463 | if (res == NULL && PyErr_Occurred()) { |
| 2464 | p->error_indicator = 1; |
| 2465 | return NULL; |
| 2466 | } |
| 2467 | goto done; |
| 2468 | } |
| 2469 | p->mark = mark; |
| 2470 | } |
| 2471 | res = NULL; |
| 2472 | done: |
| 2473 | return res; |
| 2474 | } |
| 2475 | |
| 2476 | // import_from_as_name: NAME ['as' NAME] |
| 2477 | static alias_ty |
| 2478 | import_from_as_name_rule(Parser *p) |
| 2479 | { |
| 2480 | if (p->error_indicator) { |
| 2481 | return NULL; |
| 2482 | } |
| 2483 | alias_ty res = NULL; |
| 2484 | int mark = p->mark; |
| 2485 | { // NAME ['as' NAME] |
| 2486 | expr_ty a; |
| 2487 | void *b; |
| 2488 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2489 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2490 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2491 | (b = _tmp_34_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2492 | ) |
| 2493 | { |
| 2494 | res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2495 | if (res == NULL && PyErr_Occurred()) { |
| 2496 | p->error_indicator = 1; |
| 2497 | return NULL; |
| 2498 | } |
| 2499 | goto done; |
| 2500 | } |
| 2501 | p->mark = mark; |
| 2502 | } |
| 2503 | res = NULL; |
| 2504 | done: |
| 2505 | return res; |
| 2506 | } |
| 2507 | |
| 2508 | // dotted_as_names: ','.dotted_as_name+ |
| 2509 | static asdl_seq* |
| 2510 | dotted_as_names_rule(Parser *p) |
| 2511 | { |
| 2512 | if (p->error_indicator) { |
| 2513 | return NULL; |
| 2514 | } |
| 2515 | asdl_seq* res = NULL; |
| 2516 | int mark = p->mark; |
| 2517 | { // ','.dotted_as_name+ |
| 2518 | asdl_seq * a; |
| 2519 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2520 | (a = _gather_35_rule(p)) // ','.dotted_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2521 | ) |
| 2522 | { |
| 2523 | res = a; |
| 2524 | if (res == NULL && PyErr_Occurred()) { |
| 2525 | p->error_indicator = 1; |
| 2526 | return NULL; |
| 2527 | } |
| 2528 | goto done; |
| 2529 | } |
| 2530 | p->mark = mark; |
| 2531 | } |
| 2532 | res = NULL; |
| 2533 | done: |
| 2534 | return res; |
| 2535 | } |
| 2536 | |
| 2537 | // dotted_as_name: dotted_name ['as' NAME] |
| 2538 | static alias_ty |
| 2539 | dotted_as_name_rule(Parser *p) |
| 2540 | { |
| 2541 | if (p->error_indicator) { |
| 2542 | return NULL; |
| 2543 | } |
| 2544 | alias_ty res = NULL; |
| 2545 | int mark = p->mark; |
| 2546 | { // dotted_name ['as' NAME] |
| 2547 | expr_ty a; |
| 2548 | void *b; |
| 2549 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2550 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2551 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2552 | (b = _tmp_37_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2553 | ) |
| 2554 | { |
| 2555 | res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2556 | if (res == NULL && PyErr_Occurred()) { |
| 2557 | p->error_indicator = 1; |
| 2558 | return NULL; |
| 2559 | } |
| 2560 | goto done; |
| 2561 | } |
| 2562 | p->mark = mark; |
| 2563 | } |
| 2564 | res = NULL; |
| 2565 | done: |
| 2566 | return res; |
| 2567 | } |
| 2568 | |
| 2569 | // Left-recursive |
| 2570 | // dotted_name: dotted_name '.' NAME | NAME |
| 2571 | static expr_ty dotted_name_raw(Parser *); |
| 2572 | static expr_ty |
| 2573 | dotted_name_rule(Parser *p) |
| 2574 | { |
| 2575 | expr_ty res = NULL; |
| 2576 | if (_PyPegen_is_memoized(p, dotted_name_type, &res)) |
| 2577 | return res; |
| 2578 | int mark = p->mark; |
| 2579 | int resmark = p->mark; |
| 2580 | while (1) { |
| 2581 | int tmpvar_0 = _PyPegen_update_memo(p, mark, dotted_name_type, res); |
| 2582 | if (tmpvar_0) { |
| 2583 | return res; |
| 2584 | } |
| 2585 | p->mark = mark; |
| 2586 | void *raw = dotted_name_raw(p); |
| 2587 | if (raw == NULL || p->mark <= resmark) |
| 2588 | break; |
| 2589 | resmark = p->mark; |
| 2590 | res = raw; |
| 2591 | } |
| 2592 | p->mark = resmark; |
| 2593 | return res; |
| 2594 | } |
| 2595 | static expr_ty |
| 2596 | dotted_name_raw(Parser *p) |
| 2597 | { |
| 2598 | if (p->error_indicator) { |
| 2599 | return NULL; |
| 2600 | } |
| 2601 | expr_ty res = NULL; |
| 2602 | int mark = p->mark; |
| 2603 | { // dotted_name '.' NAME |
| 2604 | expr_ty a; |
| 2605 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2606 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2607 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2608 | (a = dotted_name_rule(p)) // dotted_name |
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 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2611 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2612 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2613 | ) |
| 2614 | { |
| 2615 | res = _PyPegen_join_names_with_dot ( p , a , b ); |
| 2616 | if (res == NULL && PyErr_Occurred()) { |
| 2617 | p->error_indicator = 1; |
| 2618 | return NULL; |
| 2619 | } |
| 2620 | goto done; |
| 2621 | } |
| 2622 | p->mark = mark; |
| 2623 | } |
| 2624 | { // NAME |
| 2625 | expr_ty name_var; |
| 2626 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2627 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2628 | ) |
| 2629 | { |
| 2630 | res = name_var; |
| 2631 | goto done; |
| 2632 | } |
| 2633 | p->mark = mark; |
| 2634 | } |
| 2635 | res = NULL; |
| 2636 | done: |
| 2637 | return res; |
| 2638 | } |
| 2639 | |
| 2640 | // if_stmt: |
| 2641 | // | 'if' named_expression ':' block elif_stmt |
| 2642 | // | 'if' named_expression ':' block else_block? |
| 2643 | static stmt_ty |
| 2644 | if_stmt_rule(Parser *p) |
| 2645 | { |
| 2646 | if (p->error_indicator) { |
| 2647 | return NULL; |
| 2648 | } |
| 2649 | stmt_ty res = NULL; |
| 2650 | int mark = p->mark; |
| 2651 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2652 | p->error_indicator = 1; |
| 2653 | return NULL; |
| 2654 | } |
| 2655 | int start_lineno = p->tokens[mark]->lineno; |
| 2656 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2657 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2658 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2659 | { // 'if' named_expression ':' block elif_stmt |
| 2660 | expr_ty a; |
| 2661 | asdl_seq* b; |
| 2662 | stmt_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2663 | Token * keyword; |
| 2664 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2665 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2666 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
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 | (a = named_expression_rule(p)) // named_expression |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2673 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2674 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2675 | ) |
| 2676 | { |
| 2677 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2678 | if (token == NULL) { |
| 2679 | return NULL; |
| 2680 | } |
| 2681 | int end_lineno = token->end_lineno; |
| 2682 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2683 | int end_col_offset = token->end_col_offset; |
| 2684 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2685 | res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2686 | if (res == NULL && PyErr_Occurred()) { |
| 2687 | p->error_indicator = 1; |
| 2688 | return NULL; |
| 2689 | } |
| 2690 | goto done; |
| 2691 | } |
| 2692 | p->mark = mark; |
| 2693 | } |
| 2694 | { // 'if' named_expression ':' block else_block? |
| 2695 | expr_ty a; |
| 2696 | asdl_seq* b; |
| 2697 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2698 | Token * keyword; |
| 2699 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2700 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2701 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
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 | (a = named_expression_rule(p)) // named_expression |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2708 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2709 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2710 | ) |
| 2711 | { |
| 2712 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2713 | if (token == NULL) { |
| 2714 | return NULL; |
| 2715 | } |
| 2716 | int end_lineno = token->end_lineno; |
| 2717 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2718 | int end_col_offset = token->end_col_offset; |
| 2719 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2720 | res = _Py_If ( a , b , c , EXTRA ); |
| 2721 | if (res == NULL && PyErr_Occurred()) { |
| 2722 | p->error_indicator = 1; |
| 2723 | return NULL; |
| 2724 | } |
| 2725 | goto done; |
| 2726 | } |
| 2727 | p->mark = mark; |
| 2728 | } |
| 2729 | res = NULL; |
| 2730 | done: |
| 2731 | return res; |
| 2732 | } |
| 2733 | |
| 2734 | // elif_stmt: |
| 2735 | // | 'elif' named_expression ':' block elif_stmt |
| 2736 | // | 'elif' named_expression ':' block else_block? |
| 2737 | static stmt_ty |
| 2738 | elif_stmt_rule(Parser *p) |
| 2739 | { |
| 2740 | if (p->error_indicator) { |
| 2741 | return NULL; |
| 2742 | } |
| 2743 | stmt_ty res = NULL; |
| 2744 | int mark = p->mark; |
| 2745 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2746 | p->error_indicator = 1; |
| 2747 | return NULL; |
| 2748 | } |
| 2749 | int start_lineno = p->tokens[mark]->lineno; |
| 2750 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2751 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2752 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2753 | { // 'elif' named_expression ':' block elif_stmt |
| 2754 | expr_ty a; |
| 2755 | asdl_seq* b; |
| 2756 | stmt_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2757 | Token * keyword; |
| 2758 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2759 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2760 | (keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
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 | (a = named_expression_rule(p)) // named_expression |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2767 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2768 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2769 | ) |
| 2770 | { |
| 2771 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2772 | if (token == NULL) { |
| 2773 | return NULL; |
| 2774 | } |
| 2775 | int end_lineno = token->end_lineno; |
| 2776 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2777 | int end_col_offset = token->end_col_offset; |
| 2778 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2779 | res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2780 | if (res == NULL && PyErr_Occurred()) { |
| 2781 | p->error_indicator = 1; |
| 2782 | return NULL; |
| 2783 | } |
| 2784 | goto done; |
| 2785 | } |
| 2786 | p->mark = mark; |
| 2787 | } |
| 2788 | { // 'elif' named_expression ':' block else_block? |
| 2789 | expr_ty a; |
| 2790 | asdl_seq* b; |
| 2791 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2792 | Token * keyword; |
| 2793 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2794 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2795 | (keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
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 | (a = named_expression_rule(p)) // named_expression |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2802 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2803 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2804 | ) |
| 2805 | { |
| 2806 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2807 | if (token == NULL) { |
| 2808 | return NULL; |
| 2809 | } |
| 2810 | int end_lineno = token->end_lineno; |
| 2811 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2812 | int end_col_offset = token->end_col_offset; |
| 2813 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2814 | res = _Py_If ( a , b , c , EXTRA ); |
| 2815 | if (res == NULL && PyErr_Occurred()) { |
| 2816 | p->error_indicator = 1; |
| 2817 | return NULL; |
| 2818 | } |
| 2819 | goto done; |
| 2820 | } |
| 2821 | p->mark = mark; |
| 2822 | } |
| 2823 | res = NULL; |
| 2824 | done: |
| 2825 | return res; |
| 2826 | } |
| 2827 | |
| 2828 | // else_block: 'else' ':' block |
| 2829 | static asdl_seq* |
| 2830 | else_block_rule(Parser *p) |
| 2831 | { |
| 2832 | if (p->error_indicator) { |
| 2833 | return NULL; |
| 2834 | } |
| 2835 | asdl_seq* res = NULL; |
| 2836 | int mark = p->mark; |
| 2837 | { // 'else' ':' block |
| 2838 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2839 | Token * keyword; |
| 2840 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2841 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2842 | (keyword = _PyPegen_expect_token(p, 516)) // token='else' |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2845 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2846 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2847 | ) |
| 2848 | { |
| 2849 | res = b; |
| 2850 | if (res == NULL && PyErr_Occurred()) { |
| 2851 | p->error_indicator = 1; |
| 2852 | return NULL; |
| 2853 | } |
| 2854 | goto done; |
| 2855 | } |
| 2856 | p->mark = mark; |
| 2857 | } |
| 2858 | res = NULL; |
| 2859 | done: |
| 2860 | return res; |
| 2861 | } |
| 2862 | |
| 2863 | // while_stmt: 'while' named_expression ':' block else_block? |
| 2864 | static stmt_ty |
| 2865 | while_stmt_rule(Parser *p) |
| 2866 | { |
| 2867 | if (p->error_indicator) { |
| 2868 | return NULL; |
| 2869 | } |
| 2870 | stmt_ty res = NULL; |
| 2871 | int mark = p->mark; |
| 2872 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2873 | p->error_indicator = 1; |
| 2874 | return NULL; |
| 2875 | } |
| 2876 | int start_lineno = p->tokens[mark]->lineno; |
| 2877 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2878 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2879 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2880 | { // 'while' named_expression ':' block else_block? |
| 2881 | expr_ty a; |
| 2882 | asdl_seq* b; |
| 2883 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2884 | Token * keyword; |
| 2885 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2886 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2887 | (keyword = _PyPegen_expect_token(p, 512)) // token='while' |
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 | (a = named_expression_rule(p)) // named_expression |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2894 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2895 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2896 | ) |
| 2897 | { |
| 2898 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2899 | if (token == NULL) { |
| 2900 | return NULL; |
| 2901 | } |
| 2902 | int end_lineno = token->end_lineno; |
| 2903 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2904 | int end_col_offset = token->end_col_offset; |
| 2905 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2906 | res = _Py_While ( a , b , c , EXTRA ); |
| 2907 | if (res == NULL && PyErr_Occurred()) { |
| 2908 | p->error_indicator = 1; |
| 2909 | return NULL; |
| 2910 | } |
| 2911 | goto done; |
| 2912 | } |
| 2913 | p->mark = mark; |
| 2914 | } |
| 2915 | res = NULL; |
| 2916 | done: |
| 2917 | return res; |
| 2918 | } |
| 2919 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2920 | // for_stmt: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2921 | // | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
| 2922 | // | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2923 | static stmt_ty |
| 2924 | for_stmt_rule(Parser *p) |
| 2925 | { |
| 2926 | if (p->error_indicator) { |
| 2927 | return NULL; |
| 2928 | } |
| 2929 | stmt_ty res = NULL; |
| 2930 | int mark = p->mark; |
| 2931 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2932 | p->error_indicator = 1; |
| 2933 | return NULL; |
| 2934 | } |
| 2935 | int start_lineno = p->tokens[mark]->lineno; |
| 2936 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2937 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2938 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2939 | { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2940 | asdl_seq* b; |
| 2941 | void *el; |
| 2942 | expr_ty ex; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2943 | Token * keyword; |
| 2944 | Token * keyword_1; |
| 2945 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2946 | expr_ty t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2947 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2948 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2949 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
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 | (t = star_targets_rule(p)) // star_targets |
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 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
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 | (ex = star_expressions_rule(p)) // star_expressions |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
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 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2962 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2963 | (el = else_block_rule(p), 1) // else_block? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2964 | ) |
| 2965 | { |
| 2966 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2967 | if (token == NULL) { |
| 2968 | return NULL; |
| 2969 | } |
| 2970 | int end_lineno = token->end_lineno; |
| 2971 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2972 | int end_col_offset = token->end_col_offset; |
| 2973 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2974 | res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 2975 | if (res == NULL && PyErr_Occurred()) { |
| 2976 | p->error_indicator = 1; |
| 2977 | return NULL; |
| 2978 | } |
| 2979 | goto done; |
| 2980 | } |
| 2981 | p->mark = mark; |
| 2982 | } |
| 2983 | { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2984 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2985 | asdl_seq* b; |
| 2986 | void *el; |
| 2987 | expr_ty ex; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2988 | Token * keyword; |
| 2989 | Token * keyword_1; |
| 2990 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2991 | expr_ty t; |
| 2992 | void *tc; |
| 2993 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2994 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
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 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
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 | (t = star_targets_rule(p)) // star_targets |
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 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
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 | (ex = star_expressions_rule(p)) // star_expressions |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3005 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3006 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3007 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3008 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3009 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3010 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3011 | ) |
| 3012 | { |
| 3013 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3014 | if (token == NULL) { |
| 3015 | return NULL; |
| 3016 | } |
| 3017 | int end_lineno = token->end_lineno; |
| 3018 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3019 | int end_col_offset = token->end_col_offset; |
| 3020 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3021 | 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] | 3022 | if (res == NULL && PyErr_Occurred()) { |
| 3023 | p->error_indicator = 1; |
| 3024 | return NULL; |
| 3025 | } |
| 3026 | goto done; |
| 3027 | } |
| 3028 | p->mark = mark; |
| 3029 | } |
| 3030 | res = NULL; |
| 3031 | done: |
| 3032 | return res; |
| 3033 | } |
| 3034 | |
| 3035 | // with_stmt: |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3036 | // | 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3037 | // | 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3038 | // | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3039 | // | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3040 | static stmt_ty |
| 3041 | with_stmt_rule(Parser *p) |
| 3042 | { |
| 3043 | if (p->error_indicator) { |
| 3044 | return NULL; |
| 3045 | } |
| 3046 | stmt_ty res = NULL; |
| 3047 | int mark = p->mark; |
| 3048 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3049 | p->error_indicator = 1; |
| 3050 | return NULL; |
| 3051 | } |
| 3052 | int start_lineno = p->tokens[mark]->lineno; |
| 3053 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3054 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3055 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3056 | { // 'with' '(' ','.with_item+ ','? ')' ':' block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3057 | asdl_seq * a; |
| 3058 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3059 | Token * keyword; |
| 3060 | Token * literal; |
| 3061 | Token * literal_1; |
| 3062 | Token * literal_2; |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3063 | void *opt_var; |
| 3064 | UNUSED(opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3065 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3066 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
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 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (a = _gather_38_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3071 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3072 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3073 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3074 | (literal_1 = _PyPegen_expect_token(p, 8)) // 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 | (literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3077 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3078 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3079 | ) |
| 3080 | { |
| 3081 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3082 | if (token == NULL) { |
| 3083 | return NULL; |
| 3084 | } |
| 3085 | int end_lineno = token->end_lineno; |
| 3086 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3087 | int end_col_offset = token->end_col_offset; |
| 3088 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3089 | res = _Py_With ( a , b , NULL , EXTRA ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3090 | if (res == NULL && PyErr_Occurred()) { |
| 3091 | p->error_indicator = 1; |
| 3092 | return NULL; |
| 3093 | } |
| 3094 | goto done; |
| 3095 | } |
| 3096 | p->mark = mark; |
| 3097 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3098 | { // 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3099 | asdl_seq * a; |
| 3100 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3101 | Token * keyword; |
| 3102 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3103 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3104 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3105 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
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 | (a = _gather_40_rule(p)) // ','.with_item+ |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3110 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3111 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3112 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3113 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3114 | ) |
| 3115 | { |
| 3116 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3117 | if (token == NULL) { |
| 3118 | return NULL; |
| 3119 | } |
| 3120 | int end_lineno = token->end_lineno; |
| 3121 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3122 | int end_col_offset = token->end_col_offset; |
| 3123 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3124 | res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3125 | if (res == NULL && PyErr_Occurred()) { |
| 3126 | p->error_indicator = 1; |
| 3127 | return NULL; |
| 3128 | } |
| 3129 | goto done; |
| 3130 | } |
| 3131 | p->mark = mark; |
| 3132 | } |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3133 | { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3134 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3135 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3136 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3137 | Token * keyword; |
| 3138 | Token * literal; |
| 3139 | Token * literal_1; |
| 3140 | Token * literal_2; |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3141 | void *opt_var; |
| 3142 | UNUSED(opt_var); // Silence compiler warnings |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3143 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3144 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
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 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
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 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (a = _gather_42_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3151 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3152 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3153 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3154 | (literal_1 = _PyPegen_expect_token(p, 8)) // 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 | (literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3157 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3158 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3159 | ) |
| 3160 | { |
| 3161 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3162 | if (token == NULL) { |
| 3163 | return NULL; |
| 3164 | } |
| 3165 | int end_lineno = token->end_lineno; |
| 3166 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3167 | int end_col_offset = token->end_col_offset; |
| 3168 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3169 | res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) ); |
| 3170 | if (res == NULL && PyErr_Occurred()) { |
| 3171 | p->error_indicator = 1; |
| 3172 | return NULL; |
| 3173 | } |
| 3174 | goto done; |
| 3175 | } |
| 3176 | p->mark = mark; |
| 3177 | } |
| 3178 | { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
| 3179 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3180 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3181 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3182 | Token * keyword; |
| 3183 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3184 | void *tc; |
| 3185 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3186 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
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 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
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 | (a = _gather_44_rule(p)) // ','.with_item+ |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3195 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3196 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3197 | ) |
| 3198 | { |
| 3199 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3200 | if (token == NULL) { |
| 3201 | return NULL; |
| 3202 | } |
| 3203 | int end_lineno = token->end_lineno; |
| 3204 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3205 | int end_col_offset = token->end_col_offset; |
| 3206 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3207 | 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] | 3208 | if (res == NULL && PyErr_Occurred()) { |
| 3209 | p->error_indicator = 1; |
| 3210 | return NULL; |
| 3211 | } |
| 3212 | goto done; |
| 3213 | } |
| 3214 | p->mark = mark; |
| 3215 | } |
| 3216 | res = NULL; |
| 3217 | done: |
| 3218 | return res; |
| 3219 | } |
| 3220 | |
| 3221 | // with_item: expression ['as' target] |
| 3222 | static withitem_ty |
| 3223 | with_item_rule(Parser *p) |
| 3224 | { |
| 3225 | if (p->error_indicator) { |
| 3226 | return NULL; |
| 3227 | } |
| 3228 | withitem_ty res = NULL; |
| 3229 | int mark = p->mark; |
| 3230 | { // expression ['as' target] |
| 3231 | expr_ty e; |
| 3232 | void *o; |
| 3233 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3234 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3235 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3236 | (o = _tmp_46_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3237 | ) |
| 3238 | { |
| 3239 | res = _Py_withitem ( e , o , p -> arena ); |
| 3240 | if (res == NULL && PyErr_Occurred()) { |
| 3241 | p->error_indicator = 1; |
| 3242 | return NULL; |
| 3243 | } |
| 3244 | goto done; |
| 3245 | } |
| 3246 | p->mark = mark; |
| 3247 | } |
| 3248 | res = NULL; |
| 3249 | done: |
| 3250 | return res; |
| 3251 | } |
| 3252 | |
| 3253 | // try_stmt: |
| 3254 | // | 'try' ':' block finally_block |
| 3255 | // | 'try' ':' block except_block+ else_block? finally_block? |
| 3256 | static stmt_ty |
| 3257 | try_stmt_rule(Parser *p) |
| 3258 | { |
| 3259 | if (p->error_indicator) { |
| 3260 | return NULL; |
| 3261 | } |
| 3262 | stmt_ty res = NULL; |
| 3263 | int mark = p->mark; |
| 3264 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3265 | p->error_indicator = 1; |
| 3266 | return NULL; |
| 3267 | } |
| 3268 | int start_lineno = p->tokens[mark]->lineno; |
| 3269 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3270 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3271 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3272 | { // 'try' ':' block finally_block |
| 3273 | asdl_seq* b; |
| 3274 | asdl_seq* f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3275 | Token * keyword; |
| 3276 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3277 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3278 | (keyword = _PyPegen_expect_token(p, 511)) // token='try' |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3283 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3284 | (f = finally_block_rule(p)) // finally_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3285 | ) |
| 3286 | { |
| 3287 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3288 | if (token == NULL) { |
| 3289 | return NULL; |
| 3290 | } |
| 3291 | int end_lineno = token->end_lineno; |
| 3292 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3293 | int end_col_offset = token->end_col_offset; |
| 3294 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3295 | res = _Py_Try ( b , NULL , NULL , f , EXTRA ); |
| 3296 | if (res == NULL && PyErr_Occurred()) { |
| 3297 | p->error_indicator = 1; |
| 3298 | return NULL; |
| 3299 | } |
| 3300 | goto done; |
| 3301 | } |
| 3302 | p->mark = mark; |
| 3303 | } |
| 3304 | { // 'try' ':' block except_block+ else_block? finally_block? |
| 3305 | asdl_seq* b; |
| 3306 | void *el; |
| 3307 | asdl_seq * ex; |
| 3308 | void *f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3309 | Token * keyword; |
| 3310 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3311 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3312 | (keyword = _PyPegen_expect_token(p, 511)) // token='try' |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = block_rule(p)) // 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 | (ex = _loop1_47_rule(p)) // except_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 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3321 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3322 | (f = finally_block_rule(p), 1) // finally_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3323 | ) |
| 3324 | { |
| 3325 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3326 | if (token == NULL) { |
| 3327 | return NULL; |
| 3328 | } |
| 3329 | int end_lineno = token->end_lineno; |
| 3330 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3331 | int end_col_offset = token->end_col_offset; |
| 3332 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3333 | res = _Py_Try ( b , ex , el , f , EXTRA ); |
| 3334 | if (res == NULL && PyErr_Occurred()) { |
| 3335 | p->error_indicator = 1; |
| 3336 | return NULL; |
| 3337 | } |
| 3338 | goto done; |
| 3339 | } |
| 3340 | p->mark = mark; |
| 3341 | } |
| 3342 | res = NULL; |
| 3343 | done: |
| 3344 | return res; |
| 3345 | } |
| 3346 | |
| 3347 | // except_block: 'except' expression ['as' target] ':' block | 'except' ':' block |
| 3348 | static excepthandler_ty |
| 3349 | except_block_rule(Parser *p) |
| 3350 | { |
| 3351 | if (p->error_indicator) { |
| 3352 | return NULL; |
| 3353 | } |
| 3354 | excepthandler_ty res = NULL; |
| 3355 | int mark = p->mark; |
| 3356 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3357 | p->error_indicator = 1; |
| 3358 | return NULL; |
| 3359 | } |
| 3360 | int start_lineno = p->tokens[mark]->lineno; |
| 3361 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3362 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3363 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3364 | { // 'except' expression ['as' target] ':' block |
| 3365 | asdl_seq* b; |
| 3366 | expr_ty e; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3367 | Token * keyword; |
| 3368 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3369 | void *t; |
| 3370 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3371 | (keyword = _PyPegen_expect_token(p, 520)) // token='except' |
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 | (e = expression_rule(p)) // expression |
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 | (t = _tmp_48_rule(p), 1) // ['as' target] |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3378 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3379 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3380 | ) |
| 3381 | { |
| 3382 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3383 | if (token == NULL) { |
| 3384 | return NULL; |
| 3385 | } |
| 3386 | int end_lineno = token->end_lineno; |
| 3387 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3388 | int end_col_offset = token->end_col_offset; |
| 3389 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3390 | res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA ); |
| 3391 | if (res == NULL && PyErr_Occurred()) { |
| 3392 | p->error_indicator = 1; |
| 3393 | return NULL; |
| 3394 | } |
| 3395 | goto done; |
| 3396 | } |
| 3397 | p->mark = mark; |
| 3398 | } |
| 3399 | { // 'except' ':' block |
| 3400 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3401 | Token * keyword; |
| 3402 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3403 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3404 | (keyword = _PyPegen_expect_token(p, 520)) // token='except' |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3407 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3408 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3409 | ) |
| 3410 | { |
| 3411 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3412 | if (token == NULL) { |
| 3413 | return NULL; |
| 3414 | } |
| 3415 | int end_lineno = token->end_lineno; |
| 3416 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3417 | int end_col_offset = token->end_col_offset; |
| 3418 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3419 | res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA ); |
| 3420 | if (res == NULL && PyErr_Occurred()) { |
| 3421 | p->error_indicator = 1; |
| 3422 | return NULL; |
| 3423 | } |
| 3424 | goto done; |
| 3425 | } |
| 3426 | p->mark = mark; |
| 3427 | } |
| 3428 | res = NULL; |
| 3429 | done: |
| 3430 | return res; |
| 3431 | } |
| 3432 | |
| 3433 | // finally_block: 'finally' ':' block |
| 3434 | static asdl_seq* |
| 3435 | finally_block_rule(Parser *p) |
| 3436 | { |
| 3437 | if (p->error_indicator) { |
| 3438 | return NULL; |
| 3439 | } |
| 3440 | asdl_seq* res = NULL; |
| 3441 | int mark = p->mark; |
| 3442 | { // 'finally' ':' block |
| 3443 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3444 | Token * keyword; |
| 3445 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3446 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3447 | (keyword = _PyPegen_expect_token(p, 521)) // token='finally' |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3450 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3451 | (a = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3452 | ) |
| 3453 | { |
| 3454 | res = a; |
| 3455 | if (res == NULL && PyErr_Occurred()) { |
| 3456 | p->error_indicator = 1; |
| 3457 | return NULL; |
| 3458 | } |
| 3459 | goto done; |
| 3460 | } |
| 3461 | p->mark = mark; |
| 3462 | } |
| 3463 | res = NULL; |
| 3464 | done: |
| 3465 | return res; |
| 3466 | } |
| 3467 | |
| 3468 | // return_stmt: 'return' star_expressions? |
| 3469 | static stmt_ty |
| 3470 | return_stmt_rule(Parser *p) |
| 3471 | { |
| 3472 | if (p->error_indicator) { |
| 3473 | return NULL; |
| 3474 | } |
| 3475 | stmt_ty res = NULL; |
| 3476 | int mark = p->mark; |
| 3477 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3478 | p->error_indicator = 1; |
| 3479 | return NULL; |
| 3480 | } |
| 3481 | int start_lineno = p->tokens[mark]->lineno; |
| 3482 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3483 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3484 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3485 | { // 'return' star_expressions? |
| 3486 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3487 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3488 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3489 | (keyword = _PyPegen_expect_token(p, 500)) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3490 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3491 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3492 | ) |
| 3493 | { |
| 3494 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3495 | if (token == NULL) { |
| 3496 | return NULL; |
| 3497 | } |
| 3498 | int end_lineno = token->end_lineno; |
| 3499 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3500 | int end_col_offset = token->end_col_offset; |
| 3501 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3502 | res = _Py_Return ( a , EXTRA ); |
| 3503 | if (res == NULL && PyErr_Occurred()) { |
| 3504 | p->error_indicator = 1; |
| 3505 | return NULL; |
| 3506 | } |
| 3507 | goto done; |
| 3508 | } |
| 3509 | p->mark = mark; |
| 3510 | } |
| 3511 | res = NULL; |
| 3512 | done: |
| 3513 | return res; |
| 3514 | } |
| 3515 | |
| 3516 | // raise_stmt: 'raise' expression ['from' expression] | 'raise' |
| 3517 | static stmt_ty |
| 3518 | raise_stmt_rule(Parser *p) |
| 3519 | { |
| 3520 | if (p->error_indicator) { |
| 3521 | return NULL; |
| 3522 | } |
| 3523 | stmt_ty res = NULL; |
| 3524 | int mark = p->mark; |
| 3525 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3526 | p->error_indicator = 1; |
| 3527 | return NULL; |
| 3528 | } |
| 3529 | int start_lineno = p->tokens[mark]->lineno; |
| 3530 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3531 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3532 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3533 | { // 'raise' expression ['from' expression] |
| 3534 | expr_ty a; |
| 3535 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3536 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3537 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3538 | (keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
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 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3541 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3542 | (b = _tmp_49_rule(p), 1) // ['from' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3543 | ) |
| 3544 | { |
| 3545 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3546 | if (token == NULL) { |
| 3547 | return NULL; |
| 3548 | } |
| 3549 | int end_lineno = token->end_lineno; |
| 3550 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3551 | int end_col_offset = token->end_col_offset; |
| 3552 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3553 | res = _Py_Raise ( a , b , EXTRA ); |
| 3554 | if (res == NULL && PyErr_Occurred()) { |
| 3555 | p->error_indicator = 1; |
| 3556 | return NULL; |
| 3557 | } |
| 3558 | goto done; |
| 3559 | } |
| 3560 | p->mark = mark; |
| 3561 | } |
| 3562 | { // 'raise' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3563 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3564 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3565 | (keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3566 | ) |
| 3567 | { |
| 3568 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3569 | if (token == NULL) { |
| 3570 | return NULL; |
| 3571 | } |
| 3572 | int end_lineno = token->end_lineno; |
| 3573 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3574 | int end_col_offset = token->end_col_offset; |
| 3575 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3576 | res = _Py_Raise ( NULL , NULL , EXTRA ); |
| 3577 | if (res == NULL && PyErr_Occurred()) { |
| 3578 | p->error_indicator = 1; |
| 3579 | return NULL; |
| 3580 | } |
| 3581 | goto done; |
| 3582 | } |
| 3583 | p->mark = mark; |
| 3584 | } |
| 3585 | res = NULL; |
| 3586 | done: |
| 3587 | return res; |
| 3588 | } |
| 3589 | |
| 3590 | // function_def: decorators function_def_raw | function_def_raw |
| 3591 | static stmt_ty |
| 3592 | function_def_rule(Parser *p) |
| 3593 | { |
| 3594 | if (p->error_indicator) { |
| 3595 | return NULL; |
| 3596 | } |
| 3597 | stmt_ty res = NULL; |
| 3598 | int mark = p->mark; |
| 3599 | { // decorators function_def_raw |
| 3600 | asdl_seq* d; |
| 3601 | stmt_ty f; |
| 3602 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3603 | (d = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3604 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3605 | (f = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3606 | ) |
| 3607 | { |
| 3608 | res = _PyPegen_function_def_decorators ( p , d , f ); |
| 3609 | if (res == NULL && PyErr_Occurred()) { |
| 3610 | p->error_indicator = 1; |
| 3611 | return NULL; |
| 3612 | } |
| 3613 | goto done; |
| 3614 | } |
| 3615 | p->mark = mark; |
| 3616 | } |
| 3617 | { // function_def_raw |
| 3618 | stmt_ty function_def_raw_var; |
| 3619 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3620 | (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3621 | ) |
| 3622 | { |
| 3623 | res = function_def_raw_var; |
| 3624 | goto done; |
| 3625 | } |
| 3626 | p->mark = mark; |
| 3627 | } |
| 3628 | res = NULL; |
| 3629 | done: |
| 3630 | return res; |
| 3631 | } |
| 3632 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3633 | // function_def_raw: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3634 | // | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3635 | // | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3636 | static stmt_ty |
| 3637 | function_def_raw_rule(Parser *p) |
| 3638 | { |
| 3639 | if (p->error_indicator) { |
| 3640 | return NULL; |
| 3641 | } |
| 3642 | stmt_ty res = NULL; |
| 3643 | int mark = p->mark; |
| 3644 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3645 | p->error_indicator = 1; |
| 3646 | return NULL; |
| 3647 | } |
| 3648 | int start_lineno = p->tokens[mark]->lineno; |
| 3649 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3650 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3651 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3652 | { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3653 | void *a; |
| 3654 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3655 | Token * keyword; |
| 3656 | Token * literal; |
| 3657 | Token * literal_1; |
| 3658 | Token * literal_2; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3659 | expr_ty n; |
| 3660 | void *params; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3661 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3662 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3663 | (keyword = _PyPegen_expect_token(p, 522)) // token='def' |
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 | (n = _PyPegen_name_token(p)) // NAME |
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 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (params = params_rule(p), 1) // params? |
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 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3672 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3673 | (a = _tmp_50_rule(p), 1) // ['->' expression] |
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 | (literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3676 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3677 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3678 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3679 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3680 | ) |
| 3681 | { |
| 3682 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3683 | if (token == NULL) { |
| 3684 | return NULL; |
| 3685 | } |
| 3686 | int end_lineno = token->end_lineno; |
| 3687 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3688 | int end_col_offset = token->end_col_offset; |
| 3689 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3690 | res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3691 | if (res == NULL && PyErr_Occurred()) { |
| 3692 | p->error_indicator = 1; |
| 3693 | return NULL; |
| 3694 | } |
| 3695 | goto done; |
| 3696 | } |
| 3697 | p->mark = mark; |
| 3698 | } |
| 3699 | { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3700 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3701 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3702 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3703 | Token * keyword; |
| 3704 | Token * literal; |
| 3705 | Token * literal_1; |
| 3706 | Token * literal_2; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3707 | expr_ty n; |
| 3708 | void *params; |
| 3709 | void *tc; |
| 3710 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3711 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
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 | (keyword = _PyPegen_expect_token(p, 522)) // token='def' |
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 | (n = _PyPegen_name_token(p)) // NAME |
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 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (params = params_rule(p), 1) // params? |
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 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3722 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3723 | (a = _tmp_51_rule(p), 1) // ['->' expression] |
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 | (literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3726 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3727 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3728 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3729 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3730 | ) |
| 3731 | { |
| 3732 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3733 | if (token == NULL) { |
| 3734 | return NULL; |
| 3735 | } |
| 3736 | int end_lineno = token->end_lineno; |
| 3737 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3738 | int end_col_offset = token->end_col_offset; |
| 3739 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3740 | 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] | 3741 | if (res == NULL && PyErr_Occurred()) { |
| 3742 | p->error_indicator = 1; |
| 3743 | return NULL; |
| 3744 | } |
| 3745 | goto done; |
| 3746 | } |
| 3747 | p->mark = mark; |
| 3748 | } |
| 3749 | res = NULL; |
| 3750 | done: |
| 3751 | return res; |
| 3752 | } |
| 3753 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3754 | // func_type_comment: |
| 3755 | // | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 3756 | // | invalid_double_type_comments |
| 3757 | // | TYPE_COMMENT |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 3758 | static Token* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3759 | func_type_comment_rule(Parser *p) |
| 3760 | { |
| 3761 | if (p->error_indicator) { |
| 3762 | return NULL; |
| 3763 | } |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 3764 | Token* res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3765 | int mark = p->mark; |
| 3766 | { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3767 | Token * newline_var; |
| 3768 | Token * t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3769 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3770 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3771 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3772 | (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3773 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3774 | _PyPegen_lookahead(1, _tmp_52_rule, p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3775 | ) |
| 3776 | { |
| 3777 | res = t; |
| 3778 | if (res == NULL && PyErr_Occurred()) { |
| 3779 | p->error_indicator = 1; |
| 3780 | return NULL; |
| 3781 | } |
| 3782 | goto done; |
| 3783 | } |
| 3784 | p->mark = mark; |
| 3785 | } |
| 3786 | { // invalid_double_type_comments |
| 3787 | void *invalid_double_type_comments_var; |
| 3788 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3789 | (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] | 3790 | ) |
| 3791 | { |
| 3792 | res = invalid_double_type_comments_var; |
| 3793 | goto done; |
| 3794 | } |
| 3795 | p->mark = mark; |
| 3796 | } |
| 3797 | { // TYPE_COMMENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3798 | Token * type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3799 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3800 | (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] | 3801 | ) |
| 3802 | { |
| 3803 | res = type_comment_var; |
| 3804 | goto done; |
| 3805 | } |
| 3806 | p->mark = mark; |
| 3807 | } |
| 3808 | res = NULL; |
| 3809 | done: |
| 3810 | return res; |
| 3811 | } |
| 3812 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3813 | // params: invalid_parameters | parameters |
| 3814 | static arguments_ty |
| 3815 | params_rule(Parser *p) |
| 3816 | { |
| 3817 | if (p->error_indicator) { |
| 3818 | return NULL; |
| 3819 | } |
| 3820 | arguments_ty res = NULL; |
| 3821 | int mark = p->mark; |
| 3822 | { // invalid_parameters |
| 3823 | void *invalid_parameters_var; |
| 3824 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3825 | (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3826 | ) |
| 3827 | { |
| 3828 | res = invalid_parameters_var; |
| 3829 | goto done; |
| 3830 | } |
| 3831 | p->mark = mark; |
| 3832 | } |
| 3833 | { // parameters |
| 3834 | arguments_ty parameters_var; |
| 3835 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3836 | (parameters_var = parameters_rule(p)) // parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3837 | ) |
| 3838 | { |
| 3839 | res = parameters_var; |
| 3840 | goto done; |
| 3841 | } |
| 3842 | p->mark = mark; |
| 3843 | } |
| 3844 | res = NULL; |
| 3845 | done: |
| 3846 | return res; |
| 3847 | } |
| 3848 | |
| 3849 | // parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3850 | // | slash_no_default param_no_default* param_with_default* star_etc? |
| 3851 | // | slash_with_default param_with_default* star_etc? |
| 3852 | // | param_no_default+ param_with_default* star_etc? |
| 3853 | // | param_with_default+ star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3854 | // | star_etc |
| 3855 | static arguments_ty |
| 3856 | parameters_rule(Parser *p) |
| 3857 | { |
| 3858 | if (p->error_indicator) { |
| 3859 | return NULL; |
| 3860 | } |
| 3861 | arguments_ty res = NULL; |
| 3862 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3863 | { // slash_no_default param_no_default* param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3864 | asdl_seq* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3865 | asdl_seq * b; |
| 3866 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3867 | void *d; |
| 3868 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3869 | (a = slash_no_default_rule(p)) // slash_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 | (b = _loop0_53_rule(p)) // param_no_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 | (c = _loop0_54_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3874 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3875 | (d = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3876 | ) |
| 3877 | { |
| 3878 | res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 3879 | if (res == NULL && PyErr_Occurred()) { |
| 3880 | p->error_indicator = 1; |
| 3881 | return NULL; |
| 3882 | } |
| 3883 | goto done; |
| 3884 | } |
| 3885 | p->mark = mark; |
| 3886 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3887 | { // slash_with_default param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3888 | SlashWithDefault* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3889 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3890 | void *c; |
| 3891 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3892 | (a = slash_with_default_rule(p)) // slash_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 | (b = _loop0_55_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3895 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3896 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3897 | ) |
| 3898 | { |
| 3899 | res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 3900 | if (res == NULL && PyErr_Occurred()) { |
| 3901 | p->error_indicator = 1; |
| 3902 | return NULL; |
| 3903 | } |
| 3904 | goto done; |
| 3905 | } |
| 3906 | p->mark = mark; |
| 3907 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3908 | { // param_no_default+ param_with_default* star_etc? |
| 3909 | asdl_seq * a; |
| 3910 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3911 | void *c; |
| 3912 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3913 | (a = _loop1_56_rule(p)) // param_no_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 | (b = _loop0_57_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3916 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3917 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3918 | ) |
| 3919 | { |
| 3920 | res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 3921 | if (res == NULL && PyErr_Occurred()) { |
| 3922 | p->error_indicator = 1; |
| 3923 | return NULL; |
| 3924 | } |
| 3925 | goto done; |
| 3926 | } |
| 3927 | p->mark = mark; |
| 3928 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3929 | { // param_with_default+ star_etc? |
| 3930 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3931 | void *b; |
| 3932 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3933 | (a = _loop1_58_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3934 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3935 | (b = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3936 | ) |
| 3937 | { |
| 3938 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 3939 | if (res == NULL && PyErr_Occurred()) { |
| 3940 | p->error_indicator = 1; |
| 3941 | return NULL; |
| 3942 | } |
| 3943 | goto done; |
| 3944 | } |
| 3945 | p->mark = mark; |
| 3946 | } |
| 3947 | { // star_etc |
| 3948 | StarEtc* a; |
| 3949 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3950 | (a = star_etc_rule(p)) // star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3951 | ) |
| 3952 | { |
| 3953 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 3954 | if (res == NULL && PyErr_Occurred()) { |
| 3955 | p->error_indicator = 1; |
| 3956 | return NULL; |
| 3957 | } |
| 3958 | goto done; |
| 3959 | } |
| 3960 | p->mark = mark; |
| 3961 | } |
| 3962 | res = NULL; |
| 3963 | done: |
| 3964 | return res; |
| 3965 | } |
| 3966 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3967 | // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3968 | static asdl_seq* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3969 | slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3970 | { |
| 3971 | if (p->error_indicator) { |
| 3972 | return NULL; |
| 3973 | } |
| 3974 | asdl_seq* res = NULL; |
| 3975 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3976 | { // param_no_default+ '/' ',' |
| 3977 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3978 | Token * literal; |
| 3979 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3980 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3981 | (a = _loop1_59_rule(p)) // param_no_default+ |
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 = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3984 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3985 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3986 | ) |
| 3987 | { |
| 3988 | res = a; |
| 3989 | if (res == NULL && PyErr_Occurred()) { |
| 3990 | p->error_indicator = 1; |
| 3991 | return NULL; |
| 3992 | } |
| 3993 | goto done; |
| 3994 | } |
| 3995 | p->mark = mark; |
| 3996 | } |
| 3997 | { // param_no_default+ '/' &')' |
| 3998 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3999 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4000 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4001 | (a = _loop1_60_rule(p)) // param_no_default+ |
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 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4004 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4005 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4006 | ) |
| 4007 | { |
| 4008 | res = a; |
| 4009 | if (res == NULL && PyErr_Occurred()) { |
| 4010 | p->error_indicator = 1; |
| 4011 | return NULL; |
| 4012 | } |
| 4013 | goto done; |
| 4014 | } |
| 4015 | p->mark = mark; |
| 4016 | } |
| 4017 | res = NULL; |
| 4018 | done: |
| 4019 | return res; |
| 4020 | } |
| 4021 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4022 | // slash_with_default: |
| 4023 | // | param_no_default* param_with_default+ '/' ',' |
| 4024 | // | param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4025 | static SlashWithDefault* |
| 4026 | slash_with_default_rule(Parser *p) |
| 4027 | { |
| 4028 | if (p->error_indicator) { |
| 4029 | return NULL; |
| 4030 | } |
| 4031 | SlashWithDefault* res = NULL; |
| 4032 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4033 | { // param_no_default* param_with_default+ '/' ',' |
| 4034 | asdl_seq * a; |
| 4035 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4036 | Token * literal; |
| 4037 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4038 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4039 | (a = _loop0_61_rule(p)) // param_no_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 | (b = _loop1_62_rule(p)) // param_with_default+ |
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 = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4044 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4045 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4046 | ) |
| 4047 | { |
| 4048 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 4049 | if (res == NULL && PyErr_Occurred()) { |
| 4050 | p->error_indicator = 1; |
| 4051 | return NULL; |
| 4052 | } |
| 4053 | goto done; |
| 4054 | } |
| 4055 | p->mark = mark; |
| 4056 | } |
| 4057 | { // param_no_default* param_with_default+ '/' &')' |
| 4058 | asdl_seq * a; |
| 4059 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4060 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4061 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4062 | (a = _loop0_63_rule(p)) // param_no_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 | (b = _loop1_64_rule(p)) // param_with_default+ |
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 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4067 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4068 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4069 | ) |
| 4070 | { |
| 4071 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 4072 | if (res == NULL && PyErr_Occurred()) { |
| 4073 | p->error_indicator = 1; |
| 4074 | return NULL; |
| 4075 | } |
| 4076 | goto done; |
| 4077 | } |
| 4078 | p->mark = mark; |
| 4079 | } |
| 4080 | res = NULL; |
| 4081 | done: |
| 4082 | return res; |
| 4083 | } |
| 4084 | |
| 4085 | // star_etc: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4086 | // | '*' param_no_default param_maybe_default* kwds? |
| 4087 | // | '*' ',' param_maybe_default+ kwds? |
| 4088 | // | kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4089 | // | invalid_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4090 | static StarEtc* |
| 4091 | star_etc_rule(Parser *p) |
| 4092 | { |
| 4093 | if (p->error_indicator) { |
| 4094 | return NULL; |
| 4095 | } |
| 4096 | StarEtc* res = NULL; |
| 4097 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4098 | { // '*' param_no_default param_maybe_default* kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4099 | arg_ty a; |
| 4100 | asdl_seq * b; |
| 4101 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4102 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4103 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4104 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
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 | (a = param_no_default_rule(p)) // param_no_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 | (b = _loop0_65_rule(p)) // param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4109 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4110 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4111 | ) |
| 4112 | { |
| 4113 | res = _PyPegen_star_etc ( p , a , b , c ); |
| 4114 | if (res == NULL && PyErr_Occurred()) { |
| 4115 | p->error_indicator = 1; |
| 4116 | return NULL; |
| 4117 | } |
| 4118 | goto done; |
| 4119 | } |
| 4120 | p->mark = mark; |
| 4121 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4122 | { // '*' ',' param_maybe_default+ kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4123 | asdl_seq * b; |
| 4124 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4125 | Token * literal; |
| 4126 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4127 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4128 | (literal = _PyPegen_expect_token(p, 16)) // 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 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
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 | (b = _loop1_66_rule(p)) // param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4133 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4134 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4135 | ) |
| 4136 | { |
| 4137 | res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 4138 | if (res == NULL && PyErr_Occurred()) { |
| 4139 | p->error_indicator = 1; |
| 4140 | return NULL; |
| 4141 | } |
| 4142 | goto done; |
| 4143 | } |
| 4144 | p->mark = mark; |
| 4145 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4146 | { // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4147 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4148 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4149 | (a = kwds_rule(p)) // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4150 | ) |
| 4151 | { |
| 4152 | res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 4153 | if (res == NULL && PyErr_Occurred()) { |
| 4154 | p->error_indicator = 1; |
| 4155 | return NULL; |
| 4156 | } |
| 4157 | goto done; |
| 4158 | } |
| 4159 | p->mark = mark; |
| 4160 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4161 | { // invalid_star_etc |
| 4162 | void *invalid_star_etc_var; |
| 4163 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4164 | (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4165 | ) |
| 4166 | { |
| 4167 | res = invalid_star_etc_var; |
| 4168 | goto done; |
| 4169 | } |
| 4170 | p->mark = mark; |
| 4171 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4172 | res = NULL; |
| 4173 | done: |
| 4174 | return res; |
| 4175 | } |
| 4176 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4177 | // kwds: '**' param_no_default |
| 4178 | static arg_ty |
| 4179 | kwds_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4180 | { |
| 4181 | if (p->error_indicator) { |
| 4182 | return NULL; |
| 4183 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4184 | arg_ty res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4185 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4186 | { // '**' param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4187 | arg_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4188 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4189 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4190 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4191 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4192 | (a = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4193 | ) |
| 4194 | { |
| 4195 | res = a; |
| 4196 | if (res == NULL && PyErr_Occurred()) { |
| 4197 | p->error_indicator = 1; |
| 4198 | return NULL; |
| 4199 | } |
| 4200 | goto done; |
| 4201 | } |
| 4202 | p->mark = mark; |
| 4203 | } |
| 4204 | res = NULL; |
| 4205 | done: |
| 4206 | return res; |
| 4207 | } |
| 4208 | |
| 4209 | // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' |
| 4210 | static arg_ty |
| 4211 | param_no_default_rule(Parser *p) |
| 4212 | { |
| 4213 | if (p->error_indicator) { |
| 4214 | return NULL; |
| 4215 | } |
| 4216 | arg_ty res = NULL; |
| 4217 | int mark = p->mark; |
| 4218 | { // param ',' TYPE_COMMENT? |
| 4219 | arg_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4220 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4221 | void *tc; |
| 4222 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4223 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4224 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4225 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4226 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4227 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4228 | ) |
| 4229 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4230 | res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4231 | if (res == NULL && PyErr_Occurred()) { |
| 4232 | p->error_indicator = 1; |
| 4233 | return NULL; |
| 4234 | } |
| 4235 | goto done; |
| 4236 | } |
| 4237 | p->mark = mark; |
| 4238 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4239 | { // param TYPE_COMMENT? &')' |
| 4240 | arg_ty a; |
| 4241 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4242 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4243 | (a = param_rule(p)) // param |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4246 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4247 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4248 | ) |
| 4249 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4250 | res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4251 | if (res == NULL && PyErr_Occurred()) { |
| 4252 | p->error_indicator = 1; |
| 4253 | return NULL; |
| 4254 | } |
| 4255 | goto done; |
| 4256 | } |
| 4257 | p->mark = mark; |
| 4258 | } |
| 4259 | res = NULL; |
| 4260 | done: |
| 4261 | return res; |
| 4262 | } |
| 4263 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4264 | // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4265 | static NameDefaultPair* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4266 | param_with_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4267 | { |
| 4268 | if (p->error_indicator) { |
| 4269 | return NULL; |
| 4270 | } |
| 4271 | NameDefaultPair* res = NULL; |
| 4272 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4273 | { // param default ',' TYPE_COMMENT? |
| 4274 | arg_ty a; |
| 4275 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4276 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4277 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4278 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4279 | (a = param_rule(p)) // param |
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 | (c = default_rule(p)) // default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4282 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4283 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4284 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4285 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4286 | ) |
| 4287 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4288 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4289 | if (res == NULL && PyErr_Occurred()) { |
| 4290 | p->error_indicator = 1; |
| 4291 | return NULL; |
| 4292 | } |
| 4293 | goto done; |
| 4294 | } |
| 4295 | p->mark = mark; |
| 4296 | } |
| 4297 | { // param default TYPE_COMMENT? &')' |
| 4298 | arg_ty a; |
| 4299 | expr_ty c; |
| 4300 | void *tc; |
| 4301 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4302 | (a = param_rule(p)) // param |
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 | (c = default_rule(p)) // default |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4307 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4308 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4309 | ) |
| 4310 | { |
| 4311 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4312 | if (res == NULL && PyErr_Occurred()) { |
| 4313 | p->error_indicator = 1; |
| 4314 | return NULL; |
| 4315 | } |
| 4316 | goto done; |
| 4317 | } |
| 4318 | p->mark = mark; |
| 4319 | } |
| 4320 | res = NULL; |
| 4321 | done: |
| 4322 | return res; |
| 4323 | } |
| 4324 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4325 | // param_maybe_default: |
| 4326 | // | param default? ',' TYPE_COMMENT? |
| 4327 | // | param default? TYPE_COMMENT? &')' |
| 4328 | static NameDefaultPair* |
| 4329 | param_maybe_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4330 | { |
| 4331 | if (p->error_indicator) { |
| 4332 | return NULL; |
| 4333 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4334 | NameDefaultPair* res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4335 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4336 | { // param default? ',' TYPE_COMMENT? |
| 4337 | arg_ty a; |
| 4338 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4339 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4340 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4341 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4342 | (a = param_rule(p)) // param |
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 | (c = default_rule(p), 1) // default? |
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 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4347 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4348 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4349 | ) |
| 4350 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4351 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4352 | if (res == NULL && PyErr_Occurred()) { |
| 4353 | p->error_indicator = 1; |
| 4354 | return NULL; |
| 4355 | } |
| 4356 | goto done; |
| 4357 | } |
| 4358 | p->mark = mark; |
| 4359 | } |
| 4360 | { // param default? TYPE_COMMENT? &')' |
| 4361 | arg_ty a; |
| 4362 | void *c; |
| 4363 | void *tc; |
| 4364 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4365 | (a = param_rule(p)) // param |
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 | (c = default_rule(p), 1) // default? |
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 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4370 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4371 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4372 | ) |
| 4373 | { |
| 4374 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4375 | if (res == NULL && PyErr_Occurred()) { |
| 4376 | p->error_indicator = 1; |
| 4377 | return NULL; |
| 4378 | } |
| 4379 | goto done; |
| 4380 | } |
| 4381 | p->mark = mark; |
| 4382 | } |
| 4383 | res = NULL; |
| 4384 | done: |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4385 | return res; |
| 4386 | } |
| 4387 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4388 | // param: NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4389 | static arg_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4390 | param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4391 | { |
| 4392 | if (p->error_indicator) { |
| 4393 | return NULL; |
| 4394 | } |
| 4395 | arg_ty res = NULL; |
| 4396 | int mark = p->mark; |
| 4397 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4398 | p->error_indicator = 1; |
| 4399 | return NULL; |
| 4400 | } |
| 4401 | int start_lineno = p->tokens[mark]->lineno; |
| 4402 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4403 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4404 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4405 | { // NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4406 | expr_ty a; |
| 4407 | void *b; |
| 4408 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4409 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4410 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4411 | (b = annotation_rule(p), 1) // annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4412 | ) |
| 4413 | { |
| 4414 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4415 | if (token == NULL) { |
| 4416 | return NULL; |
| 4417 | } |
| 4418 | int end_lineno = token->end_lineno; |
| 4419 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4420 | int end_col_offset = token->end_col_offset; |
| 4421 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4422 | res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); |
| 4423 | if (res == NULL && PyErr_Occurred()) { |
| 4424 | p->error_indicator = 1; |
| 4425 | return NULL; |
| 4426 | } |
| 4427 | goto done; |
| 4428 | } |
| 4429 | p->mark = mark; |
| 4430 | } |
| 4431 | res = NULL; |
| 4432 | done: |
| 4433 | return res; |
| 4434 | } |
| 4435 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4436 | // annotation: ':' expression |
| 4437 | static expr_ty |
| 4438 | annotation_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4439 | { |
| 4440 | if (p->error_indicator) { |
| 4441 | return NULL; |
| 4442 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4443 | expr_ty res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4444 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4445 | { // ':' expression |
| 4446 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4447 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4448 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4449 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4450 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4451 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4452 | ) |
| 4453 | { |
| 4454 | res = a; |
| 4455 | if (res == NULL && PyErr_Occurred()) { |
| 4456 | p->error_indicator = 1; |
| 4457 | return NULL; |
| 4458 | } |
| 4459 | goto done; |
| 4460 | } |
| 4461 | p->mark = mark; |
| 4462 | } |
| 4463 | res = NULL; |
| 4464 | done: |
| 4465 | return res; |
| 4466 | } |
| 4467 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4468 | // default: '=' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4469 | static expr_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4470 | default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4471 | { |
| 4472 | if (p->error_indicator) { |
| 4473 | return NULL; |
| 4474 | } |
| 4475 | expr_ty res = NULL; |
| 4476 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4477 | { // '=' expression |
| 4478 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4479 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4480 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4481 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4482 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4483 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4484 | ) |
| 4485 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4486 | res = a; |
| 4487 | if (res == NULL && PyErr_Occurred()) { |
| 4488 | p->error_indicator = 1; |
| 4489 | return NULL; |
| 4490 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4491 | goto done; |
| 4492 | } |
| 4493 | p->mark = mark; |
| 4494 | } |
| 4495 | res = NULL; |
| 4496 | done: |
| 4497 | return res; |
| 4498 | } |
| 4499 | |
| 4500 | // decorators: (('@' named_expression NEWLINE))+ |
| 4501 | static asdl_seq* |
| 4502 | decorators_rule(Parser *p) |
| 4503 | { |
| 4504 | if (p->error_indicator) { |
| 4505 | return NULL; |
| 4506 | } |
| 4507 | asdl_seq* res = NULL; |
| 4508 | int mark = p->mark; |
| 4509 | { // (('@' named_expression NEWLINE))+ |
| 4510 | asdl_seq * a; |
| 4511 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4512 | (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4513 | ) |
| 4514 | { |
| 4515 | res = a; |
| 4516 | if (res == NULL && PyErr_Occurred()) { |
| 4517 | p->error_indicator = 1; |
| 4518 | return NULL; |
| 4519 | } |
| 4520 | goto done; |
| 4521 | } |
| 4522 | p->mark = mark; |
| 4523 | } |
| 4524 | res = NULL; |
| 4525 | done: |
| 4526 | return res; |
| 4527 | } |
| 4528 | |
| 4529 | // class_def: decorators class_def_raw | class_def_raw |
| 4530 | static stmt_ty |
| 4531 | class_def_rule(Parser *p) |
| 4532 | { |
| 4533 | if (p->error_indicator) { |
| 4534 | return NULL; |
| 4535 | } |
| 4536 | stmt_ty res = NULL; |
| 4537 | int mark = p->mark; |
| 4538 | { // decorators class_def_raw |
| 4539 | asdl_seq* a; |
| 4540 | stmt_ty b; |
| 4541 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4542 | (a = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4543 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4544 | (b = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4545 | ) |
| 4546 | { |
| 4547 | res = _PyPegen_class_def_decorators ( p , a , b ); |
| 4548 | if (res == NULL && PyErr_Occurred()) { |
| 4549 | p->error_indicator = 1; |
| 4550 | return NULL; |
| 4551 | } |
| 4552 | goto done; |
| 4553 | } |
| 4554 | p->mark = mark; |
| 4555 | } |
| 4556 | { // class_def_raw |
| 4557 | stmt_ty class_def_raw_var; |
| 4558 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4559 | (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4560 | ) |
| 4561 | { |
| 4562 | res = class_def_raw_var; |
| 4563 | goto done; |
| 4564 | } |
| 4565 | p->mark = mark; |
| 4566 | } |
| 4567 | res = NULL; |
| 4568 | done: |
| 4569 | return res; |
| 4570 | } |
| 4571 | |
| 4572 | // class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block |
| 4573 | static stmt_ty |
| 4574 | class_def_raw_rule(Parser *p) |
| 4575 | { |
| 4576 | if (p->error_indicator) { |
| 4577 | return NULL; |
| 4578 | } |
| 4579 | stmt_ty res = NULL; |
| 4580 | int mark = p->mark; |
| 4581 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4582 | p->error_indicator = 1; |
| 4583 | return NULL; |
| 4584 | } |
| 4585 | int start_lineno = p->tokens[mark]->lineno; |
| 4586 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4587 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4588 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4589 | { // 'class' NAME ['(' arguments? ')'] ':' block |
| 4590 | expr_ty a; |
| 4591 | void *b; |
| 4592 | asdl_seq* c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4593 | Token * keyword; |
| 4594 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4595 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4596 | (keyword = _PyPegen_expect_token(p, 523)) // token='class' |
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 | (a = _PyPegen_name_token(p)) // NAME |
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 | (b = _tmp_68_rule(p), 1) // ['(' arguments? ')'] |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4603 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4604 | (c = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4605 | ) |
| 4606 | { |
| 4607 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4608 | if (token == NULL) { |
| 4609 | return NULL; |
| 4610 | } |
| 4611 | int end_lineno = token->end_lineno; |
| 4612 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4613 | int end_col_offset = token->end_col_offset; |
| 4614 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4615 | 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 ); |
| 4616 | if (res == NULL && PyErr_Occurred()) { |
| 4617 | p->error_indicator = 1; |
| 4618 | return NULL; |
| 4619 | } |
| 4620 | goto done; |
| 4621 | } |
| 4622 | p->mark = mark; |
| 4623 | } |
| 4624 | res = NULL; |
| 4625 | done: |
| 4626 | return res; |
| 4627 | } |
| 4628 | |
| 4629 | // block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block |
| 4630 | static asdl_seq* |
| 4631 | block_rule(Parser *p) |
| 4632 | { |
| 4633 | if (p->error_indicator) { |
| 4634 | return NULL; |
| 4635 | } |
| 4636 | asdl_seq* res = NULL; |
| 4637 | if (_PyPegen_is_memoized(p, block_type, &res)) |
| 4638 | return res; |
| 4639 | int mark = p->mark; |
| 4640 | { // NEWLINE INDENT statements DEDENT |
| 4641 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4642 | Token * dedent_var; |
| 4643 | Token * indent_var; |
| 4644 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4645 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4646 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
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 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
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 | (a = statements_rule(p)) // statements |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4651 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4652 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4653 | ) |
| 4654 | { |
| 4655 | res = a; |
| 4656 | if (res == NULL && PyErr_Occurred()) { |
| 4657 | p->error_indicator = 1; |
| 4658 | return NULL; |
| 4659 | } |
| 4660 | goto done; |
| 4661 | } |
| 4662 | p->mark = mark; |
| 4663 | } |
| 4664 | { // simple_stmt |
| 4665 | asdl_seq* simple_stmt_var; |
| 4666 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4667 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4668 | ) |
| 4669 | { |
| 4670 | res = simple_stmt_var; |
| 4671 | goto done; |
| 4672 | } |
| 4673 | p->mark = mark; |
| 4674 | } |
| 4675 | { // invalid_block |
| 4676 | void *invalid_block_var; |
| 4677 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4678 | (invalid_block_var = invalid_block_rule(p)) // invalid_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4679 | ) |
| 4680 | { |
| 4681 | res = invalid_block_var; |
| 4682 | goto done; |
| 4683 | } |
| 4684 | p->mark = mark; |
| 4685 | } |
| 4686 | res = NULL; |
| 4687 | done: |
| 4688 | _PyPegen_insert_memo(p, mark, block_type, res); |
| 4689 | return res; |
| 4690 | } |
| 4691 | |
| 4692 | // expressions_list: ','.star_expression+ ','? |
| 4693 | static asdl_seq* |
| 4694 | expressions_list_rule(Parser *p) |
| 4695 | { |
| 4696 | if (p->error_indicator) { |
| 4697 | return NULL; |
| 4698 | } |
| 4699 | asdl_seq* res = NULL; |
| 4700 | int mark = p->mark; |
| 4701 | { // ','.star_expression+ ','? |
| 4702 | asdl_seq * a; |
| 4703 | void *opt_var; |
| 4704 | UNUSED(opt_var); // Silence compiler warnings |
| 4705 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4706 | (a = _gather_69_rule(p)) // ','.star_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4707 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4708 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4709 | ) |
| 4710 | { |
| 4711 | res = a; |
| 4712 | if (res == NULL && PyErr_Occurred()) { |
| 4713 | p->error_indicator = 1; |
| 4714 | return NULL; |
| 4715 | } |
| 4716 | goto done; |
| 4717 | } |
| 4718 | p->mark = mark; |
| 4719 | } |
| 4720 | res = NULL; |
| 4721 | done: |
| 4722 | return res; |
| 4723 | } |
| 4724 | |
| 4725 | // star_expressions: |
| 4726 | // | star_expression ((',' star_expression))+ ','? |
| 4727 | // | star_expression ',' |
| 4728 | // | star_expression |
| 4729 | static expr_ty |
| 4730 | star_expressions_rule(Parser *p) |
| 4731 | { |
| 4732 | if (p->error_indicator) { |
| 4733 | return NULL; |
| 4734 | } |
| 4735 | expr_ty res = NULL; |
| 4736 | int mark = p->mark; |
| 4737 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4738 | p->error_indicator = 1; |
| 4739 | return NULL; |
| 4740 | } |
| 4741 | int start_lineno = p->tokens[mark]->lineno; |
| 4742 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4743 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4744 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4745 | { // star_expression ((',' star_expression))+ ','? |
| 4746 | expr_ty a; |
| 4747 | asdl_seq * b; |
| 4748 | void *opt_var; |
| 4749 | UNUSED(opt_var); // Silence compiler warnings |
| 4750 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4751 | (a = star_expression_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 | (b = _loop1_71_rule(p)) // ((',' star_expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4754 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4755 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4756 | ) |
| 4757 | { |
| 4758 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4759 | if (token == NULL) { |
| 4760 | return NULL; |
| 4761 | } |
| 4762 | int end_lineno = token->end_lineno; |
| 4763 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4764 | int end_col_offset = token->end_col_offset; |
| 4765 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4766 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 4767 | if (res == NULL && PyErr_Occurred()) { |
| 4768 | p->error_indicator = 1; |
| 4769 | return NULL; |
| 4770 | } |
| 4771 | goto done; |
| 4772 | } |
| 4773 | p->mark = mark; |
| 4774 | } |
| 4775 | { // star_expression ',' |
| 4776 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4777 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4778 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4779 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4780 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4781 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4782 | ) |
| 4783 | { |
| 4784 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4785 | if (token == NULL) { |
| 4786 | return NULL; |
| 4787 | } |
| 4788 | int end_lineno = token->end_lineno; |
| 4789 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4790 | int end_col_offset = token->end_col_offset; |
| 4791 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4792 | res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 4793 | if (res == NULL && PyErr_Occurred()) { |
| 4794 | p->error_indicator = 1; |
| 4795 | return NULL; |
| 4796 | } |
| 4797 | goto done; |
| 4798 | } |
| 4799 | p->mark = mark; |
| 4800 | } |
| 4801 | { // star_expression |
| 4802 | expr_ty star_expression_var; |
| 4803 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4804 | (star_expression_var = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4805 | ) |
| 4806 | { |
| 4807 | res = star_expression_var; |
| 4808 | goto done; |
| 4809 | } |
| 4810 | p->mark = mark; |
| 4811 | } |
| 4812 | res = NULL; |
| 4813 | done: |
| 4814 | return res; |
| 4815 | } |
| 4816 | |
| 4817 | // star_expression: '*' bitwise_or | expression |
| 4818 | static expr_ty |
| 4819 | star_expression_rule(Parser *p) |
| 4820 | { |
| 4821 | if (p->error_indicator) { |
| 4822 | return NULL; |
| 4823 | } |
| 4824 | expr_ty res = NULL; |
| 4825 | if (_PyPegen_is_memoized(p, star_expression_type, &res)) |
| 4826 | return res; |
| 4827 | int mark = p->mark; |
| 4828 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4829 | p->error_indicator = 1; |
| 4830 | return NULL; |
| 4831 | } |
| 4832 | int start_lineno = p->tokens[mark]->lineno; |
| 4833 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4834 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4835 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4836 | { // '*' bitwise_or |
| 4837 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4838 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4839 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4840 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4841 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4842 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4843 | ) |
| 4844 | { |
| 4845 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4846 | if (token == NULL) { |
| 4847 | return NULL; |
| 4848 | } |
| 4849 | int end_lineno = token->end_lineno; |
| 4850 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4851 | int end_col_offset = token->end_col_offset; |
| 4852 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4853 | res = _Py_Starred ( a , Load , EXTRA ); |
| 4854 | if (res == NULL && PyErr_Occurred()) { |
| 4855 | p->error_indicator = 1; |
| 4856 | return NULL; |
| 4857 | } |
| 4858 | goto done; |
| 4859 | } |
| 4860 | p->mark = mark; |
| 4861 | } |
| 4862 | { // expression |
| 4863 | expr_ty expression_var; |
| 4864 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4865 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4866 | ) |
| 4867 | { |
| 4868 | res = expression_var; |
| 4869 | goto done; |
| 4870 | } |
| 4871 | p->mark = mark; |
| 4872 | } |
| 4873 | res = NULL; |
| 4874 | done: |
| 4875 | _PyPegen_insert_memo(p, mark, star_expression_type, res); |
| 4876 | return res; |
| 4877 | } |
| 4878 | |
| 4879 | // star_named_expressions: ','.star_named_expression+ ','? |
| 4880 | static asdl_seq* |
| 4881 | star_named_expressions_rule(Parser *p) |
| 4882 | { |
| 4883 | if (p->error_indicator) { |
| 4884 | return NULL; |
| 4885 | } |
| 4886 | asdl_seq* res = NULL; |
| 4887 | int mark = p->mark; |
| 4888 | { // ','.star_named_expression+ ','? |
| 4889 | asdl_seq * a; |
| 4890 | void *opt_var; |
| 4891 | UNUSED(opt_var); // Silence compiler warnings |
| 4892 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4893 | (a = _gather_72_rule(p)) // ','.star_named_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4894 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4895 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4896 | ) |
| 4897 | { |
| 4898 | res = a; |
| 4899 | if (res == NULL && PyErr_Occurred()) { |
| 4900 | p->error_indicator = 1; |
| 4901 | return NULL; |
| 4902 | } |
| 4903 | goto done; |
| 4904 | } |
| 4905 | p->mark = mark; |
| 4906 | } |
| 4907 | res = NULL; |
| 4908 | done: |
| 4909 | return res; |
| 4910 | } |
| 4911 | |
| 4912 | // star_named_expression: '*' bitwise_or | named_expression |
| 4913 | static expr_ty |
| 4914 | star_named_expression_rule(Parser *p) |
| 4915 | { |
| 4916 | if (p->error_indicator) { |
| 4917 | return NULL; |
| 4918 | } |
| 4919 | expr_ty res = NULL; |
| 4920 | int mark = p->mark; |
| 4921 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4922 | p->error_indicator = 1; |
| 4923 | return NULL; |
| 4924 | } |
| 4925 | int start_lineno = p->tokens[mark]->lineno; |
| 4926 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4927 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4928 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4929 | { // '*' bitwise_or |
| 4930 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4931 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4932 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4933 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4934 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4935 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4936 | ) |
| 4937 | { |
| 4938 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4939 | if (token == NULL) { |
| 4940 | return NULL; |
| 4941 | } |
| 4942 | int end_lineno = token->end_lineno; |
| 4943 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4944 | int end_col_offset = token->end_col_offset; |
| 4945 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4946 | res = _Py_Starred ( a , Load , EXTRA ); |
| 4947 | if (res == NULL && PyErr_Occurred()) { |
| 4948 | p->error_indicator = 1; |
| 4949 | return NULL; |
| 4950 | } |
| 4951 | goto done; |
| 4952 | } |
| 4953 | p->mark = mark; |
| 4954 | } |
| 4955 | { // named_expression |
| 4956 | expr_ty named_expression_var; |
| 4957 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4958 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4959 | ) |
| 4960 | { |
| 4961 | res = named_expression_var; |
| 4962 | goto done; |
| 4963 | } |
| 4964 | p->mark = mark; |
| 4965 | } |
| 4966 | res = NULL; |
| 4967 | done: |
| 4968 | return res; |
| 4969 | } |
| 4970 | |
| 4971 | // named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression |
| 4972 | static expr_ty |
| 4973 | named_expression_rule(Parser *p) |
| 4974 | { |
| 4975 | if (p->error_indicator) { |
| 4976 | return NULL; |
| 4977 | } |
| 4978 | expr_ty res = NULL; |
| 4979 | int mark = p->mark; |
| 4980 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4981 | p->error_indicator = 1; |
| 4982 | return NULL; |
| 4983 | } |
| 4984 | int start_lineno = p->tokens[mark]->lineno; |
| 4985 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4986 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4987 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4988 | { // NAME ':=' expression |
| 4989 | expr_ty a; |
| 4990 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4991 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4992 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4993 | (a = _PyPegen_name_token(p)) // NAME |
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 | (literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4996 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4997 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4998 | ) |
| 4999 | { |
| 5000 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5001 | if (token == NULL) { |
| 5002 | return NULL; |
| 5003 | } |
| 5004 | int end_lineno = token->end_lineno; |
| 5005 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5006 | int end_col_offset = token->end_col_offset; |
| 5007 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5008 | res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); |
| 5009 | if (res == NULL && PyErr_Occurred()) { |
| 5010 | p->error_indicator = 1; |
| 5011 | return NULL; |
| 5012 | } |
| 5013 | goto done; |
| 5014 | } |
| 5015 | p->mark = mark; |
| 5016 | } |
| 5017 | { // expression !':=' |
| 5018 | expr_ty expression_var; |
| 5019 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5020 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5021 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5022 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5023 | ) |
| 5024 | { |
| 5025 | res = expression_var; |
| 5026 | goto done; |
| 5027 | } |
| 5028 | p->mark = mark; |
| 5029 | } |
| 5030 | { // invalid_named_expression |
| 5031 | void *invalid_named_expression_var; |
| 5032 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5033 | (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5034 | ) |
| 5035 | { |
| 5036 | res = invalid_named_expression_var; |
| 5037 | goto done; |
| 5038 | } |
| 5039 | p->mark = mark; |
| 5040 | } |
| 5041 | res = NULL; |
| 5042 | done: |
| 5043 | return res; |
| 5044 | } |
| 5045 | |
| 5046 | // annotated_rhs: yield_expr | star_expressions |
| 5047 | static expr_ty |
| 5048 | annotated_rhs_rule(Parser *p) |
| 5049 | { |
| 5050 | if (p->error_indicator) { |
| 5051 | return NULL; |
| 5052 | } |
| 5053 | expr_ty res = NULL; |
| 5054 | int mark = p->mark; |
| 5055 | { // yield_expr |
| 5056 | expr_ty yield_expr_var; |
| 5057 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5058 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5059 | ) |
| 5060 | { |
| 5061 | res = yield_expr_var; |
| 5062 | goto done; |
| 5063 | } |
| 5064 | p->mark = mark; |
| 5065 | } |
| 5066 | { // star_expressions |
| 5067 | expr_ty star_expressions_var; |
| 5068 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5069 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5070 | ) |
| 5071 | { |
| 5072 | res = star_expressions_var; |
| 5073 | goto done; |
| 5074 | } |
| 5075 | p->mark = mark; |
| 5076 | } |
| 5077 | res = NULL; |
| 5078 | done: |
| 5079 | return res; |
| 5080 | } |
| 5081 | |
| 5082 | // expressions: expression ((',' expression))+ ','? | expression ',' | expression |
| 5083 | static expr_ty |
| 5084 | expressions_rule(Parser *p) |
| 5085 | { |
| 5086 | if (p->error_indicator) { |
| 5087 | return NULL; |
| 5088 | } |
| 5089 | expr_ty res = NULL; |
| 5090 | int mark = p->mark; |
| 5091 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5092 | p->error_indicator = 1; |
| 5093 | return NULL; |
| 5094 | } |
| 5095 | int start_lineno = p->tokens[mark]->lineno; |
| 5096 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5097 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5098 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5099 | { // expression ((',' expression))+ ','? |
| 5100 | expr_ty a; |
| 5101 | asdl_seq * b; |
| 5102 | void *opt_var; |
| 5103 | UNUSED(opt_var); // Silence compiler warnings |
| 5104 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5105 | (a = expression_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 | (b = _loop1_74_rule(p)) // ((',' expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5108 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5109 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5110 | ) |
| 5111 | { |
| 5112 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5113 | if (token == NULL) { |
| 5114 | return NULL; |
| 5115 | } |
| 5116 | int end_lineno = token->end_lineno; |
| 5117 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5118 | int end_col_offset = token->end_col_offset; |
| 5119 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5120 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 5121 | if (res == NULL && PyErr_Occurred()) { |
| 5122 | p->error_indicator = 1; |
| 5123 | return NULL; |
| 5124 | } |
| 5125 | goto done; |
| 5126 | } |
| 5127 | p->mark = mark; |
| 5128 | } |
| 5129 | { // expression ',' |
| 5130 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5131 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5132 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5133 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5134 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5135 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5136 | ) |
| 5137 | { |
| 5138 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5139 | if (token == NULL) { |
| 5140 | return NULL; |
| 5141 | } |
| 5142 | int end_lineno = token->end_lineno; |
| 5143 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5144 | int end_col_offset = token->end_col_offset; |
| 5145 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5146 | res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 5147 | if (res == NULL && PyErr_Occurred()) { |
| 5148 | p->error_indicator = 1; |
| 5149 | return NULL; |
| 5150 | } |
| 5151 | goto done; |
| 5152 | } |
| 5153 | p->mark = mark; |
| 5154 | } |
| 5155 | { // expression |
| 5156 | expr_ty expression_var; |
| 5157 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5158 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5159 | ) |
| 5160 | { |
| 5161 | res = expression_var; |
| 5162 | goto done; |
| 5163 | } |
| 5164 | p->mark = mark; |
| 5165 | } |
| 5166 | res = NULL; |
| 5167 | done: |
| 5168 | return res; |
| 5169 | } |
| 5170 | |
| 5171 | // expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef |
| 5172 | static expr_ty |
| 5173 | expression_rule(Parser *p) |
| 5174 | { |
| 5175 | if (p->error_indicator) { |
| 5176 | return NULL; |
| 5177 | } |
| 5178 | expr_ty res = NULL; |
| 5179 | if (_PyPegen_is_memoized(p, expression_type, &res)) |
| 5180 | return res; |
| 5181 | int mark = p->mark; |
| 5182 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5183 | p->error_indicator = 1; |
| 5184 | return NULL; |
| 5185 | } |
| 5186 | int start_lineno = p->tokens[mark]->lineno; |
| 5187 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5188 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5189 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5190 | { // disjunction 'if' disjunction 'else' expression |
| 5191 | expr_ty a; |
| 5192 | expr_ty b; |
| 5193 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5194 | Token * keyword; |
| 5195 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5196 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5197 | (a = disjunction_rule(p)) // disjunction |
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 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5200 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5201 | (b = disjunction_rule(p)) // disjunction |
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 | (keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5204 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5205 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5206 | ) |
| 5207 | { |
| 5208 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5209 | if (token == NULL) { |
| 5210 | return NULL; |
| 5211 | } |
| 5212 | int end_lineno = token->end_lineno; |
| 5213 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5214 | int end_col_offset = token->end_col_offset; |
| 5215 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5216 | res = _Py_IfExp ( b , a , c , EXTRA ); |
| 5217 | if (res == NULL && PyErr_Occurred()) { |
| 5218 | p->error_indicator = 1; |
| 5219 | return NULL; |
| 5220 | } |
| 5221 | goto done; |
| 5222 | } |
| 5223 | p->mark = mark; |
| 5224 | } |
| 5225 | { // disjunction |
| 5226 | expr_ty disjunction_var; |
| 5227 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5228 | (disjunction_var = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5229 | ) |
| 5230 | { |
| 5231 | res = disjunction_var; |
| 5232 | goto done; |
| 5233 | } |
| 5234 | p->mark = mark; |
| 5235 | } |
| 5236 | { // lambdef |
| 5237 | expr_ty lambdef_var; |
| 5238 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5239 | (lambdef_var = lambdef_rule(p)) // lambdef |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5240 | ) |
| 5241 | { |
| 5242 | res = lambdef_var; |
| 5243 | goto done; |
| 5244 | } |
| 5245 | p->mark = mark; |
| 5246 | } |
| 5247 | res = NULL; |
| 5248 | done: |
| 5249 | _PyPegen_insert_memo(p, mark, expression_type, res); |
| 5250 | return res; |
| 5251 | } |
| 5252 | |
| 5253 | // lambdef: 'lambda' lambda_parameters? ':' expression |
| 5254 | static expr_ty |
| 5255 | lambdef_rule(Parser *p) |
| 5256 | { |
| 5257 | if (p->error_indicator) { |
| 5258 | return NULL; |
| 5259 | } |
| 5260 | expr_ty res = NULL; |
| 5261 | int mark = p->mark; |
| 5262 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5263 | p->error_indicator = 1; |
| 5264 | return NULL; |
| 5265 | } |
| 5266 | int start_lineno = p->tokens[mark]->lineno; |
| 5267 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5268 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5269 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5270 | { // 'lambda' lambda_parameters? ':' expression |
| 5271 | void *a; |
| 5272 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5273 | Token * keyword; |
| 5274 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5275 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5276 | (keyword = _PyPegen_expect_token(p, 524)) // token='lambda' |
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 | (a = lambda_parameters_rule(p), 1) // lambda_parameters? |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5281 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5282 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5283 | ) |
| 5284 | { |
| 5285 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5286 | if (token == NULL) { |
| 5287 | return NULL; |
| 5288 | } |
| 5289 | int end_lineno = token->end_lineno; |
| 5290 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5291 | int end_col_offset = token->end_col_offset; |
| 5292 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5293 | res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); |
| 5294 | if (res == NULL && PyErr_Occurred()) { |
| 5295 | p->error_indicator = 1; |
| 5296 | return NULL; |
| 5297 | } |
| 5298 | goto done; |
| 5299 | } |
| 5300 | p->mark = mark; |
| 5301 | } |
| 5302 | res = NULL; |
| 5303 | done: |
| 5304 | return res; |
| 5305 | } |
| 5306 | |
| 5307 | // lambda_parameters: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5308 | // | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 5309 | // | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 5310 | // | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5311 | // | lambda_param_with_default+ lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5312 | // | lambda_star_etc |
| 5313 | static arguments_ty |
| 5314 | lambda_parameters_rule(Parser *p) |
| 5315 | { |
| 5316 | if (p->error_indicator) { |
| 5317 | return NULL; |
| 5318 | } |
| 5319 | arguments_ty res = NULL; |
| 5320 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5321 | { // 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] | 5322 | asdl_seq* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5323 | asdl_seq * b; |
| 5324 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5325 | void *d; |
| 5326 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5327 | (a = lambda_slash_no_default_rule(p)) // lambda_slash_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 | (b = _loop0_75_rule(p)) // lambda_param_no_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 | (c = _loop0_76_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5332 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5333 | (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5334 | ) |
| 5335 | { |
| 5336 | res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 5337 | if (res == NULL && PyErr_Occurred()) { |
| 5338 | p->error_indicator = 1; |
| 5339 | return NULL; |
| 5340 | } |
| 5341 | goto done; |
| 5342 | } |
| 5343 | p->mark = mark; |
| 5344 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5345 | { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5346 | SlashWithDefault* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5347 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5348 | void *c; |
| 5349 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5350 | (a = lambda_slash_with_default_rule(p)) // lambda_slash_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 | (b = _loop0_77_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5353 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5354 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5355 | ) |
| 5356 | { |
| 5357 | res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 5358 | if (res == NULL && PyErr_Occurred()) { |
| 5359 | p->error_indicator = 1; |
| 5360 | return NULL; |
| 5361 | } |
| 5362 | goto done; |
| 5363 | } |
| 5364 | p->mark = mark; |
| 5365 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5366 | { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5367 | asdl_seq * a; |
| 5368 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5369 | void *c; |
| 5370 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5371 | (a = _loop1_78_rule(p)) // lambda_param_no_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 | (b = _loop0_79_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5374 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5375 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5376 | ) |
| 5377 | { |
| 5378 | res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 5379 | if (res == NULL && PyErr_Occurred()) { |
| 5380 | p->error_indicator = 1; |
| 5381 | return NULL; |
| 5382 | } |
| 5383 | goto done; |
| 5384 | } |
| 5385 | p->mark = mark; |
| 5386 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5387 | { // lambda_param_with_default+ lambda_star_etc? |
| 5388 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5389 | void *b; |
| 5390 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5391 | (a = _loop1_80_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5392 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5393 | (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5394 | ) |
| 5395 | { |
| 5396 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 5397 | if (res == NULL && PyErr_Occurred()) { |
| 5398 | p->error_indicator = 1; |
| 5399 | return NULL; |
| 5400 | } |
| 5401 | goto done; |
| 5402 | } |
| 5403 | p->mark = mark; |
| 5404 | } |
| 5405 | { // lambda_star_etc |
| 5406 | StarEtc* a; |
| 5407 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5408 | (a = lambda_star_etc_rule(p)) // lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5409 | ) |
| 5410 | { |
| 5411 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 5412 | if (res == NULL && PyErr_Occurred()) { |
| 5413 | p->error_indicator = 1; |
| 5414 | return NULL; |
| 5415 | } |
| 5416 | goto done; |
| 5417 | } |
| 5418 | p->mark = mark; |
| 5419 | } |
| 5420 | res = NULL; |
| 5421 | done: |
| 5422 | return res; |
| 5423 | } |
| 5424 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5425 | // lambda_slash_no_default: |
| 5426 | // | lambda_param_no_default+ '/' ',' |
| 5427 | // | lambda_param_no_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5428 | static asdl_seq* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5429 | lambda_slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5430 | { |
| 5431 | if (p->error_indicator) { |
| 5432 | return NULL; |
| 5433 | } |
| 5434 | asdl_seq* res = NULL; |
| 5435 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5436 | { // lambda_param_no_default+ '/' ',' |
| 5437 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5438 | Token * literal; |
| 5439 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5440 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5441 | (a = _loop1_81_rule(p)) // lambda_param_no_default+ |
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 = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5444 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5445 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5446 | ) |
| 5447 | { |
| 5448 | res = a; |
| 5449 | if (res == NULL && PyErr_Occurred()) { |
| 5450 | p->error_indicator = 1; |
| 5451 | return NULL; |
| 5452 | } |
| 5453 | goto done; |
| 5454 | } |
| 5455 | p->mark = mark; |
| 5456 | } |
| 5457 | { // lambda_param_no_default+ '/' &':' |
| 5458 | asdl_seq * a; |
| 5459 | Token * literal; |
| 5460 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5461 | (a = _loop1_82_rule(p)) // lambda_param_no_default+ |
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 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5464 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5465 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5466 | ) |
| 5467 | { |
| 5468 | res = a; |
| 5469 | if (res == NULL && PyErr_Occurred()) { |
| 5470 | p->error_indicator = 1; |
| 5471 | return NULL; |
| 5472 | } |
| 5473 | goto done; |
| 5474 | } |
| 5475 | p->mark = mark; |
| 5476 | } |
| 5477 | res = NULL; |
| 5478 | done: |
| 5479 | return res; |
| 5480 | } |
| 5481 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5482 | // lambda_slash_with_default: |
| 5483 | // | lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 5484 | // | lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5485 | static SlashWithDefault* |
| 5486 | lambda_slash_with_default_rule(Parser *p) |
| 5487 | { |
| 5488 | if (p->error_indicator) { |
| 5489 | return NULL; |
| 5490 | } |
| 5491 | SlashWithDefault* res = NULL; |
| 5492 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5493 | { // lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 5494 | asdl_seq * a; |
| 5495 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5496 | Token * literal; |
| 5497 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5498 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5499 | (a = _loop0_83_rule(p)) // lambda_param_no_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 | (b = _loop1_84_rule(p)) // lambda_param_with_default+ |
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 = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5504 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5505 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5506 | ) |
| 5507 | { |
| 5508 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 5509 | if (res == NULL && PyErr_Occurred()) { |
| 5510 | p->error_indicator = 1; |
| 5511 | return NULL; |
| 5512 | } |
| 5513 | goto done; |
| 5514 | } |
| 5515 | p->mark = mark; |
| 5516 | } |
| 5517 | { // lambda_param_no_default* lambda_param_with_default+ '/' &':' |
| 5518 | asdl_seq * a; |
| 5519 | asdl_seq * b; |
| 5520 | Token * literal; |
| 5521 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5522 | (a = _loop0_85_rule(p)) // lambda_param_no_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 | (b = _loop1_86_rule(p)) // lambda_param_with_default+ |
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 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5527 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5528 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5529 | ) |
| 5530 | { |
| 5531 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 5532 | if (res == NULL && PyErr_Occurred()) { |
| 5533 | p->error_indicator = 1; |
| 5534 | return NULL; |
| 5535 | } |
| 5536 | goto done; |
| 5537 | } |
| 5538 | p->mark = mark; |
| 5539 | } |
| 5540 | res = NULL; |
| 5541 | done: |
| 5542 | return res; |
| 5543 | } |
| 5544 | |
| 5545 | // lambda_star_etc: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5546 | // | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 5547 | // | '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 5548 | // | lambda_kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5549 | // | invalid_lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5550 | static StarEtc* |
| 5551 | lambda_star_etc_rule(Parser *p) |
| 5552 | { |
| 5553 | if (p->error_indicator) { |
| 5554 | return NULL; |
| 5555 | } |
| 5556 | StarEtc* res = NULL; |
| 5557 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5558 | { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5559 | arg_ty a; |
| 5560 | asdl_seq * b; |
| 5561 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5562 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5563 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5564 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
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 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_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 | (b = _loop0_87_rule(p)) // lambda_param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5569 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5570 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5571 | ) |
| 5572 | { |
| 5573 | res = _PyPegen_star_etc ( p , a , b , c ); |
| 5574 | if (res == NULL && PyErr_Occurred()) { |
| 5575 | p->error_indicator = 1; |
| 5576 | return NULL; |
| 5577 | } |
| 5578 | goto done; |
| 5579 | } |
| 5580 | p->mark = mark; |
| 5581 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5582 | { // '*' ',' lambda_param_maybe_default+ lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5583 | asdl_seq * b; |
| 5584 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5585 | Token * literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5586 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5587 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5588 | (literal = _PyPegen_expect_token(p, 16)) // 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 | (literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
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 | (b = _loop1_88_rule(p)) // lambda_param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5593 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5594 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5595 | ) |
| 5596 | { |
| 5597 | res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 5598 | if (res == NULL && PyErr_Occurred()) { |
| 5599 | p->error_indicator = 1; |
| 5600 | return NULL; |
| 5601 | } |
| 5602 | goto done; |
| 5603 | } |
| 5604 | p->mark = mark; |
| 5605 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5606 | { // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5607 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5608 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5609 | (a = lambda_kwds_rule(p)) // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5610 | ) |
| 5611 | { |
| 5612 | res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 5613 | if (res == NULL && PyErr_Occurred()) { |
| 5614 | p->error_indicator = 1; |
| 5615 | return NULL; |
| 5616 | } |
| 5617 | goto done; |
| 5618 | } |
| 5619 | p->mark = mark; |
| 5620 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5621 | { // invalid_lambda_star_etc |
| 5622 | void *invalid_lambda_star_etc_var; |
| 5623 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5624 | (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] | 5625 | ) |
| 5626 | { |
| 5627 | res = invalid_lambda_star_etc_var; |
| 5628 | goto done; |
| 5629 | } |
| 5630 | p->mark = mark; |
| 5631 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5632 | res = NULL; |
| 5633 | done: |
| 5634 | return res; |
| 5635 | } |
| 5636 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5637 | // lambda_kwds: '**' lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5638 | static arg_ty |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5639 | lambda_kwds_rule(Parser *p) |
| 5640 | { |
| 5641 | if (p->error_indicator) { |
| 5642 | return NULL; |
| 5643 | } |
| 5644 | arg_ty res = NULL; |
| 5645 | int mark = p->mark; |
| 5646 | { // '**' lambda_param_no_default |
| 5647 | arg_ty a; |
| 5648 | Token * literal; |
| 5649 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5650 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5651 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5652 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5653 | ) |
| 5654 | { |
| 5655 | res = a; |
| 5656 | if (res == NULL && PyErr_Occurred()) { |
| 5657 | p->error_indicator = 1; |
| 5658 | return NULL; |
| 5659 | } |
| 5660 | goto done; |
| 5661 | } |
| 5662 | p->mark = mark; |
| 5663 | } |
| 5664 | res = NULL; |
| 5665 | done: |
| 5666 | return res; |
| 5667 | } |
| 5668 | |
| 5669 | // lambda_param_no_default: lambda_param ',' | lambda_param &':' |
| 5670 | static arg_ty |
| 5671 | lambda_param_no_default_rule(Parser *p) |
| 5672 | { |
| 5673 | if (p->error_indicator) { |
| 5674 | return NULL; |
| 5675 | } |
| 5676 | arg_ty res = NULL; |
| 5677 | int mark = p->mark; |
| 5678 | { // lambda_param ',' |
| 5679 | arg_ty a; |
| 5680 | Token * literal; |
| 5681 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5682 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5683 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5684 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5685 | ) |
| 5686 | { |
| 5687 | res = a; |
| 5688 | if (res == NULL && PyErr_Occurred()) { |
| 5689 | p->error_indicator = 1; |
| 5690 | return NULL; |
| 5691 | } |
| 5692 | goto done; |
| 5693 | } |
| 5694 | p->mark = mark; |
| 5695 | } |
| 5696 | { // lambda_param &':' |
| 5697 | arg_ty a; |
| 5698 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5699 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5700 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5701 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5702 | ) |
| 5703 | { |
| 5704 | res = a; |
| 5705 | if (res == NULL && PyErr_Occurred()) { |
| 5706 | p->error_indicator = 1; |
| 5707 | return NULL; |
| 5708 | } |
| 5709 | goto done; |
| 5710 | } |
| 5711 | p->mark = mark; |
| 5712 | } |
| 5713 | res = NULL; |
| 5714 | done: |
| 5715 | return res; |
| 5716 | } |
| 5717 | |
| 5718 | // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' |
| 5719 | static NameDefaultPair* |
| 5720 | lambda_param_with_default_rule(Parser *p) |
| 5721 | { |
| 5722 | if (p->error_indicator) { |
| 5723 | return NULL; |
| 5724 | } |
| 5725 | NameDefaultPair* res = NULL; |
| 5726 | int mark = p->mark; |
| 5727 | { // lambda_param default ',' |
| 5728 | arg_ty a; |
| 5729 | expr_ty c; |
| 5730 | Token * literal; |
| 5731 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5732 | (a = lambda_param_rule(p)) // lambda_param |
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 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5735 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5736 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5737 | ) |
| 5738 | { |
| 5739 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5740 | if (res == NULL && PyErr_Occurred()) { |
| 5741 | p->error_indicator = 1; |
| 5742 | return NULL; |
| 5743 | } |
| 5744 | goto done; |
| 5745 | } |
| 5746 | p->mark = mark; |
| 5747 | } |
| 5748 | { // lambda_param default &':' |
| 5749 | arg_ty a; |
| 5750 | expr_ty c; |
| 5751 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5752 | (a = lambda_param_rule(p)) // lambda_param |
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 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5755 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5756 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5757 | ) |
| 5758 | { |
| 5759 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5760 | if (res == NULL && PyErr_Occurred()) { |
| 5761 | p->error_indicator = 1; |
| 5762 | return NULL; |
| 5763 | } |
| 5764 | goto done; |
| 5765 | } |
| 5766 | p->mark = mark; |
| 5767 | } |
| 5768 | res = NULL; |
| 5769 | done: |
| 5770 | return res; |
| 5771 | } |
| 5772 | |
| 5773 | // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' |
| 5774 | static NameDefaultPair* |
| 5775 | lambda_param_maybe_default_rule(Parser *p) |
| 5776 | { |
| 5777 | if (p->error_indicator) { |
| 5778 | return NULL; |
| 5779 | } |
| 5780 | NameDefaultPair* res = NULL; |
| 5781 | int mark = p->mark; |
| 5782 | { // lambda_param default? ',' |
| 5783 | arg_ty a; |
| 5784 | void *c; |
| 5785 | Token * literal; |
| 5786 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5787 | (a = lambda_param_rule(p)) // lambda_param |
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 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5790 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5791 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5792 | ) |
| 5793 | { |
| 5794 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5795 | if (res == NULL && PyErr_Occurred()) { |
| 5796 | p->error_indicator = 1; |
| 5797 | return NULL; |
| 5798 | } |
| 5799 | goto done; |
| 5800 | } |
| 5801 | p->mark = mark; |
| 5802 | } |
| 5803 | { // lambda_param default? &':' |
| 5804 | arg_ty a; |
| 5805 | void *c; |
| 5806 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5807 | (a = lambda_param_rule(p)) // lambda_param |
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 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5810 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5811 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5812 | ) |
| 5813 | { |
| 5814 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5815 | if (res == NULL && PyErr_Occurred()) { |
| 5816 | p->error_indicator = 1; |
| 5817 | return NULL; |
| 5818 | } |
| 5819 | goto done; |
| 5820 | } |
| 5821 | p->mark = mark; |
| 5822 | } |
| 5823 | res = NULL; |
| 5824 | done: |
| 5825 | return res; |
| 5826 | } |
| 5827 | |
| 5828 | // lambda_param: NAME |
| 5829 | static arg_ty |
| 5830 | lambda_param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5831 | { |
| 5832 | if (p->error_indicator) { |
| 5833 | return NULL; |
| 5834 | } |
| 5835 | arg_ty res = NULL; |
| 5836 | int mark = p->mark; |
| 5837 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5838 | p->error_indicator = 1; |
| 5839 | return NULL; |
| 5840 | } |
| 5841 | int start_lineno = p->tokens[mark]->lineno; |
| 5842 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5843 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5844 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5845 | { // NAME |
| 5846 | expr_ty a; |
| 5847 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5848 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5849 | ) |
| 5850 | { |
| 5851 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5852 | if (token == NULL) { |
| 5853 | return NULL; |
| 5854 | } |
| 5855 | int end_lineno = token->end_lineno; |
| 5856 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5857 | int end_col_offset = token->end_col_offset; |
| 5858 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5859 | res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); |
| 5860 | if (res == NULL && PyErr_Occurred()) { |
| 5861 | p->error_indicator = 1; |
| 5862 | return NULL; |
| 5863 | } |
| 5864 | goto done; |
| 5865 | } |
| 5866 | p->mark = mark; |
| 5867 | } |
| 5868 | res = NULL; |
| 5869 | done: |
| 5870 | return res; |
| 5871 | } |
| 5872 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5873 | // disjunction: conjunction (('or' conjunction))+ | conjunction |
| 5874 | static expr_ty |
| 5875 | disjunction_rule(Parser *p) |
| 5876 | { |
| 5877 | if (p->error_indicator) { |
| 5878 | return NULL; |
| 5879 | } |
| 5880 | expr_ty res = NULL; |
| 5881 | if (_PyPegen_is_memoized(p, disjunction_type, &res)) |
| 5882 | return res; |
| 5883 | int mark = p->mark; |
| 5884 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5885 | p->error_indicator = 1; |
| 5886 | return NULL; |
| 5887 | } |
| 5888 | int start_lineno = p->tokens[mark]->lineno; |
| 5889 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5890 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5891 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5892 | { // conjunction (('or' conjunction))+ |
| 5893 | expr_ty a; |
| 5894 | asdl_seq * b; |
| 5895 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5896 | (a = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5897 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5898 | (b = _loop1_89_rule(p)) // (('or' conjunction))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5899 | ) |
| 5900 | { |
| 5901 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5902 | if (token == NULL) { |
| 5903 | return NULL; |
| 5904 | } |
| 5905 | int end_lineno = token->end_lineno; |
| 5906 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5907 | int end_col_offset = token->end_col_offset; |
| 5908 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5909 | res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5910 | if (res == NULL && PyErr_Occurred()) { |
| 5911 | p->error_indicator = 1; |
| 5912 | return NULL; |
| 5913 | } |
| 5914 | goto done; |
| 5915 | } |
| 5916 | p->mark = mark; |
| 5917 | } |
| 5918 | { // conjunction |
| 5919 | expr_ty conjunction_var; |
| 5920 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5921 | (conjunction_var = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5922 | ) |
| 5923 | { |
| 5924 | res = conjunction_var; |
| 5925 | goto done; |
| 5926 | } |
| 5927 | p->mark = mark; |
| 5928 | } |
| 5929 | res = NULL; |
| 5930 | done: |
| 5931 | _PyPegen_insert_memo(p, mark, disjunction_type, res); |
| 5932 | return res; |
| 5933 | } |
| 5934 | |
| 5935 | // conjunction: inversion (('and' inversion))+ | inversion |
| 5936 | static expr_ty |
| 5937 | conjunction_rule(Parser *p) |
| 5938 | { |
| 5939 | if (p->error_indicator) { |
| 5940 | return NULL; |
| 5941 | } |
| 5942 | expr_ty res = NULL; |
| 5943 | if (_PyPegen_is_memoized(p, conjunction_type, &res)) |
| 5944 | return res; |
| 5945 | int mark = p->mark; |
| 5946 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5947 | p->error_indicator = 1; |
| 5948 | return NULL; |
| 5949 | } |
| 5950 | int start_lineno = p->tokens[mark]->lineno; |
| 5951 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5952 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5953 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5954 | { // inversion (('and' inversion))+ |
| 5955 | expr_ty a; |
| 5956 | asdl_seq * b; |
| 5957 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5958 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5959 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5960 | (b = _loop1_90_rule(p)) // (('and' inversion))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5961 | ) |
| 5962 | { |
| 5963 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5964 | if (token == NULL) { |
| 5965 | return NULL; |
| 5966 | } |
| 5967 | int end_lineno = token->end_lineno; |
| 5968 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5969 | int end_col_offset = token->end_col_offset; |
| 5970 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5971 | res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5972 | if (res == NULL && PyErr_Occurred()) { |
| 5973 | p->error_indicator = 1; |
| 5974 | return NULL; |
| 5975 | } |
| 5976 | goto done; |
| 5977 | } |
| 5978 | p->mark = mark; |
| 5979 | } |
| 5980 | { // inversion |
| 5981 | expr_ty inversion_var; |
| 5982 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5983 | (inversion_var = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5984 | ) |
| 5985 | { |
| 5986 | res = inversion_var; |
| 5987 | goto done; |
| 5988 | } |
| 5989 | p->mark = mark; |
| 5990 | } |
| 5991 | res = NULL; |
| 5992 | done: |
| 5993 | _PyPegen_insert_memo(p, mark, conjunction_type, res); |
| 5994 | return res; |
| 5995 | } |
| 5996 | |
| 5997 | // inversion: 'not' inversion | comparison |
| 5998 | static expr_ty |
| 5999 | inversion_rule(Parser *p) |
| 6000 | { |
| 6001 | if (p->error_indicator) { |
| 6002 | return NULL; |
| 6003 | } |
| 6004 | expr_ty res = NULL; |
| 6005 | if (_PyPegen_is_memoized(p, inversion_type, &res)) |
| 6006 | return res; |
| 6007 | int mark = p->mark; |
| 6008 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6009 | p->error_indicator = 1; |
| 6010 | return NULL; |
| 6011 | } |
| 6012 | int start_lineno = p->tokens[mark]->lineno; |
| 6013 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6014 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6015 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6016 | { // 'not' inversion |
| 6017 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6018 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6019 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6020 | (keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6021 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6022 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6023 | ) |
| 6024 | { |
| 6025 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6026 | if (token == NULL) { |
| 6027 | return NULL; |
| 6028 | } |
| 6029 | int end_lineno = token->end_lineno; |
| 6030 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6031 | int end_col_offset = token->end_col_offset; |
| 6032 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6033 | res = _Py_UnaryOp ( Not , a , EXTRA ); |
| 6034 | if (res == NULL && PyErr_Occurred()) { |
| 6035 | p->error_indicator = 1; |
| 6036 | return NULL; |
| 6037 | } |
| 6038 | goto done; |
| 6039 | } |
| 6040 | p->mark = mark; |
| 6041 | } |
| 6042 | { // comparison |
| 6043 | expr_ty comparison_var; |
| 6044 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6045 | (comparison_var = comparison_rule(p)) // comparison |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6046 | ) |
| 6047 | { |
| 6048 | res = comparison_var; |
| 6049 | goto done; |
| 6050 | } |
| 6051 | p->mark = mark; |
| 6052 | } |
| 6053 | res = NULL; |
| 6054 | done: |
| 6055 | _PyPegen_insert_memo(p, mark, inversion_type, res); |
| 6056 | return res; |
| 6057 | } |
| 6058 | |
| 6059 | // comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or |
| 6060 | static expr_ty |
| 6061 | comparison_rule(Parser *p) |
| 6062 | { |
| 6063 | if (p->error_indicator) { |
| 6064 | return NULL; |
| 6065 | } |
| 6066 | expr_ty res = NULL; |
| 6067 | int mark = p->mark; |
| 6068 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6069 | p->error_indicator = 1; |
| 6070 | return NULL; |
| 6071 | } |
| 6072 | int start_lineno = p->tokens[mark]->lineno; |
| 6073 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6074 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6075 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6076 | { // bitwise_or compare_op_bitwise_or_pair+ |
| 6077 | expr_ty a; |
| 6078 | asdl_seq * b; |
| 6079 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6080 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6081 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6082 | (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6083 | ) |
| 6084 | { |
| 6085 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6086 | if (token == NULL) { |
| 6087 | return NULL; |
| 6088 | } |
| 6089 | int end_lineno = token->end_lineno; |
| 6090 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6091 | int end_col_offset = token->end_col_offset; |
| 6092 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6093 | res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); |
| 6094 | if (res == NULL && PyErr_Occurred()) { |
| 6095 | p->error_indicator = 1; |
| 6096 | return NULL; |
| 6097 | } |
| 6098 | goto done; |
| 6099 | } |
| 6100 | p->mark = mark; |
| 6101 | } |
| 6102 | { // bitwise_or |
| 6103 | expr_ty bitwise_or_var; |
| 6104 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6105 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6106 | ) |
| 6107 | { |
| 6108 | res = bitwise_or_var; |
| 6109 | goto done; |
| 6110 | } |
| 6111 | p->mark = mark; |
| 6112 | } |
| 6113 | res = NULL; |
| 6114 | done: |
| 6115 | return res; |
| 6116 | } |
| 6117 | |
| 6118 | // compare_op_bitwise_or_pair: |
| 6119 | // | eq_bitwise_or |
| 6120 | // | noteq_bitwise_or |
| 6121 | // | lte_bitwise_or |
| 6122 | // | lt_bitwise_or |
| 6123 | // | gte_bitwise_or |
| 6124 | // | gt_bitwise_or |
| 6125 | // | notin_bitwise_or |
| 6126 | // | in_bitwise_or |
| 6127 | // | isnot_bitwise_or |
| 6128 | // | is_bitwise_or |
| 6129 | static CmpopExprPair* |
| 6130 | compare_op_bitwise_or_pair_rule(Parser *p) |
| 6131 | { |
| 6132 | if (p->error_indicator) { |
| 6133 | return NULL; |
| 6134 | } |
| 6135 | CmpopExprPair* res = NULL; |
| 6136 | int mark = p->mark; |
| 6137 | { // eq_bitwise_or |
| 6138 | CmpopExprPair* eq_bitwise_or_var; |
| 6139 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6140 | (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6141 | ) |
| 6142 | { |
| 6143 | res = eq_bitwise_or_var; |
| 6144 | goto done; |
| 6145 | } |
| 6146 | p->mark = mark; |
| 6147 | } |
| 6148 | { // noteq_bitwise_or |
| 6149 | CmpopExprPair* noteq_bitwise_or_var; |
| 6150 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6151 | (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6152 | ) |
| 6153 | { |
| 6154 | res = noteq_bitwise_or_var; |
| 6155 | goto done; |
| 6156 | } |
| 6157 | p->mark = mark; |
| 6158 | } |
| 6159 | { // lte_bitwise_or |
| 6160 | CmpopExprPair* lte_bitwise_or_var; |
| 6161 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6162 | (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6163 | ) |
| 6164 | { |
| 6165 | res = lte_bitwise_or_var; |
| 6166 | goto done; |
| 6167 | } |
| 6168 | p->mark = mark; |
| 6169 | } |
| 6170 | { // lt_bitwise_or |
| 6171 | CmpopExprPair* lt_bitwise_or_var; |
| 6172 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6173 | (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6174 | ) |
| 6175 | { |
| 6176 | res = lt_bitwise_or_var; |
| 6177 | goto done; |
| 6178 | } |
| 6179 | p->mark = mark; |
| 6180 | } |
| 6181 | { // gte_bitwise_or |
| 6182 | CmpopExprPair* gte_bitwise_or_var; |
| 6183 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6184 | (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6185 | ) |
| 6186 | { |
| 6187 | res = gte_bitwise_or_var; |
| 6188 | goto done; |
| 6189 | } |
| 6190 | p->mark = mark; |
| 6191 | } |
| 6192 | { // gt_bitwise_or |
| 6193 | CmpopExprPair* gt_bitwise_or_var; |
| 6194 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6195 | (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6196 | ) |
| 6197 | { |
| 6198 | res = gt_bitwise_or_var; |
| 6199 | goto done; |
| 6200 | } |
| 6201 | p->mark = mark; |
| 6202 | } |
| 6203 | { // notin_bitwise_or |
| 6204 | CmpopExprPair* notin_bitwise_or_var; |
| 6205 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6206 | (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6207 | ) |
| 6208 | { |
| 6209 | res = notin_bitwise_or_var; |
| 6210 | goto done; |
| 6211 | } |
| 6212 | p->mark = mark; |
| 6213 | } |
| 6214 | { // in_bitwise_or |
| 6215 | CmpopExprPair* in_bitwise_or_var; |
| 6216 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6217 | (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6218 | ) |
| 6219 | { |
| 6220 | res = in_bitwise_or_var; |
| 6221 | goto done; |
| 6222 | } |
| 6223 | p->mark = mark; |
| 6224 | } |
| 6225 | { // isnot_bitwise_or |
| 6226 | CmpopExprPair* isnot_bitwise_or_var; |
| 6227 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6228 | (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6229 | ) |
| 6230 | { |
| 6231 | res = isnot_bitwise_or_var; |
| 6232 | goto done; |
| 6233 | } |
| 6234 | p->mark = mark; |
| 6235 | } |
| 6236 | { // is_bitwise_or |
| 6237 | CmpopExprPair* is_bitwise_or_var; |
| 6238 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6239 | (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6240 | ) |
| 6241 | { |
| 6242 | res = is_bitwise_or_var; |
| 6243 | goto done; |
| 6244 | } |
| 6245 | p->mark = mark; |
| 6246 | } |
| 6247 | res = NULL; |
| 6248 | done: |
| 6249 | return res; |
| 6250 | } |
| 6251 | |
| 6252 | // eq_bitwise_or: '==' bitwise_or |
| 6253 | static CmpopExprPair* |
| 6254 | eq_bitwise_or_rule(Parser *p) |
| 6255 | { |
| 6256 | if (p->error_indicator) { |
| 6257 | return NULL; |
| 6258 | } |
| 6259 | CmpopExprPair* res = NULL; |
| 6260 | int mark = p->mark; |
| 6261 | { // '==' bitwise_or |
| 6262 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6263 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6264 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6265 | (literal = _PyPegen_expect_token(p, 27)) // token='==' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6266 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6267 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6268 | ) |
| 6269 | { |
| 6270 | res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); |
| 6271 | if (res == NULL && PyErr_Occurred()) { |
| 6272 | p->error_indicator = 1; |
| 6273 | return NULL; |
| 6274 | } |
| 6275 | goto done; |
| 6276 | } |
| 6277 | p->mark = mark; |
| 6278 | } |
| 6279 | res = NULL; |
| 6280 | done: |
| 6281 | return res; |
| 6282 | } |
| 6283 | |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6284 | // noteq_bitwise_or: ('!=') bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6285 | static CmpopExprPair* |
| 6286 | noteq_bitwise_or_rule(Parser *p) |
| 6287 | { |
| 6288 | if (p->error_indicator) { |
| 6289 | return NULL; |
| 6290 | } |
| 6291 | CmpopExprPair* res = NULL; |
| 6292 | int mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6293 | { // ('!=') bitwise_or |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6294 | void *_tmp_92_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6295 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6296 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6297 | (_tmp_92_var = _tmp_92_rule(p)) // '!=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6298 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6299 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6300 | ) |
| 6301 | { |
| 6302 | res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); |
| 6303 | if (res == NULL && PyErr_Occurred()) { |
| 6304 | p->error_indicator = 1; |
| 6305 | return NULL; |
| 6306 | } |
| 6307 | goto done; |
| 6308 | } |
| 6309 | p->mark = mark; |
| 6310 | } |
| 6311 | res = NULL; |
| 6312 | done: |
| 6313 | return res; |
| 6314 | } |
| 6315 | |
| 6316 | // lte_bitwise_or: '<=' bitwise_or |
| 6317 | static CmpopExprPair* |
| 6318 | lte_bitwise_or_rule(Parser *p) |
| 6319 | { |
| 6320 | if (p->error_indicator) { |
| 6321 | return NULL; |
| 6322 | } |
| 6323 | CmpopExprPair* res = NULL; |
| 6324 | int mark = p->mark; |
| 6325 | { // '<=' bitwise_or |
| 6326 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6327 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6328 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6329 | (literal = _PyPegen_expect_token(p, 29)) // token='<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6330 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6331 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6332 | ) |
| 6333 | { |
| 6334 | res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); |
| 6335 | if (res == NULL && PyErr_Occurred()) { |
| 6336 | p->error_indicator = 1; |
| 6337 | return NULL; |
| 6338 | } |
| 6339 | goto done; |
| 6340 | } |
| 6341 | p->mark = mark; |
| 6342 | } |
| 6343 | res = NULL; |
| 6344 | done: |
| 6345 | return res; |
| 6346 | } |
| 6347 | |
| 6348 | // lt_bitwise_or: '<' bitwise_or |
| 6349 | static CmpopExprPair* |
| 6350 | lt_bitwise_or_rule(Parser *p) |
| 6351 | { |
| 6352 | if (p->error_indicator) { |
| 6353 | return NULL; |
| 6354 | } |
| 6355 | CmpopExprPair* res = NULL; |
| 6356 | int mark = p->mark; |
| 6357 | { // '<' bitwise_or |
| 6358 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6359 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6360 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6361 | (literal = _PyPegen_expect_token(p, 20)) // token='<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6362 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6363 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6364 | ) |
| 6365 | { |
| 6366 | res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); |
| 6367 | if (res == NULL && PyErr_Occurred()) { |
| 6368 | p->error_indicator = 1; |
| 6369 | return NULL; |
| 6370 | } |
| 6371 | goto done; |
| 6372 | } |
| 6373 | p->mark = mark; |
| 6374 | } |
| 6375 | res = NULL; |
| 6376 | done: |
| 6377 | return res; |
| 6378 | } |
| 6379 | |
| 6380 | // gte_bitwise_or: '>=' bitwise_or |
| 6381 | static CmpopExprPair* |
| 6382 | gte_bitwise_or_rule(Parser *p) |
| 6383 | { |
| 6384 | if (p->error_indicator) { |
| 6385 | return NULL; |
| 6386 | } |
| 6387 | CmpopExprPair* res = NULL; |
| 6388 | int mark = p->mark; |
| 6389 | { // '>=' bitwise_or |
| 6390 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6391 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6392 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6393 | (literal = _PyPegen_expect_token(p, 30)) // token='>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6394 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6395 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6396 | ) |
| 6397 | { |
| 6398 | res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); |
| 6399 | if (res == NULL && PyErr_Occurred()) { |
| 6400 | p->error_indicator = 1; |
| 6401 | return NULL; |
| 6402 | } |
| 6403 | goto done; |
| 6404 | } |
| 6405 | p->mark = mark; |
| 6406 | } |
| 6407 | res = NULL; |
| 6408 | done: |
| 6409 | return res; |
| 6410 | } |
| 6411 | |
| 6412 | // gt_bitwise_or: '>' bitwise_or |
| 6413 | static CmpopExprPair* |
| 6414 | gt_bitwise_or_rule(Parser *p) |
| 6415 | { |
| 6416 | if (p->error_indicator) { |
| 6417 | return NULL; |
| 6418 | } |
| 6419 | CmpopExprPair* res = NULL; |
| 6420 | int mark = p->mark; |
| 6421 | { // '>' bitwise_or |
| 6422 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6423 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6424 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6425 | (literal = _PyPegen_expect_token(p, 21)) // token='>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6426 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6427 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6428 | ) |
| 6429 | { |
| 6430 | res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); |
| 6431 | if (res == NULL && PyErr_Occurred()) { |
| 6432 | p->error_indicator = 1; |
| 6433 | return NULL; |
| 6434 | } |
| 6435 | goto done; |
| 6436 | } |
| 6437 | p->mark = mark; |
| 6438 | } |
| 6439 | res = NULL; |
| 6440 | done: |
| 6441 | return res; |
| 6442 | } |
| 6443 | |
| 6444 | // notin_bitwise_or: 'not' 'in' bitwise_or |
| 6445 | static CmpopExprPair* |
| 6446 | notin_bitwise_or_rule(Parser *p) |
| 6447 | { |
| 6448 | if (p->error_indicator) { |
| 6449 | return NULL; |
| 6450 | } |
| 6451 | CmpopExprPair* res = NULL; |
| 6452 | int mark = p->mark; |
| 6453 | { // 'not' 'in' bitwise_or |
| 6454 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6455 | Token * keyword; |
| 6456 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6457 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6458 | (keyword = _PyPegen_expect_token(p, 525)) // token='not' |
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 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6461 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6462 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6463 | ) |
| 6464 | { |
| 6465 | res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); |
| 6466 | if (res == NULL && PyErr_Occurred()) { |
| 6467 | p->error_indicator = 1; |
| 6468 | return NULL; |
| 6469 | } |
| 6470 | goto done; |
| 6471 | } |
| 6472 | p->mark = mark; |
| 6473 | } |
| 6474 | res = NULL; |
| 6475 | done: |
| 6476 | return res; |
| 6477 | } |
| 6478 | |
| 6479 | // in_bitwise_or: 'in' bitwise_or |
| 6480 | static CmpopExprPair* |
| 6481 | in_bitwise_or_rule(Parser *p) |
| 6482 | { |
| 6483 | if (p->error_indicator) { |
| 6484 | return NULL; |
| 6485 | } |
| 6486 | CmpopExprPair* res = NULL; |
| 6487 | int mark = p->mark; |
| 6488 | { // 'in' bitwise_or |
| 6489 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6490 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6491 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6492 | (keyword = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6493 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6494 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6495 | ) |
| 6496 | { |
| 6497 | res = _PyPegen_cmpop_expr_pair ( p , In , a ); |
| 6498 | if (res == NULL && PyErr_Occurred()) { |
| 6499 | p->error_indicator = 1; |
| 6500 | return NULL; |
| 6501 | } |
| 6502 | goto done; |
| 6503 | } |
| 6504 | p->mark = mark; |
| 6505 | } |
| 6506 | res = NULL; |
| 6507 | done: |
| 6508 | return res; |
| 6509 | } |
| 6510 | |
| 6511 | // isnot_bitwise_or: 'is' 'not' bitwise_or |
| 6512 | static CmpopExprPair* |
| 6513 | isnot_bitwise_or_rule(Parser *p) |
| 6514 | { |
| 6515 | if (p->error_indicator) { |
| 6516 | return NULL; |
| 6517 | } |
| 6518 | CmpopExprPair* res = NULL; |
| 6519 | int mark = p->mark; |
| 6520 | { // 'is' 'not' bitwise_or |
| 6521 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6522 | Token * keyword; |
| 6523 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6524 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6525 | (keyword = _PyPegen_expect_token(p, 526)) // token='is' |
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 | (keyword_1 = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6528 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6529 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6530 | ) |
| 6531 | { |
| 6532 | res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); |
| 6533 | if (res == NULL && PyErr_Occurred()) { |
| 6534 | p->error_indicator = 1; |
| 6535 | return NULL; |
| 6536 | } |
| 6537 | goto done; |
| 6538 | } |
| 6539 | p->mark = mark; |
| 6540 | } |
| 6541 | res = NULL; |
| 6542 | done: |
| 6543 | return res; |
| 6544 | } |
| 6545 | |
| 6546 | // is_bitwise_or: 'is' bitwise_or |
| 6547 | static CmpopExprPair* |
| 6548 | is_bitwise_or_rule(Parser *p) |
| 6549 | { |
| 6550 | if (p->error_indicator) { |
| 6551 | return NULL; |
| 6552 | } |
| 6553 | CmpopExprPair* res = NULL; |
| 6554 | int mark = p->mark; |
| 6555 | { // 'is' bitwise_or |
| 6556 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6557 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6558 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6559 | (keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6560 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6561 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6562 | ) |
| 6563 | { |
| 6564 | res = _PyPegen_cmpop_expr_pair ( p , Is , a ); |
| 6565 | if (res == NULL && PyErr_Occurred()) { |
| 6566 | p->error_indicator = 1; |
| 6567 | return NULL; |
| 6568 | } |
| 6569 | goto done; |
| 6570 | } |
| 6571 | p->mark = mark; |
| 6572 | } |
| 6573 | res = NULL; |
| 6574 | done: |
| 6575 | return res; |
| 6576 | } |
| 6577 | |
| 6578 | // Left-recursive |
| 6579 | // bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor |
| 6580 | static expr_ty bitwise_or_raw(Parser *); |
| 6581 | static expr_ty |
| 6582 | bitwise_or_rule(Parser *p) |
| 6583 | { |
| 6584 | expr_ty res = NULL; |
| 6585 | if (_PyPegen_is_memoized(p, bitwise_or_type, &res)) |
| 6586 | return res; |
| 6587 | int mark = p->mark; |
| 6588 | int resmark = p->mark; |
| 6589 | while (1) { |
| 6590 | int tmpvar_1 = _PyPegen_update_memo(p, mark, bitwise_or_type, res); |
| 6591 | if (tmpvar_1) { |
| 6592 | return res; |
| 6593 | } |
| 6594 | p->mark = mark; |
| 6595 | void *raw = bitwise_or_raw(p); |
| 6596 | if (raw == NULL || p->mark <= resmark) |
| 6597 | break; |
| 6598 | resmark = p->mark; |
| 6599 | res = raw; |
| 6600 | } |
| 6601 | p->mark = resmark; |
| 6602 | return res; |
| 6603 | } |
| 6604 | static expr_ty |
| 6605 | bitwise_or_raw(Parser *p) |
| 6606 | { |
| 6607 | if (p->error_indicator) { |
| 6608 | return NULL; |
| 6609 | } |
| 6610 | expr_ty res = NULL; |
| 6611 | int mark = p->mark; |
| 6612 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6613 | p->error_indicator = 1; |
| 6614 | return NULL; |
| 6615 | } |
| 6616 | int start_lineno = p->tokens[mark]->lineno; |
| 6617 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6618 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6619 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6620 | { // bitwise_or '|' bitwise_xor |
| 6621 | expr_ty a; |
| 6622 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6623 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6624 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6625 | (a = bitwise_or_rule(p)) // bitwise_or |
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 | (literal = _PyPegen_expect_token(p, 18)) // token='|' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6628 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6629 | (b = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6630 | ) |
| 6631 | { |
| 6632 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6633 | if (token == NULL) { |
| 6634 | return NULL; |
| 6635 | } |
| 6636 | int end_lineno = token->end_lineno; |
| 6637 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6638 | int end_col_offset = token->end_col_offset; |
| 6639 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6640 | res = _Py_BinOp ( a , BitOr , b , EXTRA ); |
| 6641 | if (res == NULL && PyErr_Occurred()) { |
| 6642 | p->error_indicator = 1; |
| 6643 | return NULL; |
| 6644 | } |
| 6645 | goto done; |
| 6646 | } |
| 6647 | p->mark = mark; |
| 6648 | } |
| 6649 | { // bitwise_xor |
| 6650 | expr_ty bitwise_xor_var; |
| 6651 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6652 | (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6653 | ) |
| 6654 | { |
| 6655 | res = bitwise_xor_var; |
| 6656 | goto done; |
| 6657 | } |
| 6658 | p->mark = mark; |
| 6659 | } |
| 6660 | res = NULL; |
| 6661 | done: |
| 6662 | return res; |
| 6663 | } |
| 6664 | |
| 6665 | // Left-recursive |
| 6666 | // bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and |
| 6667 | static expr_ty bitwise_xor_raw(Parser *); |
| 6668 | static expr_ty |
| 6669 | bitwise_xor_rule(Parser *p) |
| 6670 | { |
| 6671 | expr_ty res = NULL; |
| 6672 | if (_PyPegen_is_memoized(p, bitwise_xor_type, &res)) |
| 6673 | return res; |
| 6674 | int mark = p->mark; |
| 6675 | int resmark = p->mark; |
| 6676 | while (1) { |
| 6677 | int tmpvar_2 = _PyPegen_update_memo(p, mark, bitwise_xor_type, res); |
| 6678 | if (tmpvar_2) { |
| 6679 | return res; |
| 6680 | } |
| 6681 | p->mark = mark; |
| 6682 | void *raw = bitwise_xor_raw(p); |
| 6683 | if (raw == NULL || p->mark <= resmark) |
| 6684 | break; |
| 6685 | resmark = p->mark; |
| 6686 | res = raw; |
| 6687 | } |
| 6688 | p->mark = resmark; |
| 6689 | return res; |
| 6690 | } |
| 6691 | static expr_ty |
| 6692 | bitwise_xor_raw(Parser *p) |
| 6693 | { |
| 6694 | if (p->error_indicator) { |
| 6695 | return NULL; |
| 6696 | } |
| 6697 | expr_ty res = NULL; |
| 6698 | int mark = p->mark; |
| 6699 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6700 | p->error_indicator = 1; |
| 6701 | return NULL; |
| 6702 | } |
| 6703 | int start_lineno = p->tokens[mark]->lineno; |
| 6704 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6705 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6706 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6707 | { // bitwise_xor '^' bitwise_and |
| 6708 | expr_ty a; |
| 6709 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6710 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6711 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6712 | (a = bitwise_xor_rule(p)) // bitwise_xor |
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 | (literal = _PyPegen_expect_token(p, 32)) // token='^' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6715 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6716 | (b = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6717 | ) |
| 6718 | { |
| 6719 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6720 | if (token == NULL) { |
| 6721 | return NULL; |
| 6722 | } |
| 6723 | int end_lineno = token->end_lineno; |
| 6724 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6725 | int end_col_offset = token->end_col_offset; |
| 6726 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6727 | res = _Py_BinOp ( a , BitXor , b , EXTRA ); |
| 6728 | if (res == NULL && PyErr_Occurred()) { |
| 6729 | p->error_indicator = 1; |
| 6730 | return NULL; |
| 6731 | } |
| 6732 | goto done; |
| 6733 | } |
| 6734 | p->mark = mark; |
| 6735 | } |
| 6736 | { // bitwise_and |
| 6737 | expr_ty bitwise_and_var; |
| 6738 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6739 | (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6740 | ) |
| 6741 | { |
| 6742 | res = bitwise_and_var; |
| 6743 | goto done; |
| 6744 | } |
| 6745 | p->mark = mark; |
| 6746 | } |
| 6747 | res = NULL; |
| 6748 | done: |
| 6749 | return res; |
| 6750 | } |
| 6751 | |
| 6752 | // Left-recursive |
| 6753 | // bitwise_and: bitwise_and '&' shift_expr | shift_expr |
| 6754 | static expr_ty bitwise_and_raw(Parser *); |
| 6755 | static expr_ty |
| 6756 | bitwise_and_rule(Parser *p) |
| 6757 | { |
| 6758 | expr_ty res = NULL; |
| 6759 | if (_PyPegen_is_memoized(p, bitwise_and_type, &res)) |
| 6760 | return res; |
| 6761 | int mark = p->mark; |
| 6762 | int resmark = p->mark; |
| 6763 | while (1) { |
| 6764 | int tmpvar_3 = _PyPegen_update_memo(p, mark, bitwise_and_type, res); |
| 6765 | if (tmpvar_3) { |
| 6766 | return res; |
| 6767 | } |
| 6768 | p->mark = mark; |
| 6769 | void *raw = bitwise_and_raw(p); |
| 6770 | if (raw == NULL || p->mark <= resmark) |
| 6771 | break; |
| 6772 | resmark = p->mark; |
| 6773 | res = raw; |
| 6774 | } |
| 6775 | p->mark = resmark; |
| 6776 | return res; |
| 6777 | } |
| 6778 | static expr_ty |
| 6779 | bitwise_and_raw(Parser *p) |
| 6780 | { |
| 6781 | if (p->error_indicator) { |
| 6782 | return NULL; |
| 6783 | } |
| 6784 | expr_ty res = NULL; |
| 6785 | int mark = p->mark; |
| 6786 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6787 | p->error_indicator = 1; |
| 6788 | return NULL; |
| 6789 | } |
| 6790 | int start_lineno = p->tokens[mark]->lineno; |
| 6791 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6792 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6793 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6794 | { // bitwise_and '&' shift_expr |
| 6795 | expr_ty a; |
| 6796 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6797 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6798 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6799 | (a = bitwise_and_rule(p)) // bitwise_and |
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 | (literal = _PyPegen_expect_token(p, 19)) // token='&' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6802 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6803 | (b = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6804 | ) |
| 6805 | { |
| 6806 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6807 | if (token == NULL) { |
| 6808 | return NULL; |
| 6809 | } |
| 6810 | int end_lineno = token->end_lineno; |
| 6811 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6812 | int end_col_offset = token->end_col_offset; |
| 6813 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6814 | res = _Py_BinOp ( a , BitAnd , b , EXTRA ); |
| 6815 | if (res == NULL && PyErr_Occurred()) { |
| 6816 | p->error_indicator = 1; |
| 6817 | return NULL; |
| 6818 | } |
| 6819 | goto done; |
| 6820 | } |
| 6821 | p->mark = mark; |
| 6822 | } |
| 6823 | { // shift_expr |
| 6824 | expr_ty shift_expr_var; |
| 6825 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6826 | (shift_expr_var = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6827 | ) |
| 6828 | { |
| 6829 | res = shift_expr_var; |
| 6830 | goto done; |
| 6831 | } |
| 6832 | p->mark = mark; |
| 6833 | } |
| 6834 | res = NULL; |
| 6835 | done: |
| 6836 | return res; |
| 6837 | } |
| 6838 | |
| 6839 | // Left-recursive |
| 6840 | // shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum |
| 6841 | static expr_ty shift_expr_raw(Parser *); |
| 6842 | static expr_ty |
| 6843 | shift_expr_rule(Parser *p) |
| 6844 | { |
| 6845 | expr_ty res = NULL; |
| 6846 | if (_PyPegen_is_memoized(p, shift_expr_type, &res)) |
| 6847 | return res; |
| 6848 | int mark = p->mark; |
| 6849 | int resmark = p->mark; |
| 6850 | while (1) { |
| 6851 | int tmpvar_4 = _PyPegen_update_memo(p, mark, shift_expr_type, res); |
| 6852 | if (tmpvar_4) { |
| 6853 | return res; |
| 6854 | } |
| 6855 | p->mark = mark; |
| 6856 | void *raw = shift_expr_raw(p); |
| 6857 | if (raw == NULL || p->mark <= resmark) |
| 6858 | break; |
| 6859 | resmark = p->mark; |
| 6860 | res = raw; |
| 6861 | } |
| 6862 | p->mark = resmark; |
| 6863 | return res; |
| 6864 | } |
| 6865 | static expr_ty |
| 6866 | shift_expr_raw(Parser *p) |
| 6867 | { |
| 6868 | if (p->error_indicator) { |
| 6869 | return NULL; |
| 6870 | } |
| 6871 | expr_ty res = NULL; |
| 6872 | int mark = p->mark; |
| 6873 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6874 | p->error_indicator = 1; |
| 6875 | return NULL; |
| 6876 | } |
| 6877 | int start_lineno = p->tokens[mark]->lineno; |
| 6878 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6879 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6880 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6881 | { // shift_expr '<<' sum |
| 6882 | expr_ty a; |
| 6883 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6884 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6885 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6886 | (a = shift_expr_rule(p)) // shift_expr |
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 | (literal = _PyPegen_expect_token(p, 33)) // token='<<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6889 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6890 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6891 | ) |
| 6892 | { |
| 6893 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6894 | if (token == NULL) { |
| 6895 | return NULL; |
| 6896 | } |
| 6897 | int end_lineno = token->end_lineno; |
| 6898 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6899 | int end_col_offset = token->end_col_offset; |
| 6900 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6901 | res = _Py_BinOp ( a , LShift , b , EXTRA ); |
| 6902 | if (res == NULL && PyErr_Occurred()) { |
| 6903 | p->error_indicator = 1; |
| 6904 | return NULL; |
| 6905 | } |
| 6906 | goto done; |
| 6907 | } |
| 6908 | p->mark = mark; |
| 6909 | } |
| 6910 | { // shift_expr '>>' sum |
| 6911 | expr_ty a; |
| 6912 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6913 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6914 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6915 | (a = shift_expr_rule(p)) // shift_expr |
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 | (literal = _PyPegen_expect_token(p, 34)) // token='>>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6918 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6919 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6920 | ) |
| 6921 | { |
| 6922 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6923 | if (token == NULL) { |
| 6924 | return NULL; |
| 6925 | } |
| 6926 | int end_lineno = token->end_lineno; |
| 6927 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6928 | int end_col_offset = token->end_col_offset; |
| 6929 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6930 | res = _Py_BinOp ( a , RShift , b , EXTRA ); |
| 6931 | if (res == NULL && PyErr_Occurred()) { |
| 6932 | p->error_indicator = 1; |
| 6933 | return NULL; |
| 6934 | } |
| 6935 | goto done; |
| 6936 | } |
| 6937 | p->mark = mark; |
| 6938 | } |
| 6939 | { // sum |
| 6940 | expr_ty sum_var; |
| 6941 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6942 | (sum_var = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6943 | ) |
| 6944 | { |
| 6945 | res = sum_var; |
| 6946 | goto done; |
| 6947 | } |
| 6948 | p->mark = mark; |
| 6949 | } |
| 6950 | res = NULL; |
| 6951 | done: |
| 6952 | return res; |
| 6953 | } |
| 6954 | |
| 6955 | // Left-recursive |
| 6956 | // sum: sum '+' term | sum '-' term | term |
| 6957 | static expr_ty sum_raw(Parser *); |
| 6958 | static expr_ty |
| 6959 | sum_rule(Parser *p) |
| 6960 | { |
| 6961 | expr_ty res = NULL; |
| 6962 | if (_PyPegen_is_memoized(p, sum_type, &res)) |
| 6963 | return res; |
| 6964 | int mark = p->mark; |
| 6965 | int resmark = p->mark; |
| 6966 | while (1) { |
| 6967 | int tmpvar_5 = _PyPegen_update_memo(p, mark, sum_type, res); |
| 6968 | if (tmpvar_5) { |
| 6969 | return res; |
| 6970 | } |
| 6971 | p->mark = mark; |
| 6972 | void *raw = sum_raw(p); |
| 6973 | if (raw == NULL || p->mark <= resmark) |
| 6974 | break; |
| 6975 | resmark = p->mark; |
| 6976 | res = raw; |
| 6977 | } |
| 6978 | p->mark = resmark; |
| 6979 | return res; |
| 6980 | } |
| 6981 | static expr_ty |
| 6982 | sum_raw(Parser *p) |
| 6983 | { |
| 6984 | if (p->error_indicator) { |
| 6985 | return NULL; |
| 6986 | } |
| 6987 | expr_ty res = NULL; |
| 6988 | int mark = p->mark; |
| 6989 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6990 | p->error_indicator = 1; |
| 6991 | return NULL; |
| 6992 | } |
| 6993 | int start_lineno = p->tokens[mark]->lineno; |
| 6994 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6995 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6996 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6997 | { // sum '+' term |
| 6998 | expr_ty a; |
| 6999 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7000 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7001 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7002 | (a = sum_rule(p)) // sum |
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 | (literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7005 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7006 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7007 | ) |
| 7008 | { |
| 7009 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7010 | if (token == NULL) { |
| 7011 | return NULL; |
| 7012 | } |
| 7013 | int end_lineno = token->end_lineno; |
| 7014 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7015 | int end_col_offset = token->end_col_offset; |
| 7016 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7017 | res = _Py_BinOp ( a , Add , b , EXTRA ); |
| 7018 | if (res == NULL && PyErr_Occurred()) { |
| 7019 | p->error_indicator = 1; |
| 7020 | return NULL; |
| 7021 | } |
| 7022 | goto done; |
| 7023 | } |
| 7024 | p->mark = mark; |
| 7025 | } |
| 7026 | { // sum '-' term |
| 7027 | expr_ty a; |
| 7028 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7029 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7030 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7031 | (a = sum_rule(p)) // sum |
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 | (literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7034 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7035 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7036 | ) |
| 7037 | { |
| 7038 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7039 | if (token == NULL) { |
| 7040 | return NULL; |
| 7041 | } |
| 7042 | int end_lineno = token->end_lineno; |
| 7043 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7044 | int end_col_offset = token->end_col_offset; |
| 7045 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7046 | res = _Py_BinOp ( a , Sub , b , EXTRA ); |
| 7047 | if (res == NULL && PyErr_Occurred()) { |
| 7048 | p->error_indicator = 1; |
| 7049 | return NULL; |
| 7050 | } |
| 7051 | goto done; |
| 7052 | } |
| 7053 | p->mark = mark; |
| 7054 | } |
| 7055 | { // term |
| 7056 | expr_ty term_var; |
| 7057 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7058 | (term_var = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7059 | ) |
| 7060 | { |
| 7061 | res = term_var; |
| 7062 | goto done; |
| 7063 | } |
| 7064 | p->mark = mark; |
| 7065 | } |
| 7066 | res = NULL; |
| 7067 | done: |
| 7068 | return res; |
| 7069 | } |
| 7070 | |
| 7071 | // Left-recursive |
| 7072 | // term: |
| 7073 | // | term '*' factor |
| 7074 | // | term '/' factor |
| 7075 | // | term '//' factor |
| 7076 | // | term '%' factor |
| 7077 | // | term '@' factor |
| 7078 | // | factor |
| 7079 | static expr_ty term_raw(Parser *); |
| 7080 | static expr_ty |
| 7081 | term_rule(Parser *p) |
| 7082 | { |
| 7083 | expr_ty res = NULL; |
| 7084 | if (_PyPegen_is_memoized(p, term_type, &res)) |
| 7085 | return res; |
| 7086 | int mark = p->mark; |
| 7087 | int resmark = p->mark; |
| 7088 | while (1) { |
| 7089 | int tmpvar_6 = _PyPegen_update_memo(p, mark, term_type, res); |
| 7090 | if (tmpvar_6) { |
| 7091 | return res; |
| 7092 | } |
| 7093 | p->mark = mark; |
| 7094 | void *raw = term_raw(p); |
| 7095 | if (raw == NULL || p->mark <= resmark) |
| 7096 | break; |
| 7097 | resmark = p->mark; |
| 7098 | res = raw; |
| 7099 | } |
| 7100 | p->mark = resmark; |
| 7101 | return res; |
| 7102 | } |
| 7103 | static expr_ty |
| 7104 | term_raw(Parser *p) |
| 7105 | { |
| 7106 | if (p->error_indicator) { |
| 7107 | return NULL; |
| 7108 | } |
| 7109 | expr_ty res = NULL; |
| 7110 | int mark = p->mark; |
| 7111 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7112 | p->error_indicator = 1; |
| 7113 | return NULL; |
| 7114 | } |
| 7115 | int start_lineno = p->tokens[mark]->lineno; |
| 7116 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7117 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7118 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7119 | { // term '*' factor |
| 7120 | expr_ty a; |
| 7121 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7122 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7123 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7124 | (a = term_rule(p)) // term |
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 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7127 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7128 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7129 | ) |
| 7130 | { |
| 7131 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7132 | if (token == NULL) { |
| 7133 | return NULL; |
| 7134 | } |
| 7135 | int end_lineno = token->end_lineno; |
| 7136 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7137 | int end_col_offset = token->end_col_offset; |
| 7138 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7139 | res = _Py_BinOp ( a , Mult , b , EXTRA ); |
| 7140 | if (res == NULL && PyErr_Occurred()) { |
| 7141 | p->error_indicator = 1; |
| 7142 | return NULL; |
| 7143 | } |
| 7144 | goto done; |
| 7145 | } |
| 7146 | p->mark = mark; |
| 7147 | } |
| 7148 | { // term '/' factor |
| 7149 | expr_ty a; |
| 7150 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7151 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7152 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7153 | (a = term_rule(p)) // term |
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 | (literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7156 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7157 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7158 | ) |
| 7159 | { |
| 7160 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7161 | if (token == NULL) { |
| 7162 | return NULL; |
| 7163 | } |
| 7164 | int end_lineno = token->end_lineno; |
| 7165 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7166 | int end_col_offset = token->end_col_offset; |
| 7167 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7168 | res = _Py_BinOp ( a , Div , b , EXTRA ); |
| 7169 | if (res == NULL && PyErr_Occurred()) { |
| 7170 | p->error_indicator = 1; |
| 7171 | return NULL; |
| 7172 | } |
| 7173 | goto done; |
| 7174 | } |
| 7175 | p->mark = mark; |
| 7176 | } |
| 7177 | { // term '//' factor |
| 7178 | expr_ty a; |
| 7179 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7180 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7181 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7182 | (a = term_rule(p)) // term |
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 | (literal = _PyPegen_expect_token(p, 47)) // token='//' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7185 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7186 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7187 | ) |
| 7188 | { |
| 7189 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7190 | if (token == NULL) { |
| 7191 | return NULL; |
| 7192 | } |
| 7193 | int end_lineno = token->end_lineno; |
| 7194 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7195 | int end_col_offset = token->end_col_offset; |
| 7196 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7197 | res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); |
| 7198 | if (res == NULL && PyErr_Occurred()) { |
| 7199 | p->error_indicator = 1; |
| 7200 | return NULL; |
| 7201 | } |
| 7202 | goto done; |
| 7203 | } |
| 7204 | p->mark = mark; |
| 7205 | } |
| 7206 | { // term '%' factor |
| 7207 | expr_ty a; |
| 7208 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7209 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7210 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7211 | (a = term_rule(p)) // term |
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 | (literal = _PyPegen_expect_token(p, 24)) // token='%' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7214 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7215 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7216 | ) |
| 7217 | { |
| 7218 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7219 | if (token == NULL) { |
| 7220 | return NULL; |
| 7221 | } |
| 7222 | int end_lineno = token->end_lineno; |
| 7223 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7224 | int end_col_offset = token->end_col_offset; |
| 7225 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7226 | res = _Py_BinOp ( a , Mod , b , EXTRA ); |
| 7227 | if (res == NULL && PyErr_Occurred()) { |
| 7228 | p->error_indicator = 1; |
| 7229 | return NULL; |
| 7230 | } |
| 7231 | goto done; |
| 7232 | } |
| 7233 | p->mark = mark; |
| 7234 | } |
| 7235 | { // term '@' factor |
| 7236 | expr_ty a; |
| 7237 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7238 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7239 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7240 | (a = term_rule(p)) // term |
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 | (literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7243 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7244 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7245 | ) |
| 7246 | { |
| 7247 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7248 | if (token == NULL) { |
| 7249 | return NULL; |
| 7250 | } |
| 7251 | int end_lineno = token->end_lineno; |
| 7252 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7253 | int end_col_offset = token->end_col_offset; |
| 7254 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 7255 | 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] | 7256 | if (res == NULL && PyErr_Occurred()) { |
| 7257 | p->error_indicator = 1; |
| 7258 | return NULL; |
| 7259 | } |
| 7260 | goto done; |
| 7261 | } |
| 7262 | p->mark = mark; |
| 7263 | } |
| 7264 | { // factor |
| 7265 | expr_ty factor_var; |
| 7266 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7267 | (factor_var = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7268 | ) |
| 7269 | { |
| 7270 | res = factor_var; |
| 7271 | goto done; |
| 7272 | } |
| 7273 | p->mark = mark; |
| 7274 | } |
| 7275 | res = NULL; |
| 7276 | done: |
| 7277 | return res; |
| 7278 | } |
| 7279 | |
| 7280 | // factor: '+' factor | '-' factor | '~' factor | power |
| 7281 | static expr_ty |
| 7282 | factor_rule(Parser *p) |
| 7283 | { |
| 7284 | if (p->error_indicator) { |
| 7285 | return NULL; |
| 7286 | } |
| 7287 | expr_ty res = NULL; |
| 7288 | if (_PyPegen_is_memoized(p, factor_type, &res)) |
| 7289 | return res; |
| 7290 | int mark = p->mark; |
| 7291 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7292 | p->error_indicator = 1; |
| 7293 | return NULL; |
| 7294 | } |
| 7295 | int start_lineno = p->tokens[mark]->lineno; |
| 7296 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7297 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7298 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7299 | { // '+' factor |
| 7300 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7301 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7302 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7303 | (literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7304 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7305 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7306 | ) |
| 7307 | { |
| 7308 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7309 | if (token == NULL) { |
| 7310 | return NULL; |
| 7311 | } |
| 7312 | int end_lineno = token->end_lineno; |
| 7313 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7314 | int end_col_offset = token->end_col_offset; |
| 7315 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7316 | res = _Py_UnaryOp ( UAdd , a , EXTRA ); |
| 7317 | if (res == NULL && PyErr_Occurred()) { |
| 7318 | p->error_indicator = 1; |
| 7319 | return NULL; |
| 7320 | } |
| 7321 | goto done; |
| 7322 | } |
| 7323 | p->mark = mark; |
| 7324 | } |
| 7325 | { // '-' factor |
| 7326 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7327 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7328 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7329 | (literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7330 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7331 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7332 | ) |
| 7333 | { |
| 7334 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7335 | if (token == NULL) { |
| 7336 | return NULL; |
| 7337 | } |
| 7338 | int end_lineno = token->end_lineno; |
| 7339 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7340 | int end_col_offset = token->end_col_offset; |
| 7341 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7342 | res = _Py_UnaryOp ( USub , a , EXTRA ); |
| 7343 | if (res == NULL && PyErr_Occurred()) { |
| 7344 | p->error_indicator = 1; |
| 7345 | return NULL; |
| 7346 | } |
| 7347 | goto done; |
| 7348 | } |
| 7349 | p->mark = mark; |
| 7350 | } |
| 7351 | { // '~' factor |
| 7352 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7353 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7354 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7355 | (literal = _PyPegen_expect_token(p, 31)) // token='~' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7356 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7357 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7358 | ) |
| 7359 | { |
| 7360 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7361 | if (token == NULL) { |
| 7362 | return NULL; |
| 7363 | } |
| 7364 | int end_lineno = token->end_lineno; |
| 7365 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7366 | int end_col_offset = token->end_col_offset; |
| 7367 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7368 | res = _Py_UnaryOp ( Invert , a , EXTRA ); |
| 7369 | if (res == NULL && PyErr_Occurred()) { |
| 7370 | p->error_indicator = 1; |
| 7371 | return NULL; |
| 7372 | } |
| 7373 | goto done; |
| 7374 | } |
| 7375 | p->mark = mark; |
| 7376 | } |
| 7377 | { // power |
| 7378 | expr_ty power_var; |
| 7379 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7380 | (power_var = power_rule(p)) // power |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7381 | ) |
| 7382 | { |
| 7383 | res = power_var; |
| 7384 | goto done; |
| 7385 | } |
| 7386 | p->mark = mark; |
| 7387 | } |
| 7388 | res = NULL; |
| 7389 | done: |
| 7390 | _PyPegen_insert_memo(p, mark, factor_type, res); |
| 7391 | return res; |
| 7392 | } |
| 7393 | |
| 7394 | // power: await_primary '**' factor | await_primary |
| 7395 | static expr_ty |
| 7396 | power_rule(Parser *p) |
| 7397 | { |
| 7398 | if (p->error_indicator) { |
| 7399 | return NULL; |
| 7400 | } |
| 7401 | expr_ty res = NULL; |
| 7402 | int mark = p->mark; |
| 7403 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7404 | p->error_indicator = 1; |
| 7405 | return NULL; |
| 7406 | } |
| 7407 | int start_lineno = p->tokens[mark]->lineno; |
| 7408 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7409 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7410 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7411 | { // await_primary '**' factor |
| 7412 | expr_ty a; |
| 7413 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7414 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7415 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7416 | (a = await_primary_rule(p)) // await_primary |
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 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7419 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7420 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7421 | ) |
| 7422 | { |
| 7423 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7424 | if (token == NULL) { |
| 7425 | return NULL; |
| 7426 | } |
| 7427 | int end_lineno = token->end_lineno; |
| 7428 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7429 | int end_col_offset = token->end_col_offset; |
| 7430 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7431 | res = _Py_BinOp ( a , Pow , b , EXTRA ); |
| 7432 | if (res == NULL && PyErr_Occurred()) { |
| 7433 | p->error_indicator = 1; |
| 7434 | return NULL; |
| 7435 | } |
| 7436 | goto done; |
| 7437 | } |
| 7438 | p->mark = mark; |
| 7439 | } |
| 7440 | { // await_primary |
| 7441 | expr_ty await_primary_var; |
| 7442 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7443 | (await_primary_var = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7444 | ) |
| 7445 | { |
| 7446 | res = await_primary_var; |
| 7447 | goto done; |
| 7448 | } |
| 7449 | p->mark = mark; |
| 7450 | } |
| 7451 | res = NULL; |
| 7452 | done: |
| 7453 | return res; |
| 7454 | } |
| 7455 | |
| 7456 | // await_primary: AWAIT primary | primary |
| 7457 | static expr_ty |
| 7458 | await_primary_rule(Parser *p) |
| 7459 | { |
| 7460 | if (p->error_indicator) { |
| 7461 | return NULL; |
| 7462 | } |
| 7463 | expr_ty res = NULL; |
| 7464 | if (_PyPegen_is_memoized(p, await_primary_type, &res)) |
| 7465 | return res; |
| 7466 | int mark = p->mark; |
| 7467 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7468 | p->error_indicator = 1; |
| 7469 | return NULL; |
| 7470 | } |
| 7471 | int start_lineno = p->tokens[mark]->lineno; |
| 7472 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7473 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7474 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7475 | { // AWAIT primary |
| 7476 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7477 | Token * await_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7478 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7479 | (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7480 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7481 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7482 | ) |
| 7483 | { |
| 7484 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7485 | if (token == NULL) { |
| 7486 | return NULL; |
| 7487 | } |
| 7488 | int end_lineno = token->end_lineno; |
| 7489 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7490 | int end_col_offset = token->end_col_offset; |
| 7491 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 7492 | res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7493 | if (res == NULL && PyErr_Occurred()) { |
| 7494 | p->error_indicator = 1; |
| 7495 | return NULL; |
| 7496 | } |
| 7497 | goto done; |
| 7498 | } |
| 7499 | p->mark = mark; |
| 7500 | } |
| 7501 | { // primary |
| 7502 | expr_ty primary_var; |
| 7503 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7504 | (primary_var = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7505 | ) |
| 7506 | { |
| 7507 | res = primary_var; |
| 7508 | goto done; |
| 7509 | } |
| 7510 | p->mark = mark; |
| 7511 | } |
| 7512 | res = NULL; |
| 7513 | done: |
| 7514 | _PyPegen_insert_memo(p, mark, await_primary_type, res); |
| 7515 | return res; |
| 7516 | } |
| 7517 | |
| 7518 | // Left-recursive |
| 7519 | // primary: |
| 7520 | // | primary '.' NAME |
| 7521 | // | primary genexp |
| 7522 | // | primary '(' arguments? ')' |
| 7523 | // | primary '[' slices ']' |
| 7524 | // | atom |
| 7525 | static expr_ty primary_raw(Parser *); |
| 7526 | static expr_ty |
| 7527 | primary_rule(Parser *p) |
| 7528 | { |
| 7529 | expr_ty res = NULL; |
| 7530 | if (_PyPegen_is_memoized(p, primary_type, &res)) |
| 7531 | return res; |
| 7532 | int mark = p->mark; |
| 7533 | int resmark = p->mark; |
| 7534 | while (1) { |
| 7535 | int tmpvar_7 = _PyPegen_update_memo(p, mark, primary_type, res); |
| 7536 | if (tmpvar_7) { |
| 7537 | return res; |
| 7538 | } |
| 7539 | p->mark = mark; |
| 7540 | void *raw = primary_raw(p); |
| 7541 | if (raw == NULL || p->mark <= resmark) |
| 7542 | break; |
| 7543 | resmark = p->mark; |
| 7544 | res = raw; |
| 7545 | } |
| 7546 | p->mark = resmark; |
| 7547 | return res; |
| 7548 | } |
| 7549 | static expr_ty |
| 7550 | primary_raw(Parser *p) |
| 7551 | { |
| 7552 | if (p->error_indicator) { |
| 7553 | return NULL; |
| 7554 | } |
| 7555 | expr_ty res = NULL; |
| 7556 | int mark = p->mark; |
| 7557 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7558 | p->error_indicator = 1; |
| 7559 | return NULL; |
| 7560 | } |
| 7561 | int start_lineno = p->tokens[mark]->lineno; |
| 7562 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7563 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7564 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7565 | { // primary '.' NAME |
| 7566 | expr_ty a; |
| 7567 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7568 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7569 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7570 | (a = primary_rule(p)) // primary |
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 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7573 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7574 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7575 | ) |
| 7576 | { |
| 7577 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7578 | if (token == NULL) { |
| 7579 | return NULL; |
| 7580 | } |
| 7581 | int end_lineno = token->end_lineno; |
| 7582 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7583 | int end_col_offset = token->end_col_offset; |
| 7584 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7585 | res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 7586 | if (res == NULL && PyErr_Occurred()) { |
| 7587 | p->error_indicator = 1; |
| 7588 | return NULL; |
| 7589 | } |
| 7590 | goto done; |
| 7591 | } |
| 7592 | p->mark = mark; |
| 7593 | } |
| 7594 | { // primary genexp |
| 7595 | expr_ty a; |
| 7596 | expr_ty b; |
| 7597 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7598 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7599 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7600 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7601 | ) |
| 7602 | { |
| 7603 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7604 | if (token == NULL) { |
| 7605 | return NULL; |
| 7606 | } |
| 7607 | int end_lineno = token->end_lineno; |
| 7608 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7609 | int end_col_offset = token->end_col_offset; |
| 7610 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7611 | res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 7612 | if (res == NULL && PyErr_Occurred()) { |
| 7613 | p->error_indicator = 1; |
| 7614 | return NULL; |
| 7615 | } |
| 7616 | goto done; |
| 7617 | } |
| 7618 | p->mark = mark; |
| 7619 | } |
| 7620 | { // primary '(' arguments? ')' |
| 7621 | expr_ty a; |
| 7622 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7623 | Token * literal; |
| 7624 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7625 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7626 | (a = primary_rule(p)) // primary |
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 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7631 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7632 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7633 | ) |
| 7634 | { |
| 7635 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7636 | if (token == NULL) { |
| 7637 | return NULL; |
| 7638 | } |
| 7639 | int end_lineno = token->end_lineno; |
| 7640 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7641 | int end_col_offset = token->end_col_offset; |
| 7642 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7643 | res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 7644 | if (res == NULL && PyErr_Occurred()) { |
| 7645 | p->error_indicator = 1; |
| 7646 | return NULL; |
| 7647 | } |
| 7648 | goto done; |
| 7649 | } |
| 7650 | p->mark = mark; |
| 7651 | } |
| 7652 | { // primary '[' slices ']' |
| 7653 | expr_ty a; |
| 7654 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7655 | Token * literal; |
| 7656 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7657 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7658 | (a = primary_rule(p)) // primary |
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 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
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 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7663 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7664 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7665 | ) |
| 7666 | { |
| 7667 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7668 | if (token == NULL) { |
| 7669 | return NULL; |
| 7670 | } |
| 7671 | int end_lineno = token->end_lineno; |
| 7672 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7673 | int end_col_offset = token->end_col_offset; |
| 7674 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7675 | res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 7676 | if (res == NULL && PyErr_Occurred()) { |
| 7677 | p->error_indicator = 1; |
| 7678 | return NULL; |
| 7679 | } |
| 7680 | goto done; |
| 7681 | } |
| 7682 | p->mark = mark; |
| 7683 | } |
| 7684 | { // atom |
| 7685 | expr_ty atom_var; |
| 7686 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7687 | (atom_var = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7688 | ) |
| 7689 | { |
| 7690 | res = atom_var; |
| 7691 | goto done; |
| 7692 | } |
| 7693 | p->mark = mark; |
| 7694 | } |
| 7695 | res = NULL; |
| 7696 | done: |
| 7697 | return res; |
| 7698 | } |
| 7699 | |
| 7700 | // slices: slice !',' | ','.slice+ ','? |
| 7701 | static expr_ty |
| 7702 | slices_rule(Parser *p) |
| 7703 | { |
| 7704 | if (p->error_indicator) { |
| 7705 | return NULL; |
| 7706 | } |
| 7707 | expr_ty res = NULL; |
| 7708 | int mark = p->mark; |
| 7709 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7710 | p->error_indicator = 1; |
| 7711 | return NULL; |
| 7712 | } |
| 7713 | int start_lineno = p->tokens[mark]->lineno; |
| 7714 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7715 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7716 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7717 | { // slice !',' |
| 7718 | expr_ty a; |
| 7719 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7720 | (a = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7721 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7722 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7723 | ) |
| 7724 | { |
| 7725 | res = a; |
| 7726 | if (res == NULL && PyErr_Occurred()) { |
| 7727 | p->error_indicator = 1; |
| 7728 | return NULL; |
| 7729 | } |
| 7730 | goto done; |
| 7731 | } |
| 7732 | p->mark = mark; |
| 7733 | } |
| 7734 | { // ','.slice+ ','? |
| 7735 | asdl_seq * a; |
| 7736 | void *opt_var; |
| 7737 | UNUSED(opt_var); // Silence compiler warnings |
| 7738 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7739 | (a = _gather_93_rule(p)) // ','.slice+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7740 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7741 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7742 | ) |
| 7743 | { |
| 7744 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7745 | if (token == NULL) { |
| 7746 | return NULL; |
| 7747 | } |
| 7748 | int end_lineno = token->end_lineno; |
| 7749 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7750 | int end_col_offset = token->end_col_offset; |
| 7751 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7752 | res = _Py_Tuple ( a , Load , EXTRA ); |
| 7753 | if (res == NULL && PyErr_Occurred()) { |
| 7754 | p->error_indicator = 1; |
| 7755 | return NULL; |
| 7756 | } |
| 7757 | goto done; |
| 7758 | } |
| 7759 | p->mark = mark; |
| 7760 | } |
| 7761 | res = NULL; |
| 7762 | done: |
| 7763 | return res; |
| 7764 | } |
| 7765 | |
| 7766 | // slice: expression? ':' expression? [':' expression?] | expression |
| 7767 | static expr_ty |
| 7768 | slice_rule(Parser *p) |
| 7769 | { |
| 7770 | if (p->error_indicator) { |
| 7771 | return NULL; |
| 7772 | } |
| 7773 | expr_ty res = NULL; |
| 7774 | int mark = p->mark; |
| 7775 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7776 | p->error_indicator = 1; |
| 7777 | return NULL; |
| 7778 | } |
| 7779 | int start_lineno = p->tokens[mark]->lineno; |
| 7780 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7781 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7782 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7783 | { // expression? ':' expression? [':' expression?] |
| 7784 | void *a; |
| 7785 | void *b; |
| 7786 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7787 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7788 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7789 | (a = expression_rule(p), 1) // expression? |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
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 | (b = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7794 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7795 | (c = _tmp_95_rule(p), 1) // [':' expression?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7796 | ) |
| 7797 | { |
| 7798 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7799 | if (token == NULL) { |
| 7800 | return NULL; |
| 7801 | } |
| 7802 | int end_lineno = token->end_lineno; |
| 7803 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7804 | int end_col_offset = token->end_col_offset; |
| 7805 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7806 | res = _Py_Slice ( a , b , c , EXTRA ); |
| 7807 | if (res == NULL && PyErr_Occurred()) { |
| 7808 | p->error_indicator = 1; |
| 7809 | return NULL; |
| 7810 | } |
| 7811 | goto done; |
| 7812 | } |
| 7813 | p->mark = mark; |
| 7814 | } |
| 7815 | { // expression |
| 7816 | expr_ty a; |
| 7817 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7818 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7819 | ) |
| 7820 | { |
| 7821 | res = a; |
| 7822 | if (res == NULL && PyErr_Occurred()) { |
| 7823 | p->error_indicator = 1; |
| 7824 | return NULL; |
| 7825 | } |
| 7826 | goto done; |
| 7827 | } |
| 7828 | p->mark = mark; |
| 7829 | } |
| 7830 | res = NULL; |
| 7831 | done: |
| 7832 | return res; |
| 7833 | } |
| 7834 | |
| 7835 | // atom: |
| 7836 | // | NAME |
| 7837 | // | 'True' |
| 7838 | // | 'False' |
| 7839 | // | 'None' |
| 7840 | // | '__new_parser__' |
| 7841 | // | &STRING strings |
| 7842 | // | NUMBER |
| 7843 | // | &'(' (tuple | group | genexp) |
| 7844 | // | &'[' (list | listcomp) |
| 7845 | // | &'{' (dict | set | dictcomp | setcomp) |
| 7846 | // | '...' |
| 7847 | static expr_ty |
| 7848 | atom_rule(Parser *p) |
| 7849 | { |
| 7850 | if (p->error_indicator) { |
| 7851 | return NULL; |
| 7852 | } |
| 7853 | expr_ty res = NULL; |
| 7854 | int mark = p->mark; |
| 7855 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7856 | p->error_indicator = 1; |
| 7857 | return NULL; |
| 7858 | } |
| 7859 | int start_lineno = p->tokens[mark]->lineno; |
| 7860 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7861 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7862 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7863 | { // NAME |
| 7864 | expr_ty name_var; |
| 7865 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7866 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7867 | ) |
| 7868 | { |
| 7869 | res = name_var; |
| 7870 | goto done; |
| 7871 | } |
| 7872 | p->mark = mark; |
| 7873 | } |
| 7874 | { // 'True' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7875 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7876 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7877 | (keyword = _PyPegen_expect_token(p, 527)) // token='True' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7878 | ) |
| 7879 | { |
| 7880 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7881 | if (token == NULL) { |
| 7882 | return NULL; |
| 7883 | } |
| 7884 | int end_lineno = token->end_lineno; |
| 7885 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7886 | int end_col_offset = token->end_col_offset; |
| 7887 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7888 | res = _Py_Constant ( Py_True , NULL , EXTRA ); |
| 7889 | if (res == NULL && PyErr_Occurred()) { |
| 7890 | p->error_indicator = 1; |
| 7891 | return NULL; |
| 7892 | } |
| 7893 | goto done; |
| 7894 | } |
| 7895 | p->mark = mark; |
| 7896 | } |
| 7897 | { // 'False' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7898 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7899 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7900 | (keyword = _PyPegen_expect_token(p, 528)) // token='False' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7901 | ) |
| 7902 | { |
| 7903 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7904 | if (token == NULL) { |
| 7905 | return NULL; |
| 7906 | } |
| 7907 | int end_lineno = token->end_lineno; |
| 7908 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7909 | int end_col_offset = token->end_col_offset; |
| 7910 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7911 | res = _Py_Constant ( Py_False , NULL , EXTRA ); |
| 7912 | if (res == NULL && PyErr_Occurred()) { |
| 7913 | p->error_indicator = 1; |
| 7914 | return NULL; |
| 7915 | } |
| 7916 | goto done; |
| 7917 | } |
| 7918 | p->mark = mark; |
| 7919 | } |
| 7920 | { // 'None' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7921 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7922 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7923 | (keyword = _PyPegen_expect_token(p, 529)) // token='None' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7924 | ) |
| 7925 | { |
| 7926 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7927 | if (token == NULL) { |
| 7928 | return NULL; |
| 7929 | } |
| 7930 | int end_lineno = token->end_lineno; |
| 7931 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7932 | int end_col_offset = token->end_col_offset; |
| 7933 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7934 | res = _Py_Constant ( Py_None , NULL , EXTRA ); |
| 7935 | if (res == NULL && PyErr_Occurred()) { |
| 7936 | p->error_indicator = 1; |
| 7937 | return NULL; |
| 7938 | } |
| 7939 | goto done; |
| 7940 | } |
| 7941 | p->mark = mark; |
| 7942 | } |
| 7943 | { // '__new_parser__' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7944 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7945 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7946 | (keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7947 | ) |
| 7948 | { |
| 7949 | res = RAISE_SYNTAX_ERROR ( "You found it!" ); |
| 7950 | if (res == NULL && PyErr_Occurred()) { |
| 7951 | p->error_indicator = 1; |
| 7952 | return NULL; |
| 7953 | } |
| 7954 | goto done; |
| 7955 | } |
| 7956 | p->mark = mark; |
| 7957 | } |
| 7958 | { // &STRING strings |
| 7959 | expr_ty strings_var; |
| 7960 | if ( |
| 7961 | _PyPegen_lookahead(1, _PyPegen_string_token, p) |
| 7962 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7963 | (strings_var = strings_rule(p)) // strings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7964 | ) |
| 7965 | { |
| 7966 | res = strings_var; |
| 7967 | goto done; |
| 7968 | } |
| 7969 | p->mark = mark; |
| 7970 | } |
| 7971 | { // NUMBER |
| 7972 | expr_ty number_var; |
| 7973 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7974 | (number_var = _PyPegen_number_token(p)) // NUMBER |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7975 | ) |
| 7976 | { |
| 7977 | res = number_var; |
| 7978 | goto done; |
| 7979 | } |
| 7980 | p->mark = mark; |
| 7981 | } |
| 7982 | { // &'(' (tuple | group | genexp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7983 | void *_tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7984 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7985 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7986 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7987 | (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7988 | ) |
| 7989 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7990 | res = _tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7991 | goto done; |
| 7992 | } |
| 7993 | p->mark = mark; |
| 7994 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7995 | { // &'[' (list | listcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7996 | void *_tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7997 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7998 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7999 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8000 | (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8001 | ) |
| 8002 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8003 | res = _tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8004 | goto done; |
| 8005 | } |
| 8006 | p->mark = mark; |
| 8007 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8008 | { // &'{' (dict | set | dictcomp | setcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8009 | void *_tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8010 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8011 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8012 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8013 | (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8014 | ) |
| 8015 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8016 | res = _tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8017 | goto done; |
| 8018 | } |
| 8019 | p->mark = mark; |
| 8020 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8021 | { // '...' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8022 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8023 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8024 | (literal = _PyPegen_expect_token(p, 52)) // token='...' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8025 | ) |
| 8026 | { |
| 8027 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8028 | if (token == NULL) { |
| 8029 | return NULL; |
| 8030 | } |
| 8031 | int end_lineno = token->end_lineno; |
| 8032 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8033 | int end_col_offset = token->end_col_offset; |
| 8034 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8035 | res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); |
| 8036 | if (res == NULL && PyErr_Occurred()) { |
| 8037 | p->error_indicator = 1; |
| 8038 | return NULL; |
| 8039 | } |
| 8040 | goto done; |
| 8041 | } |
| 8042 | p->mark = mark; |
| 8043 | } |
| 8044 | res = NULL; |
| 8045 | done: |
| 8046 | return res; |
| 8047 | } |
| 8048 | |
| 8049 | // strings: STRING+ |
| 8050 | static expr_ty |
| 8051 | strings_rule(Parser *p) |
| 8052 | { |
| 8053 | if (p->error_indicator) { |
| 8054 | return NULL; |
| 8055 | } |
| 8056 | expr_ty res = NULL; |
| 8057 | if (_PyPegen_is_memoized(p, strings_type, &res)) |
| 8058 | return res; |
| 8059 | int mark = p->mark; |
| 8060 | { // STRING+ |
| 8061 | asdl_seq * a; |
| 8062 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8063 | (a = _loop1_99_rule(p)) // STRING+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8064 | ) |
| 8065 | { |
| 8066 | res = _PyPegen_concatenate_strings ( p , a ); |
| 8067 | if (res == NULL && PyErr_Occurred()) { |
| 8068 | p->error_indicator = 1; |
| 8069 | return NULL; |
| 8070 | } |
| 8071 | goto done; |
| 8072 | } |
| 8073 | p->mark = mark; |
| 8074 | } |
| 8075 | res = NULL; |
| 8076 | done: |
| 8077 | _PyPegen_insert_memo(p, mark, strings_type, res); |
| 8078 | return res; |
| 8079 | } |
| 8080 | |
| 8081 | // list: '[' star_named_expressions? ']' |
| 8082 | static expr_ty |
| 8083 | list_rule(Parser *p) |
| 8084 | { |
| 8085 | if (p->error_indicator) { |
| 8086 | return NULL; |
| 8087 | } |
| 8088 | expr_ty res = NULL; |
| 8089 | int mark = p->mark; |
| 8090 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8091 | p->error_indicator = 1; |
| 8092 | return NULL; |
| 8093 | } |
| 8094 | int start_lineno = p->tokens[mark]->lineno; |
| 8095 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8096 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8097 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8098 | { // '[' star_named_expressions? ']' |
| 8099 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8100 | Token * literal; |
| 8101 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8102 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8103 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
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 | (a = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8106 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8107 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8108 | ) |
| 8109 | { |
| 8110 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8111 | if (token == NULL) { |
| 8112 | return NULL; |
| 8113 | } |
| 8114 | int end_lineno = token->end_lineno; |
| 8115 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8116 | int end_col_offset = token->end_col_offset; |
| 8117 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8118 | res = _Py_List ( a , Load , EXTRA ); |
| 8119 | if (res == NULL && PyErr_Occurred()) { |
| 8120 | p->error_indicator = 1; |
| 8121 | return NULL; |
| 8122 | } |
| 8123 | goto done; |
| 8124 | } |
| 8125 | p->mark = mark; |
| 8126 | } |
| 8127 | res = NULL; |
| 8128 | done: |
| 8129 | return res; |
| 8130 | } |
| 8131 | |
| 8132 | // listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension |
| 8133 | static expr_ty |
| 8134 | listcomp_rule(Parser *p) |
| 8135 | { |
| 8136 | if (p->error_indicator) { |
| 8137 | return NULL; |
| 8138 | } |
| 8139 | expr_ty res = NULL; |
| 8140 | int mark = p->mark; |
| 8141 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8142 | p->error_indicator = 1; |
| 8143 | return NULL; |
| 8144 | } |
| 8145 | int start_lineno = p->tokens[mark]->lineno; |
| 8146 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8147 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8148 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8149 | { // '[' named_expression for_if_clauses ']' |
| 8150 | expr_ty a; |
| 8151 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8152 | Token * literal; |
| 8153 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8154 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8155 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
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 | (a = named_expression_rule(p)) // named_expression |
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 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8160 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8161 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8162 | ) |
| 8163 | { |
| 8164 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8165 | if (token == NULL) { |
| 8166 | return NULL; |
| 8167 | } |
| 8168 | int end_lineno = token->end_lineno; |
| 8169 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8170 | int end_col_offset = token->end_col_offset; |
| 8171 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8172 | res = _Py_ListComp ( a , b , EXTRA ); |
| 8173 | if (res == NULL && PyErr_Occurred()) { |
| 8174 | p->error_indicator = 1; |
| 8175 | return NULL; |
| 8176 | } |
| 8177 | goto done; |
| 8178 | } |
| 8179 | p->mark = mark; |
| 8180 | } |
| 8181 | { // invalid_comprehension |
| 8182 | void *invalid_comprehension_var; |
| 8183 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8184 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8185 | ) |
| 8186 | { |
| 8187 | res = invalid_comprehension_var; |
| 8188 | goto done; |
| 8189 | } |
| 8190 | p->mark = mark; |
| 8191 | } |
| 8192 | res = NULL; |
| 8193 | done: |
| 8194 | return res; |
| 8195 | } |
| 8196 | |
| 8197 | // tuple: '(' [star_named_expression ',' star_named_expressions?] ')' |
| 8198 | static expr_ty |
| 8199 | tuple_rule(Parser *p) |
| 8200 | { |
| 8201 | if (p->error_indicator) { |
| 8202 | return NULL; |
| 8203 | } |
| 8204 | expr_ty res = NULL; |
| 8205 | int mark = p->mark; |
| 8206 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8207 | p->error_indicator = 1; |
| 8208 | return NULL; |
| 8209 | } |
| 8210 | int start_lineno = p->tokens[mark]->lineno; |
| 8211 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8212 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8213 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8214 | { // '(' [star_named_expression ',' star_named_expressions?] ')' |
| 8215 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8216 | Token * literal; |
| 8217 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8218 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8219 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8222 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8223 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8224 | ) |
| 8225 | { |
| 8226 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8227 | if (token == NULL) { |
| 8228 | return NULL; |
| 8229 | } |
| 8230 | int end_lineno = token->end_lineno; |
| 8231 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8232 | int end_col_offset = token->end_col_offset; |
| 8233 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8234 | res = _Py_Tuple ( a , Load , EXTRA ); |
| 8235 | if (res == NULL && PyErr_Occurred()) { |
| 8236 | p->error_indicator = 1; |
| 8237 | return NULL; |
| 8238 | } |
| 8239 | goto done; |
| 8240 | } |
| 8241 | p->mark = mark; |
| 8242 | } |
| 8243 | res = NULL; |
| 8244 | done: |
| 8245 | return res; |
| 8246 | } |
| 8247 | |
| 8248 | // group: '(' (yield_expr | named_expression) ')' |
| 8249 | static expr_ty |
| 8250 | group_rule(Parser *p) |
| 8251 | { |
| 8252 | if (p->error_indicator) { |
| 8253 | return NULL; |
| 8254 | } |
| 8255 | expr_ty res = NULL; |
| 8256 | int mark = p->mark; |
| 8257 | { // '(' (yield_expr | named_expression) ')' |
| 8258 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8259 | Token * literal; |
| 8260 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8261 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8262 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (a = _tmp_101_rule(p)) // yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8265 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8266 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8267 | ) |
| 8268 | { |
| 8269 | res = a; |
| 8270 | if (res == NULL && PyErr_Occurred()) { |
| 8271 | p->error_indicator = 1; |
| 8272 | return NULL; |
| 8273 | } |
| 8274 | goto done; |
| 8275 | } |
| 8276 | p->mark = mark; |
| 8277 | } |
| 8278 | res = NULL; |
| 8279 | done: |
| 8280 | return res; |
| 8281 | } |
| 8282 | |
| 8283 | // genexp: '(' expression for_if_clauses ')' | invalid_comprehension |
| 8284 | static expr_ty |
| 8285 | genexp_rule(Parser *p) |
| 8286 | { |
| 8287 | if (p->error_indicator) { |
| 8288 | return NULL; |
| 8289 | } |
| 8290 | expr_ty res = NULL; |
| 8291 | int mark = p->mark; |
| 8292 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8293 | p->error_indicator = 1; |
| 8294 | return NULL; |
| 8295 | } |
| 8296 | int start_lineno = p->tokens[mark]->lineno; |
| 8297 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8298 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8299 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8300 | { // '(' expression for_if_clauses ')' |
| 8301 | expr_ty a; |
| 8302 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8303 | Token * literal; |
| 8304 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8305 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8306 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
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 | (a = expression_rule(p)) // expression |
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 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8311 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8312 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8313 | ) |
| 8314 | { |
| 8315 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8316 | if (token == NULL) { |
| 8317 | return NULL; |
| 8318 | } |
| 8319 | int end_lineno = token->end_lineno; |
| 8320 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8321 | int end_col_offset = token->end_col_offset; |
| 8322 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8323 | res = _Py_GeneratorExp ( a , b , EXTRA ); |
| 8324 | if (res == NULL && PyErr_Occurred()) { |
| 8325 | p->error_indicator = 1; |
| 8326 | return NULL; |
| 8327 | } |
| 8328 | goto done; |
| 8329 | } |
| 8330 | p->mark = mark; |
| 8331 | } |
| 8332 | { // invalid_comprehension |
| 8333 | void *invalid_comprehension_var; |
| 8334 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8335 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8336 | ) |
| 8337 | { |
| 8338 | res = invalid_comprehension_var; |
| 8339 | goto done; |
| 8340 | } |
| 8341 | p->mark = mark; |
| 8342 | } |
| 8343 | res = NULL; |
| 8344 | done: |
| 8345 | return res; |
| 8346 | } |
| 8347 | |
| 8348 | // set: '{' expressions_list '}' |
| 8349 | static expr_ty |
| 8350 | set_rule(Parser *p) |
| 8351 | { |
| 8352 | if (p->error_indicator) { |
| 8353 | return NULL; |
| 8354 | } |
| 8355 | expr_ty res = NULL; |
| 8356 | int mark = p->mark; |
| 8357 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8358 | p->error_indicator = 1; |
| 8359 | return NULL; |
| 8360 | } |
| 8361 | int start_lineno = p->tokens[mark]->lineno; |
| 8362 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8363 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8364 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8365 | { // '{' expressions_list '}' |
| 8366 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8367 | Token * literal; |
| 8368 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8369 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8370 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
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 | (a = expressions_list_rule(p)) // expressions_list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8373 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8374 | (literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8375 | ) |
| 8376 | { |
| 8377 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8378 | if (token == NULL) { |
| 8379 | return NULL; |
| 8380 | } |
| 8381 | int end_lineno = token->end_lineno; |
| 8382 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8383 | int end_col_offset = token->end_col_offset; |
| 8384 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8385 | res = _Py_Set ( a , EXTRA ); |
| 8386 | if (res == NULL && PyErr_Occurred()) { |
| 8387 | p->error_indicator = 1; |
| 8388 | return NULL; |
| 8389 | } |
| 8390 | goto done; |
| 8391 | } |
| 8392 | p->mark = mark; |
| 8393 | } |
| 8394 | res = NULL; |
| 8395 | done: |
| 8396 | return res; |
| 8397 | } |
| 8398 | |
| 8399 | // setcomp: '{' expression for_if_clauses '}' | invalid_comprehension |
| 8400 | static expr_ty |
| 8401 | setcomp_rule(Parser *p) |
| 8402 | { |
| 8403 | if (p->error_indicator) { |
| 8404 | return NULL; |
| 8405 | } |
| 8406 | expr_ty res = NULL; |
| 8407 | int mark = p->mark; |
| 8408 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8409 | p->error_indicator = 1; |
| 8410 | return NULL; |
| 8411 | } |
| 8412 | int start_lineno = p->tokens[mark]->lineno; |
| 8413 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8414 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8415 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8416 | { // '{' expression for_if_clauses '}' |
| 8417 | expr_ty a; |
| 8418 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8419 | Token * literal; |
| 8420 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8421 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8422 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
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 | (a = expression_rule(p)) // expression |
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 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8427 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8428 | (literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8429 | ) |
| 8430 | { |
| 8431 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8432 | if (token == NULL) { |
| 8433 | return NULL; |
| 8434 | } |
| 8435 | int end_lineno = token->end_lineno; |
| 8436 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8437 | int end_col_offset = token->end_col_offset; |
| 8438 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8439 | res = _Py_SetComp ( a , b , EXTRA ); |
| 8440 | if (res == NULL && PyErr_Occurred()) { |
| 8441 | p->error_indicator = 1; |
| 8442 | return NULL; |
| 8443 | } |
| 8444 | goto done; |
| 8445 | } |
| 8446 | p->mark = mark; |
| 8447 | } |
| 8448 | { // invalid_comprehension |
| 8449 | void *invalid_comprehension_var; |
| 8450 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8451 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8452 | ) |
| 8453 | { |
| 8454 | res = invalid_comprehension_var; |
| 8455 | goto done; |
| 8456 | } |
| 8457 | p->mark = mark; |
| 8458 | } |
| 8459 | res = NULL; |
| 8460 | done: |
| 8461 | return res; |
| 8462 | } |
| 8463 | |
| 8464 | // dict: '{' kvpairs? '}' |
| 8465 | static expr_ty |
| 8466 | dict_rule(Parser *p) |
| 8467 | { |
| 8468 | if (p->error_indicator) { |
| 8469 | return NULL; |
| 8470 | } |
| 8471 | expr_ty res = NULL; |
| 8472 | int mark = p->mark; |
| 8473 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8474 | p->error_indicator = 1; |
| 8475 | return NULL; |
| 8476 | } |
| 8477 | int start_lineno = p->tokens[mark]->lineno; |
| 8478 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8479 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8480 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8481 | { // '{' kvpairs? '}' |
| 8482 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8483 | Token * literal; |
| 8484 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8485 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8486 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
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 | (a = kvpairs_rule(p), 1) // kvpairs? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8489 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8490 | (literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8491 | ) |
| 8492 | { |
| 8493 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8494 | if (token == NULL) { |
| 8495 | return NULL; |
| 8496 | } |
| 8497 | int end_lineno = token->end_lineno; |
| 8498 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8499 | int end_col_offset = token->end_col_offset; |
| 8500 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8501 | res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); |
| 8502 | if (res == NULL && PyErr_Occurred()) { |
| 8503 | p->error_indicator = 1; |
| 8504 | return NULL; |
| 8505 | } |
| 8506 | goto done; |
| 8507 | } |
| 8508 | p->mark = mark; |
| 8509 | } |
| 8510 | res = NULL; |
| 8511 | done: |
| 8512 | return res; |
| 8513 | } |
| 8514 | |
| 8515 | // dictcomp: '{' kvpair for_if_clauses '}' |
| 8516 | static expr_ty |
| 8517 | dictcomp_rule(Parser *p) |
| 8518 | { |
| 8519 | if (p->error_indicator) { |
| 8520 | return NULL; |
| 8521 | } |
| 8522 | expr_ty res = NULL; |
| 8523 | int mark = p->mark; |
| 8524 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8525 | p->error_indicator = 1; |
| 8526 | return NULL; |
| 8527 | } |
| 8528 | int start_lineno = p->tokens[mark]->lineno; |
| 8529 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8530 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8531 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8532 | { // '{' kvpair for_if_clauses '}' |
| 8533 | KeyValuePair* a; |
| 8534 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8535 | Token * literal; |
| 8536 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8537 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8538 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
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 | (a = kvpair_rule(p)) // kvpair |
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 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8543 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8544 | (literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8545 | ) |
| 8546 | { |
| 8547 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8548 | if (token == NULL) { |
| 8549 | return NULL; |
| 8550 | } |
| 8551 | int end_lineno = token->end_lineno; |
| 8552 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8553 | int end_col_offset = token->end_col_offset; |
| 8554 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8555 | res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); |
| 8556 | if (res == NULL && PyErr_Occurred()) { |
| 8557 | p->error_indicator = 1; |
| 8558 | return NULL; |
| 8559 | } |
| 8560 | goto done; |
| 8561 | } |
| 8562 | p->mark = mark; |
| 8563 | } |
| 8564 | res = NULL; |
| 8565 | done: |
| 8566 | return res; |
| 8567 | } |
| 8568 | |
| 8569 | // kvpairs: ','.kvpair+ ','? |
| 8570 | static asdl_seq* |
| 8571 | kvpairs_rule(Parser *p) |
| 8572 | { |
| 8573 | if (p->error_indicator) { |
| 8574 | return NULL; |
| 8575 | } |
| 8576 | asdl_seq* res = NULL; |
| 8577 | int mark = p->mark; |
| 8578 | { // ','.kvpair+ ','? |
| 8579 | asdl_seq * a; |
| 8580 | void *opt_var; |
| 8581 | UNUSED(opt_var); // Silence compiler warnings |
| 8582 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8583 | (a = _gather_102_rule(p)) // ','.kvpair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8584 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8585 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8586 | ) |
| 8587 | { |
| 8588 | res = a; |
| 8589 | if (res == NULL && PyErr_Occurred()) { |
| 8590 | p->error_indicator = 1; |
| 8591 | return NULL; |
| 8592 | } |
| 8593 | goto done; |
| 8594 | } |
| 8595 | p->mark = mark; |
| 8596 | } |
| 8597 | res = NULL; |
| 8598 | done: |
| 8599 | return res; |
| 8600 | } |
| 8601 | |
| 8602 | // kvpair: '**' bitwise_or | expression ':' expression |
| 8603 | static KeyValuePair* |
| 8604 | kvpair_rule(Parser *p) |
| 8605 | { |
| 8606 | if (p->error_indicator) { |
| 8607 | return NULL; |
| 8608 | } |
| 8609 | KeyValuePair* res = NULL; |
| 8610 | int mark = p->mark; |
| 8611 | { // '**' bitwise_or |
| 8612 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8613 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8614 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8615 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8616 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8617 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8618 | ) |
| 8619 | { |
| 8620 | res = _PyPegen_key_value_pair ( p , NULL , a ); |
| 8621 | if (res == NULL && PyErr_Occurred()) { |
| 8622 | p->error_indicator = 1; |
| 8623 | return NULL; |
| 8624 | } |
| 8625 | goto done; |
| 8626 | } |
| 8627 | p->mark = mark; |
| 8628 | } |
| 8629 | { // expression ':' expression |
| 8630 | expr_ty a; |
| 8631 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8632 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8633 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8634 | (a = expression_rule(p)) // expression |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8637 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8638 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8639 | ) |
| 8640 | { |
| 8641 | res = _PyPegen_key_value_pair ( p , a , b ); |
| 8642 | if (res == NULL && PyErr_Occurred()) { |
| 8643 | p->error_indicator = 1; |
| 8644 | return NULL; |
| 8645 | } |
| 8646 | goto done; |
| 8647 | } |
| 8648 | p->mark = mark; |
| 8649 | } |
| 8650 | res = NULL; |
| 8651 | done: |
| 8652 | return res; |
| 8653 | } |
| 8654 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8655 | // for_if_clauses: for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8656 | static asdl_seq* |
| 8657 | for_if_clauses_rule(Parser *p) |
| 8658 | { |
| 8659 | if (p->error_indicator) { |
| 8660 | return NULL; |
| 8661 | } |
| 8662 | asdl_seq* res = NULL; |
| 8663 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8664 | { // for_if_clause+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8665 | asdl_seq * _loop1_104_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8666 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8667 | (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8668 | ) |
| 8669 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8670 | res = _loop1_104_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8671 | goto done; |
| 8672 | } |
| 8673 | p->mark = mark; |
| 8674 | } |
| 8675 | res = NULL; |
| 8676 | done: |
| 8677 | return res; |
| 8678 | } |
| 8679 | |
| 8680 | // for_if_clause: |
| 8681 | // | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8682 | // | 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8683 | static comprehension_ty |
| 8684 | for_if_clause_rule(Parser *p) |
| 8685 | { |
| 8686 | if (p->error_indicator) { |
| 8687 | return NULL; |
| 8688 | } |
| 8689 | comprehension_ty res = NULL; |
| 8690 | int mark = p->mark; |
| 8691 | { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8692 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8693 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8694 | expr_ty b; |
| 8695 | asdl_seq * c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8696 | Token * keyword; |
| 8697 | Token * keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8698 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8699 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
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 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
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 | (a = star_targets_rule(p)) // star_targets |
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 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
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 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8708 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8709 | (c = _loop0_105_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8710 | ) |
| 8711 | { |
| 8712 | res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); |
| 8713 | if (res == NULL && PyErr_Occurred()) { |
| 8714 | p->error_indicator = 1; |
| 8715 | return NULL; |
| 8716 | } |
| 8717 | goto done; |
| 8718 | } |
| 8719 | p->mark = mark; |
| 8720 | } |
| 8721 | { // 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8722 | expr_ty a; |
| 8723 | expr_ty b; |
| 8724 | asdl_seq * c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8725 | Token * keyword; |
| 8726 | Token * keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8727 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8728 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
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 | (a = star_targets_rule(p)) // star_targets |
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 | (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
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 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8735 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8736 | (c = _loop0_106_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8737 | ) |
| 8738 | { |
| 8739 | res = _Py_comprehension ( a , b , c , 0 , p -> arena ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8740 | if (res == NULL && PyErr_Occurred()) { |
| 8741 | p->error_indicator = 1; |
| 8742 | return NULL; |
| 8743 | } |
| 8744 | goto done; |
| 8745 | } |
| 8746 | p->mark = mark; |
| 8747 | } |
| 8748 | res = NULL; |
| 8749 | done: |
| 8750 | return res; |
| 8751 | } |
| 8752 | |
| 8753 | // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? |
| 8754 | static expr_ty |
| 8755 | yield_expr_rule(Parser *p) |
| 8756 | { |
| 8757 | if (p->error_indicator) { |
| 8758 | return NULL; |
| 8759 | } |
| 8760 | expr_ty res = NULL; |
| 8761 | int mark = p->mark; |
| 8762 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8763 | p->error_indicator = 1; |
| 8764 | return NULL; |
| 8765 | } |
| 8766 | int start_lineno = p->tokens[mark]->lineno; |
| 8767 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8768 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8769 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8770 | { // 'yield' 'from' expression |
| 8771 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8772 | Token * keyword; |
| 8773 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8774 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8775 | (keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
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 | (keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8778 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8779 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8780 | ) |
| 8781 | { |
| 8782 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8783 | if (token == NULL) { |
| 8784 | return NULL; |
| 8785 | } |
| 8786 | int end_lineno = token->end_lineno; |
| 8787 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8788 | int end_col_offset = token->end_col_offset; |
| 8789 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8790 | res = _Py_YieldFrom ( a , EXTRA ); |
| 8791 | if (res == NULL && PyErr_Occurred()) { |
| 8792 | p->error_indicator = 1; |
| 8793 | return NULL; |
| 8794 | } |
| 8795 | goto done; |
| 8796 | } |
| 8797 | p->mark = mark; |
| 8798 | } |
| 8799 | { // 'yield' star_expressions? |
| 8800 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8801 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8802 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8803 | (keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8804 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8805 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8806 | ) |
| 8807 | { |
| 8808 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8809 | if (token == NULL) { |
| 8810 | return NULL; |
| 8811 | } |
| 8812 | int end_lineno = token->end_lineno; |
| 8813 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8814 | int end_col_offset = token->end_col_offset; |
| 8815 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8816 | res = _Py_Yield ( a , EXTRA ); |
| 8817 | if (res == NULL && PyErr_Occurred()) { |
| 8818 | p->error_indicator = 1; |
| 8819 | return NULL; |
| 8820 | } |
| 8821 | goto done; |
| 8822 | } |
| 8823 | p->mark = mark; |
| 8824 | } |
| 8825 | res = NULL; |
| 8826 | done: |
| 8827 | return res; |
| 8828 | } |
| 8829 | |
| 8830 | // arguments: args ','? &')' | incorrect_arguments |
| 8831 | static expr_ty |
| 8832 | arguments_rule(Parser *p) |
| 8833 | { |
| 8834 | if (p->error_indicator) { |
| 8835 | return NULL; |
| 8836 | } |
| 8837 | expr_ty res = NULL; |
| 8838 | if (_PyPegen_is_memoized(p, arguments_type, &res)) |
| 8839 | return res; |
| 8840 | int mark = p->mark; |
| 8841 | { // args ','? &')' |
| 8842 | expr_ty a; |
| 8843 | void *opt_var; |
| 8844 | UNUSED(opt_var); // Silence compiler warnings |
| 8845 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8846 | (a = args_rule(p)) // args |
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 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8849 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8850 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8851 | ) |
| 8852 | { |
| 8853 | res = a; |
| 8854 | if (res == NULL && PyErr_Occurred()) { |
| 8855 | p->error_indicator = 1; |
| 8856 | return NULL; |
| 8857 | } |
| 8858 | goto done; |
| 8859 | } |
| 8860 | p->mark = mark; |
| 8861 | } |
| 8862 | { // incorrect_arguments |
| 8863 | void *incorrect_arguments_var; |
| 8864 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8865 | (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8866 | ) |
| 8867 | { |
| 8868 | res = incorrect_arguments_var; |
| 8869 | goto done; |
| 8870 | } |
| 8871 | p->mark = mark; |
| 8872 | } |
| 8873 | res = NULL; |
| 8874 | done: |
| 8875 | _PyPegen_insert_memo(p, mark, arguments_type, res); |
| 8876 | return res; |
| 8877 | } |
| 8878 | |
| 8879 | // args: starred_expression [',' args] | kwargs | named_expression [',' args] |
| 8880 | static expr_ty |
| 8881 | args_rule(Parser *p) |
| 8882 | { |
| 8883 | if (p->error_indicator) { |
| 8884 | return NULL; |
| 8885 | } |
| 8886 | expr_ty res = NULL; |
| 8887 | int mark = p->mark; |
| 8888 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8889 | p->error_indicator = 1; |
| 8890 | return NULL; |
| 8891 | } |
| 8892 | int start_lineno = p->tokens[mark]->lineno; |
| 8893 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8894 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8895 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8896 | { // starred_expression [',' args] |
| 8897 | expr_ty a; |
| 8898 | void *b; |
| 8899 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8900 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8901 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8902 | (b = _tmp_107_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8903 | ) |
| 8904 | { |
| 8905 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8906 | if (token == NULL) { |
| 8907 | return NULL; |
| 8908 | } |
| 8909 | int end_lineno = token->end_lineno; |
| 8910 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8911 | int end_col_offset = token->end_col_offset; |
| 8912 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8913 | 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 ); |
| 8914 | if (res == NULL && PyErr_Occurred()) { |
| 8915 | p->error_indicator = 1; |
| 8916 | return NULL; |
| 8917 | } |
| 8918 | goto done; |
| 8919 | } |
| 8920 | p->mark = mark; |
| 8921 | } |
| 8922 | { // kwargs |
| 8923 | asdl_seq* a; |
| 8924 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8925 | (a = kwargs_rule(p)) // kwargs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8926 | ) |
| 8927 | { |
| 8928 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8929 | if (token == NULL) { |
| 8930 | return NULL; |
| 8931 | } |
| 8932 | int end_lineno = token->end_lineno; |
| 8933 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8934 | int end_col_offset = token->end_col_offset; |
| 8935 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8936 | 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 ); |
| 8937 | if (res == NULL && PyErr_Occurred()) { |
| 8938 | p->error_indicator = 1; |
| 8939 | return NULL; |
| 8940 | } |
| 8941 | goto done; |
| 8942 | } |
| 8943 | p->mark = mark; |
| 8944 | } |
| 8945 | { // named_expression [',' args] |
| 8946 | expr_ty a; |
| 8947 | void *b; |
| 8948 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8949 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8950 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8951 | (b = _tmp_108_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8952 | ) |
| 8953 | { |
| 8954 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8955 | if (token == NULL) { |
| 8956 | return NULL; |
| 8957 | } |
| 8958 | int end_lineno = token->end_lineno; |
| 8959 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8960 | int end_col_offset = token->end_col_offset; |
| 8961 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8962 | 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 ); |
| 8963 | if (res == NULL && PyErr_Occurred()) { |
| 8964 | p->error_indicator = 1; |
| 8965 | return NULL; |
| 8966 | } |
| 8967 | goto done; |
| 8968 | } |
| 8969 | p->mark = mark; |
| 8970 | } |
| 8971 | res = NULL; |
| 8972 | done: |
| 8973 | return res; |
| 8974 | } |
| 8975 | |
| 8976 | // kwargs: |
| 8977 | // | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 8978 | // | ','.kwarg_or_starred+ |
| 8979 | // | ','.kwarg_or_double_starred+ |
| 8980 | static asdl_seq* |
| 8981 | kwargs_rule(Parser *p) |
| 8982 | { |
| 8983 | if (p->error_indicator) { |
| 8984 | return NULL; |
| 8985 | } |
| 8986 | asdl_seq* res = NULL; |
| 8987 | int mark = p->mark; |
| 8988 | { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 8989 | asdl_seq * a; |
| 8990 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8991 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8992 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8993 | (a = _gather_109_rule(p)) // ','.kwarg_or_starred+ |
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 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8996 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8997 | (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8998 | ) |
| 8999 | { |
| 9000 | res = _PyPegen_join_sequences ( p , a , b ); |
| 9001 | if (res == NULL && PyErr_Occurred()) { |
| 9002 | p->error_indicator = 1; |
| 9003 | return NULL; |
| 9004 | } |
| 9005 | goto done; |
| 9006 | } |
| 9007 | p->mark = mark; |
| 9008 | } |
| 9009 | { // ','.kwarg_or_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9010 | asdl_seq * _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9011 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9012 | (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9013 | ) |
| 9014 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9015 | res = _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9016 | goto done; |
| 9017 | } |
| 9018 | p->mark = mark; |
| 9019 | } |
| 9020 | { // ','.kwarg_or_double_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9021 | asdl_seq * _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9022 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9023 | (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9024 | ) |
| 9025 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9026 | res = _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9027 | goto done; |
| 9028 | } |
| 9029 | p->mark = mark; |
| 9030 | } |
| 9031 | res = NULL; |
| 9032 | done: |
| 9033 | return res; |
| 9034 | } |
| 9035 | |
| 9036 | // starred_expression: '*' expression |
| 9037 | static expr_ty |
| 9038 | starred_expression_rule(Parser *p) |
| 9039 | { |
| 9040 | if (p->error_indicator) { |
| 9041 | return NULL; |
| 9042 | } |
| 9043 | expr_ty res = NULL; |
| 9044 | int mark = p->mark; |
| 9045 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9046 | p->error_indicator = 1; |
| 9047 | return NULL; |
| 9048 | } |
| 9049 | int start_lineno = p->tokens[mark]->lineno; |
| 9050 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9051 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9052 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9053 | { // '*' expression |
| 9054 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9055 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9056 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9057 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9058 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9059 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9060 | ) |
| 9061 | { |
| 9062 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9063 | if (token == NULL) { |
| 9064 | return NULL; |
| 9065 | } |
| 9066 | int end_lineno = token->end_lineno; |
| 9067 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9068 | int end_col_offset = token->end_col_offset; |
| 9069 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9070 | res = _Py_Starred ( a , Load , EXTRA ); |
| 9071 | if (res == NULL && PyErr_Occurred()) { |
| 9072 | p->error_indicator = 1; |
| 9073 | return NULL; |
| 9074 | } |
| 9075 | goto done; |
| 9076 | } |
| 9077 | p->mark = mark; |
| 9078 | } |
| 9079 | res = NULL; |
| 9080 | done: |
| 9081 | return res; |
| 9082 | } |
| 9083 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame^] | 9084 | // kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9085 | static KeywordOrStarred* |
| 9086 | kwarg_or_starred_rule(Parser *p) |
| 9087 | { |
| 9088 | if (p->error_indicator) { |
| 9089 | return NULL; |
| 9090 | } |
| 9091 | KeywordOrStarred* res = NULL; |
| 9092 | int mark = p->mark; |
| 9093 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9094 | p->error_indicator = 1; |
| 9095 | return NULL; |
| 9096 | } |
| 9097 | int start_lineno = p->tokens[mark]->lineno; |
| 9098 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9099 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9100 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9101 | { // NAME '=' expression |
| 9102 | expr_ty a; |
| 9103 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9104 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9105 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9106 | (a = _PyPegen_name_token(p)) // NAME |
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 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9109 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9110 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9111 | ) |
| 9112 | { |
| 9113 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9114 | if (token == NULL) { |
| 9115 | return NULL; |
| 9116 | } |
| 9117 | int end_lineno = token->end_lineno; |
| 9118 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9119 | int end_col_offset = token->end_col_offset; |
| 9120 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9121 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9122 | if (res == NULL && PyErr_Occurred()) { |
| 9123 | p->error_indicator = 1; |
| 9124 | return NULL; |
| 9125 | } |
| 9126 | goto done; |
| 9127 | } |
| 9128 | p->mark = mark; |
| 9129 | } |
| 9130 | { // starred_expression |
| 9131 | expr_ty a; |
| 9132 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9133 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9134 | ) |
| 9135 | { |
| 9136 | res = _PyPegen_keyword_or_starred ( p , a , 0 ); |
| 9137 | if (res == NULL && PyErr_Occurred()) { |
| 9138 | p->error_indicator = 1; |
| 9139 | return NULL; |
| 9140 | } |
| 9141 | goto done; |
| 9142 | } |
| 9143 | p->mark = mark; |
| 9144 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame^] | 9145 | { // invalid_kwarg |
| 9146 | void *invalid_kwarg_var; |
| 9147 | if ( |
| 9148 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 9149 | ) |
| 9150 | { |
| 9151 | res = invalid_kwarg_var; |
| 9152 | goto done; |
| 9153 | } |
| 9154 | p->mark = mark; |
| 9155 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9156 | res = NULL; |
| 9157 | done: |
| 9158 | return res; |
| 9159 | } |
| 9160 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame^] | 9161 | // kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9162 | static KeywordOrStarred* |
| 9163 | kwarg_or_double_starred_rule(Parser *p) |
| 9164 | { |
| 9165 | if (p->error_indicator) { |
| 9166 | return NULL; |
| 9167 | } |
| 9168 | KeywordOrStarred* res = NULL; |
| 9169 | int mark = p->mark; |
| 9170 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9171 | p->error_indicator = 1; |
| 9172 | return NULL; |
| 9173 | } |
| 9174 | int start_lineno = p->tokens[mark]->lineno; |
| 9175 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9176 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9177 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9178 | { // NAME '=' expression |
| 9179 | expr_ty a; |
| 9180 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9181 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9182 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9183 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9184 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9185 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9186 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9187 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9188 | ) |
| 9189 | { |
| 9190 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9191 | if (token == NULL) { |
| 9192 | return NULL; |
| 9193 | } |
| 9194 | int end_lineno = token->end_lineno; |
| 9195 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9196 | int end_col_offset = token->end_col_offset; |
| 9197 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9198 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9199 | if (res == NULL && PyErr_Occurred()) { |
| 9200 | p->error_indicator = 1; |
| 9201 | return NULL; |
| 9202 | } |
| 9203 | goto done; |
| 9204 | } |
| 9205 | p->mark = mark; |
| 9206 | } |
| 9207 | { // '**' expression |
| 9208 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9209 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9210 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9211 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9212 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9213 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9214 | ) |
| 9215 | { |
| 9216 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9217 | if (token == NULL) { |
| 9218 | return NULL; |
| 9219 | } |
| 9220 | int end_lineno = token->end_lineno; |
| 9221 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9222 | int end_col_offset = token->end_col_offset; |
| 9223 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9224 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); |
| 9225 | if (res == NULL && PyErr_Occurred()) { |
| 9226 | p->error_indicator = 1; |
| 9227 | return NULL; |
| 9228 | } |
| 9229 | goto done; |
| 9230 | } |
| 9231 | p->mark = mark; |
| 9232 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame^] | 9233 | { // invalid_kwarg |
| 9234 | void *invalid_kwarg_var; |
| 9235 | if ( |
| 9236 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 9237 | ) |
| 9238 | { |
| 9239 | res = invalid_kwarg_var; |
| 9240 | goto done; |
| 9241 | } |
| 9242 | p->mark = mark; |
| 9243 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9244 | res = NULL; |
| 9245 | done: |
| 9246 | return res; |
| 9247 | } |
| 9248 | |
| 9249 | // star_targets: star_target !',' | star_target ((',' star_target))* ','? |
| 9250 | static expr_ty |
| 9251 | star_targets_rule(Parser *p) |
| 9252 | { |
| 9253 | if (p->error_indicator) { |
| 9254 | return NULL; |
| 9255 | } |
| 9256 | expr_ty res = NULL; |
| 9257 | int mark = p->mark; |
| 9258 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9259 | p->error_indicator = 1; |
| 9260 | return NULL; |
| 9261 | } |
| 9262 | int start_lineno = p->tokens[mark]->lineno; |
| 9263 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9264 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9265 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9266 | { // star_target !',' |
| 9267 | expr_ty a; |
| 9268 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9269 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9270 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9271 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9272 | ) |
| 9273 | { |
| 9274 | res = a; |
| 9275 | if (res == NULL && PyErr_Occurred()) { |
| 9276 | p->error_indicator = 1; |
| 9277 | return NULL; |
| 9278 | } |
| 9279 | goto done; |
| 9280 | } |
| 9281 | p->mark = mark; |
| 9282 | } |
| 9283 | { // star_target ((',' star_target))* ','? |
| 9284 | expr_ty a; |
| 9285 | asdl_seq * b; |
| 9286 | void *opt_var; |
| 9287 | UNUSED(opt_var); // Silence compiler warnings |
| 9288 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9289 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9290 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9291 | (b = _loop0_117_rule(p)) // ((',' star_target))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9292 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9293 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9294 | ) |
| 9295 | { |
| 9296 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9297 | if (token == NULL) { |
| 9298 | return NULL; |
| 9299 | } |
| 9300 | int end_lineno = token->end_lineno; |
| 9301 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9302 | int end_col_offset = token->end_col_offset; |
| 9303 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9304 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); |
| 9305 | if (res == NULL && PyErr_Occurred()) { |
| 9306 | p->error_indicator = 1; |
| 9307 | return NULL; |
| 9308 | } |
| 9309 | goto done; |
| 9310 | } |
| 9311 | p->mark = mark; |
| 9312 | } |
| 9313 | res = NULL; |
| 9314 | done: |
| 9315 | return res; |
| 9316 | } |
| 9317 | |
| 9318 | // star_targets_seq: ','.star_target+ ','? |
| 9319 | static asdl_seq* |
| 9320 | star_targets_seq_rule(Parser *p) |
| 9321 | { |
| 9322 | if (p->error_indicator) { |
| 9323 | return NULL; |
| 9324 | } |
| 9325 | asdl_seq* res = NULL; |
| 9326 | int mark = p->mark; |
| 9327 | { // ','.star_target+ ','? |
| 9328 | asdl_seq * a; |
| 9329 | void *opt_var; |
| 9330 | UNUSED(opt_var); // Silence compiler warnings |
| 9331 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9332 | (a = _gather_118_rule(p)) // ','.star_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9333 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9334 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9335 | ) |
| 9336 | { |
| 9337 | res = a; |
| 9338 | if (res == NULL && PyErr_Occurred()) { |
| 9339 | p->error_indicator = 1; |
| 9340 | return NULL; |
| 9341 | } |
| 9342 | goto done; |
| 9343 | } |
| 9344 | p->mark = mark; |
| 9345 | } |
| 9346 | res = NULL; |
| 9347 | done: |
| 9348 | return res; |
| 9349 | } |
| 9350 | |
| 9351 | // star_target: |
| 9352 | // | '*' (!'*' star_target) |
| 9353 | // | t_primary '.' NAME !t_lookahead |
| 9354 | // | t_primary '[' slices ']' !t_lookahead |
| 9355 | // | star_atom |
| 9356 | static expr_ty |
| 9357 | star_target_rule(Parser *p) |
| 9358 | { |
| 9359 | if (p->error_indicator) { |
| 9360 | return NULL; |
| 9361 | } |
| 9362 | expr_ty res = NULL; |
| 9363 | if (_PyPegen_is_memoized(p, star_target_type, &res)) |
| 9364 | return res; |
| 9365 | int mark = p->mark; |
| 9366 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9367 | p->error_indicator = 1; |
| 9368 | return NULL; |
| 9369 | } |
| 9370 | int start_lineno = p->tokens[mark]->lineno; |
| 9371 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9372 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9373 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9374 | { // '*' (!'*' star_target) |
| 9375 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9376 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9377 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9378 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9379 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9380 | (a = _tmp_120_rule(p)) // !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9381 | ) |
| 9382 | { |
| 9383 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9384 | if (token == NULL) { |
| 9385 | return NULL; |
| 9386 | } |
| 9387 | int end_lineno = token->end_lineno; |
| 9388 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9389 | int end_col_offset = token->end_col_offset; |
| 9390 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9391 | res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); |
| 9392 | if (res == NULL && PyErr_Occurred()) { |
| 9393 | p->error_indicator = 1; |
| 9394 | return NULL; |
| 9395 | } |
| 9396 | goto done; |
| 9397 | } |
| 9398 | p->mark = mark; |
| 9399 | } |
| 9400 | { // t_primary '.' NAME !t_lookahead |
| 9401 | expr_ty a; |
| 9402 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9403 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9404 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9405 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9406 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9407 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9408 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9409 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9410 | && |
| 9411 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9412 | ) |
| 9413 | { |
| 9414 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9415 | if (token == NULL) { |
| 9416 | return NULL; |
| 9417 | } |
| 9418 | int end_lineno = token->end_lineno; |
| 9419 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9420 | int end_col_offset = token->end_col_offset; |
| 9421 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9422 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9423 | if (res == NULL && PyErr_Occurred()) { |
| 9424 | p->error_indicator = 1; |
| 9425 | return NULL; |
| 9426 | } |
| 9427 | goto done; |
| 9428 | } |
| 9429 | p->mark = mark; |
| 9430 | } |
| 9431 | { // t_primary '[' slices ']' !t_lookahead |
| 9432 | expr_ty a; |
| 9433 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9434 | Token * literal; |
| 9435 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9436 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9437 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9438 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9439 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9440 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9441 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9442 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9443 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9444 | && |
| 9445 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9446 | ) |
| 9447 | { |
| 9448 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9449 | if (token == NULL) { |
| 9450 | return NULL; |
| 9451 | } |
| 9452 | int end_lineno = token->end_lineno; |
| 9453 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9454 | int end_col_offset = token->end_col_offset; |
| 9455 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9456 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9457 | if (res == NULL && PyErr_Occurred()) { |
| 9458 | p->error_indicator = 1; |
| 9459 | return NULL; |
| 9460 | } |
| 9461 | goto done; |
| 9462 | } |
| 9463 | p->mark = mark; |
| 9464 | } |
| 9465 | { // star_atom |
| 9466 | expr_ty star_atom_var; |
| 9467 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9468 | (star_atom_var = star_atom_rule(p)) // star_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9469 | ) |
| 9470 | { |
| 9471 | res = star_atom_var; |
| 9472 | goto done; |
| 9473 | } |
| 9474 | p->mark = mark; |
| 9475 | } |
| 9476 | res = NULL; |
| 9477 | done: |
| 9478 | _PyPegen_insert_memo(p, mark, star_target_type, res); |
| 9479 | return res; |
| 9480 | } |
| 9481 | |
| 9482 | // star_atom: |
| 9483 | // | NAME |
| 9484 | // | '(' star_target ')' |
| 9485 | // | '(' star_targets_seq? ')' |
| 9486 | // | '[' star_targets_seq? ']' |
| 9487 | static expr_ty |
| 9488 | star_atom_rule(Parser *p) |
| 9489 | { |
| 9490 | if (p->error_indicator) { |
| 9491 | return NULL; |
| 9492 | } |
| 9493 | expr_ty res = NULL; |
| 9494 | int mark = p->mark; |
| 9495 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9496 | p->error_indicator = 1; |
| 9497 | return NULL; |
| 9498 | } |
| 9499 | int start_lineno = p->tokens[mark]->lineno; |
| 9500 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9501 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9502 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9503 | { // NAME |
| 9504 | expr_ty a; |
| 9505 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9506 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9507 | ) |
| 9508 | { |
| 9509 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9510 | if (res == NULL && PyErr_Occurred()) { |
| 9511 | p->error_indicator = 1; |
| 9512 | return NULL; |
| 9513 | } |
| 9514 | goto done; |
| 9515 | } |
| 9516 | p->mark = mark; |
| 9517 | } |
| 9518 | { // '(' star_target ')' |
| 9519 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9520 | Token * literal; |
| 9521 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9522 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9523 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9524 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9525 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9526 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9527 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9528 | ) |
| 9529 | { |
| 9530 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9531 | if (res == NULL && PyErr_Occurred()) { |
| 9532 | p->error_indicator = 1; |
| 9533 | return NULL; |
| 9534 | } |
| 9535 | goto done; |
| 9536 | } |
| 9537 | p->mark = mark; |
| 9538 | } |
| 9539 | { // '(' star_targets_seq? ')' |
| 9540 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9541 | Token * literal; |
| 9542 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9543 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9544 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9545 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9546 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9547 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9548 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9549 | ) |
| 9550 | { |
| 9551 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9552 | if (token == NULL) { |
| 9553 | return NULL; |
| 9554 | } |
| 9555 | int end_lineno = token->end_lineno; |
| 9556 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9557 | int end_col_offset = token->end_col_offset; |
| 9558 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9559 | res = _Py_Tuple ( a , Store , EXTRA ); |
| 9560 | if (res == NULL && PyErr_Occurred()) { |
| 9561 | p->error_indicator = 1; |
| 9562 | return NULL; |
| 9563 | } |
| 9564 | goto done; |
| 9565 | } |
| 9566 | p->mark = mark; |
| 9567 | } |
| 9568 | { // '[' star_targets_seq? ']' |
| 9569 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9570 | Token * literal; |
| 9571 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9572 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9573 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9574 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9575 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9576 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9577 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9578 | ) |
| 9579 | { |
| 9580 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9581 | if (token == NULL) { |
| 9582 | return NULL; |
| 9583 | } |
| 9584 | int end_lineno = token->end_lineno; |
| 9585 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9586 | int end_col_offset = token->end_col_offset; |
| 9587 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9588 | res = _Py_List ( a , Store , EXTRA ); |
| 9589 | if (res == NULL && PyErr_Occurred()) { |
| 9590 | p->error_indicator = 1; |
| 9591 | return NULL; |
| 9592 | } |
| 9593 | goto done; |
| 9594 | } |
| 9595 | p->mark = mark; |
| 9596 | } |
| 9597 | res = NULL; |
| 9598 | done: |
| 9599 | return res; |
| 9600 | } |
| 9601 | |
| 9602 | // inside_paren_ann_assign_target: |
| 9603 | // | ann_assign_subscript_attribute_target |
| 9604 | // | NAME |
| 9605 | // | '(' inside_paren_ann_assign_target ')' |
| 9606 | static expr_ty |
| 9607 | inside_paren_ann_assign_target_rule(Parser *p) |
| 9608 | { |
| 9609 | if (p->error_indicator) { |
| 9610 | return NULL; |
| 9611 | } |
| 9612 | expr_ty res = NULL; |
| 9613 | int mark = p->mark; |
| 9614 | { // ann_assign_subscript_attribute_target |
| 9615 | expr_ty ann_assign_subscript_attribute_target_var; |
| 9616 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9617 | (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] | 9618 | ) |
| 9619 | { |
| 9620 | res = ann_assign_subscript_attribute_target_var; |
| 9621 | goto done; |
| 9622 | } |
| 9623 | p->mark = mark; |
| 9624 | } |
| 9625 | { // NAME |
| 9626 | expr_ty a; |
| 9627 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9628 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9629 | ) |
| 9630 | { |
| 9631 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9632 | if (res == NULL && PyErr_Occurred()) { |
| 9633 | p->error_indicator = 1; |
| 9634 | return NULL; |
| 9635 | } |
| 9636 | goto done; |
| 9637 | } |
| 9638 | p->mark = mark; |
| 9639 | } |
| 9640 | { // '(' inside_paren_ann_assign_target ')' |
| 9641 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9642 | Token * literal; |
| 9643 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9644 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9645 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9646 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9647 | (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] | 9648 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9649 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9650 | ) |
| 9651 | { |
| 9652 | res = a; |
| 9653 | if (res == NULL && PyErr_Occurred()) { |
| 9654 | p->error_indicator = 1; |
| 9655 | return NULL; |
| 9656 | } |
| 9657 | goto done; |
| 9658 | } |
| 9659 | p->mark = mark; |
| 9660 | } |
| 9661 | res = NULL; |
| 9662 | done: |
| 9663 | return res; |
| 9664 | } |
| 9665 | |
| 9666 | // ann_assign_subscript_attribute_target: |
| 9667 | // | t_primary '.' NAME !t_lookahead |
| 9668 | // | t_primary '[' slices ']' !t_lookahead |
| 9669 | static expr_ty |
| 9670 | ann_assign_subscript_attribute_target_rule(Parser *p) |
| 9671 | { |
| 9672 | if (p->error_indicator) { |
| 9673 | return NULL; |
| 9674 | } |
| 9675 | expr_ty res = NULL; |
| 9676 | int mark = p->mark; |
| 9677 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9678 | p->error_indicator = 1; |
| 9679 | return NULL; |
| 9680 | } |
| 9681 | int start_lineno = p->tokens[mark]->lineno; |
| 9682 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9683 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9684 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9685 | { // t_primary '.' NAME !t_lookahead |
| 9686 | expr_ty a; |
| 9687 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9688 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9689 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9690 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9691 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9692 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9693 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9694 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9695 | && |
| 9696 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9697 | ) |
| 9698 | { |
| 9699 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9700 | if (token == NULL) { |
| 9701 | return NULL; |
| 9702 | } |
| 9703 | int end_lineno = token->end_lineno; |
| 9704 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9705 | int end_col_offset = token->end_col_offset; |
| 9706 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9707 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9708 | if (res == NULL && PyErr_Occurred()) { |
| 9709 | p->error_indicator = 1; |
| 9710 | return NULL; |
| 9711 | } |
| 9712 | goto done; |
| 9713 | } |
| 9714 | p->mark = mark; |
| 9715 | } |
| 9716 | { // t_primary '[' slices ']' !t_lookahead |
| 9717 | expr_ty a; |
| 9718 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9719 | Token * literal; |
| 9720 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9721 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9722 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9723 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9724 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9725 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9726 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9727 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9728 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9729 | && |
| 9730 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9731 | ) |
| 9732 | { |
| 9733 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9734 | if (token == NULL) { |
| 9735 | return NULL; |
| 9736 | } |
| 9737 | int end_lineno = token->end_lineno; |
| 9738 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9739 | int end_col_offset = token->end_col_offset; |
| 9740 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9741 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9742 | if (res == NULL && PyErr_Occurred()) { |
| 9743 | p->error_indicator = 1; |
| 9744 | return NULL; |
| 9745 | } |
| 9746 | goto done; |
| 9747 | } |
| 9748 | p->mark = mark; |
| 9749 | } |
| 9750 | res = NULL; |
| 9751 | done: |
| 9752 | return res; |
| 9753 | } |
| 9754 | |
| 9755 | // del_targets: ','.del_target+ ','? |
| 9756 | static asdl_seq* |
| 9757 | del_targets_rule(Parser *p) |
| 9758 | { |
| 9759 | if (p->error_indicator) { |
| 9760 | return NULL; |
| 9761 | } |
| 9762 | asdl_seq* res = NULL; |
| 9763 | int mark = p->mark; |
| 9764 | { // ','.del_target+ ','? |
| 9765 | asdl_seq * a; |
| 9766 | void *opt_var; |
| 9767 | UNUSED(opt_var); // Silence compiler warnings |
| 9768 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9769 | (a = _gather_121_rule(p)) // ','.del_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9770 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9771 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9772 | ) |
| 9773 | { |
| 9774 | res = a; |
| 9775 | if (res == NULL && PyErr_Occurred()) { |
| 9776 | p->error_indicator = 1; |
| 9777 | return NULL; |
| 9778 | } |
| 9779 | goto done; |
| 9780 | } |
| 9781 | p->mark = mark; |
| 9782 | } |
| 9783 | res = NULL; |
| 9784 | done: |
| 9785 | return res; |
| 9786 | } |
| 9787 | |
| 9788 | // del_target: |
| 9789 | // | t_primary '.' NAME !t_lookahead |
| 9790 | // | t_primary '[' slices ']' !t_lookahead |
| 9791 | // | del_t_atom |
| 9792 | static expr_ty |
| 9793 | del_target_rule(Parser *p) |
| 9794 | { |
| 9795 | if (p->error_indicator) { |
| 9796 | return NULL; |
| 9797 | } |
| 9798 | expr_ty res = NULL; |
| 9799 | if (_PyPegen_is_memoized(p, del_target_type, &res)) |
| 9800 | return res; |
| 9801 | int mark = p->mark; |
| 9802 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9803 | p->error_indicator = 1; |
| 9804 | return NULL; |
| 9805 | } |
| 9806 | int start_lineno = p->tokens[mark]->lineno; |
| 9807 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9808 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9809 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9810 | { // t_primary '.' NAME !t_lookahead |
| 9811 | expr_ty a; |
| 9812 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9813 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9814 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9815 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9816 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9817 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9818 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9819 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9820 | && |
| 9821 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9822 | ) |
| 9823 | { |
| 9824 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9825 | if (token == NULL) { |
| 9826 | return NULL; |
| 9827 | } |
| 9828 | int end_lineno = token->end_lineno; |
| 9829 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9830 | int end_col_offset = token->end_col_offset; |
| 9831 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9832 | res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); |
| 9833 | if (res == NULL && PyErr_Occurred()) { |
| 9834 | p->error_indicator = 1; |
| 9835 | return NULL; |
| 9836 | } |
| 9837 | goto done; |
| 9838 | } |
| 9839 | p->mark = mark; |
| 9840 | } |
| 9841 | { // t_primary '[' slices ']' !t_lookahead |
| 9842 | expr_ty a; |
| 9843 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9844 | Token * literal; |
| 9845 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9846 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9847 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9848 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9849 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9850 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9851 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9852 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9853 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9854 | && |
| 9855 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9856 | ) |
| 9857 | { |
| 9858 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9859 | if (token == NULL) { |
| 9860 | return NULL; |
| 9861 | } |
| 9862 | int end_lineno = token->end_lineno; |
| 9863 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9864 | int end_col_offset = token->end_col_offset; |
| 9865 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9866 | res = _Py_Subscript ( a , b , Del , EXTRA ); |
| 9867 | if (res == NULL && PyErr_Occurred()) { |
| 9868 | p->error_indicator = 1; |
| 9869 | return NULL; |
| 9870 | } |
| 9871 | goto done; |
| 9872 | } |
| 9873 | p->mark = mark; |
| 9874 | } |
| 9875 | { // del_t_atom |
| 9876 | expr_ty del_t_atom_var; |
| 9877 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9878 | (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9879 | ) |
| 9880 | { |
| 9881 | res = del_t_atom_var; |
| 9882 | goto done; |
| 9883 | } |
| 9884 | p->mark = mark; |
| 9885 | } |
| 9886 | res = NULL; |
| 9887 | done: |
| 9888 | _PyPegen_insert_memo(p, mark, del_target_type, res); |
| 9889 | return res; |
| 9890 | } |
| 9891 | |
| 9892 | // del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']' |
| 9893 | static expr_ty |
| 9894 | del_t_atom_rule(Parser *p) |
| 9895 | { |
| 9896 | if (p->error_indicator) { |
| 9897 | return NULL; |
| 9898 | } |
| 9899 | expr_ty res = NULL; |
| 9900 | int mark = p->mark; |
| 9901 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9902 | p->error_indicator = 1; |
| 9903 | return NULL; |
| 9904 | } |
| 9905 | int start_lineno = p->tokens[mark]->lineno; |
| 9906 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9907 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9908 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9909 | { // NAME |
| 9910 | expr_ty a; |
| 9911 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9912 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9913 | ) |
| 9914 | { |
| 9915 | res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9916 | if (res == NULL && PyErr_Occurred()) { |
| 9917 | p->error_indicator = 1; |
| 9918 | return NULL; |
| 9919 | } |
| 9920 | goto done; |
| 9921 | } |
| 9922 | p->mark = mark; |
| 9923 | } |
| 9924 | { // '(' del_target ')' |
| 9925 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9926 | Token * literal; |
| 9927 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9928 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9929 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9930 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9931 | (a = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9932 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9933 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9934 | ) |
| 9935 | { |
| 9936 | res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9937 | if (res == NULL && PyErr_Occurred()) { |
| 9938 | p->error_indicator = 1; |
| 9939 | return NULL; |
| 9940 | } |
| 9941 | goto done; |
| 9942 | } |
| 9943 | p->mark = mark; |
| 9944 | } |
| 9945 | { // '(' del_targets? ')' |
| 9946 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9947 | Token * literal; |
| 9948 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9949 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9950 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9951 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9952 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9953 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9954 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9955 | ) |
| 9956 | { |
| 9957 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9958 | if (token == NULL) { |
| 9959 | return NULL; |
| 9960 | } |
| 9961 | int end_lineno = token->end_lineno; |
| 9962 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9963 | int end_col_offset = token->end_col_offset; |
| 9964 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9965 | res = _Py_Tuple ( a , Del , EXTRA ); |
| 9966 | if (res == NULL && PyErr_Occurred()) { |
| 9967 | p->error_indicator = 1; |
| 9968 | return NULL; |
| 9969 | } |
| 9970 | goto done; |
| 9971 | } |
| 9972 | p->mark = mark; |
| 9973 | } |
| 9974 | { // '[' del_targets? ']' |
| 9975 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9976 | Token * literal; |
| 9977 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9978 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9979 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9980 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9981 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9982 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9983 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9984 | ) |
| 9985 | { |
| 9986 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9987 | if (token == NULL) { |
| 9988 | return NULL; |
| 9989 | } |
| 9990 | int end_lineno = token->end_lineno; |
| 9991 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9992 | int end_col_offset = token->end_col_offset; |
| 9993 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9994 | res = _Py_List ( a , Del , EXTRA ); |
| 9995 | if (res == NULL && PyErr_Occurred()) { |
| 9996 | p->error_indicator = 1; |
| 9997 | return NULL; |
| 9998 | } |
| 9999 | goto done; |
| 10000 | } |
| 10001 | p->mark = mark; |
| 10002 | } |
| 10003 | res = NULL; |
| 10004 | done: |
| 10005 | return res; |
| 10006 | } |
| 10007 | |
| 10008 | // targets: ','.target+ ','? |
| 10009 | static asdl_seq* |
| 10010 | targets_rule(Parser *p) |
| 10011 | { |
| 10012 | if (p->error_indicator) { |
| 10013 | return NULL; |
| 10014 | } |
| 10015 | asdl_seq* res = NULL; |
| 10016 | int mark = p->mark; |
| 10017 | { // ','.target+ ','? |
| 10018 | asdl_seq * a; |
| 10019 | void *opt_var; |
| 10020 | UNUSED(opt_var); // Silence compiler warnings |
| 10021 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10022 | (a = _gather_123_rule(p)) // ','.target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10023 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10024 | (opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10025 | ) |
| 10026 | { |
| 10027 | res = a; |
| 10028 | if (res == NULL && PyErr_Occurred()) { |
| 10029 | p->error_indicator = 1; |
| 10030 | return NULL; |
| 10031 | } |
| 10032 | goto done; |
| 10033 | } |
| 10034 | p->mark = mark; |
| 10035 | } |
| 10036 | res = NULL; |
| 10037 | done: |
| 10038 | return res; |
| 10039 | } |
| 10040 | |
| 10041 | // target: |
| 10042 | // | t_primary '.' NAME !t_lookahead |
| 10043 | // | t_primary '[' slices ']' !t_lookahead |
| 10044 | // | t_atom |
| 10045 | static expr_ty |
| 10046 | target_rule(Parser *p) |
| 10047 | { |
| 10048 | if (p->error_indicator) { |
| 10049 | return NULL; |
| 10050 | } |
| 10051 | expr_ty res = NULL; |
| 10052 | if (_PyPegen_is_memoized(p, target_type, &res)) |
| 10053 | return res; |
| 10054 | int mark = p->mark; |
| 10055 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10056 | p->error_indicator = 1; |
| 10057 | return NULL; |
| 10058 | } |
| 10059 | int start_lineno = p->tokens[mark]->lineno; |
| 10060 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 10061 | int start_col_offset = p->tokens[mark]->col_offset; |
| 10062 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 10063 | { // t_primary '.' NAME !t_lookahead |
| 10064 | expr_ty a; |
| 10065 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10066 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10067 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10068 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10069 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10070 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10071 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10072 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10073 | && |
| 10074 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10075 | ) |
| 10076 | { |
| 10077 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10078 | if (token == NULL) { |
| 10079 | return NULL; |
| 10080 | } |
| 10081 | int end_lineno = token->end_lineno; |
| 10082 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10083 | int end_col_offset = token->end_col_offset; |
| 10084 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10085 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 10086 | if (res == NULL && PyErr_Occurred()) { |
| 10087 | p->error_indicator = 1; |
| 10088 | return NULL; |
| 10089 | } |
| 10090 | goto done; |
| 10091 | } |
| 10092 | p->mark = mark; |
| 10093 | } |
| 10094 | { // t_primary '[' slices ']' !t_lookahead |
| 10095 | expr_ty a; |
| 10096 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10097 | Token * literal; |
| 10098 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10099 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10100 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10101 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10102 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10103 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10104 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10105 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10106 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10107 | && |
| 10108 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10109 | ) |
| 10110 | { |
| 10111 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10112 | if (token == NULL) { |
| 10113 | return NULL; |
| 10114 | } |
| 10115 | int end_lineno = token->end_lineno; |
| 10116 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10117 | int end_col_offset = token->end_col_offset; |
| 10118 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10119 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 10120 | if (res == NULL && PyErr_Occurred()) { |
| 10121 | p->error_indicator = 1; |
| 10122 | return NULL; |
| 10123 | } |
| 10124 | goto done; |
| 10125 | } |
| 10126 | p->mark = mark; |
| 10127 | } |
| 10128 | { // t_atom |
| 10129 | expr_ty t_atom_var; |
| 10130 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10131 | (t_atom_var = t_atom_rule(p)) // t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10132 | ) |
| 10133 | { |
| 10134 | res = t_atom_var; |
| 10135 | goto done; |
| 10136 | } |
| 10137 | p->mark = mark; |
| 10138 | } |
| 10139 | res = NULL; |
| 10140 | done: |
| 10141 | _PyPegen_insert_memo(p, mark, target_type, res); |
| 10142 | return res; |
| 10143 | } |
| 10144 | |
| 10145 | // Left-recursive |
| 10146 | // t_primary: |
| 10147 | // | t_primary '.' NAME &t_lookahead |
| 10148 | // | t_primary '[' slices ']' &t_lookahead |
| 10149 | // | t_primary genexp &t_lookahead |
| 10150 | // | t_primary '(' arguments? ')' &t_lookahead |
| 10151 | // | atom &t_lookahead |
| 10152 | static expr_ty t_primary_raw(Parser *); |
| 10153 | static expr_ty |
| 10154 | t_primary_rule(Parser *p) |
| 10155 | { |
| 10156 | expr_ty res = NULL; |
| 10157 | if (_PyPegen_is_memoized(p, t_primary_type, &res)) |
| 10158 | return res; |
| 10159 | int mark = p->mark; |
| 10160 | int resmark = p->mark; |
| 10161 | while (1) { |
| 10162 | int tmpvar_8 = _PyPegen_update_memo(p, mark, t_primary_type, res); |
| 10163 | if (tmpvar_8) { |
| 10164 | return res; |
| 10165 | } |
| 10166 | p->mark = mark; |
| 10167 | void *raw = t_primary_raw(p); |
| 10168 | if (raw == NULL || p->mark <= resmark) |
| 10169 | break; |
| 10170 | resmark = p->mark; |
| 10171 | res = raw; |
| 10172 | } |
| 10173 | p->mark = resmark; |
| 10174 | return res; |
| 10175 | } |
| 10176 | static expr_ty |
| 10177 | t_primary_raw(Parser *p) |
| 10178 | { |
| 10179 | if (p->error_indicator) { |
| 10180 | return NULL; |
| 10181 | } |
| 10182 | expr_ty res = NULL; |
| 10183 | int mark = p->mark; |
| 10184 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10185 | p->error_indicator = 1; |
| 10186 | return NULL; |
| 10187 | } |
| 10188 | int start_lineno = p->tokens[mark]->lineno; |
| 10189 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 10190 | int start_col_offset = p->tokens[mark]->col_offset; |
| 10191 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 10192 | { // t_primary '.' NAME &t_lookahead |
| 10193 | expr_ty a; |
| 10194 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10195 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10196 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10197 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10198 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10199 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10200 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10201 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10202 | && |
| 10203 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10204 | ) |
| 10205 | { |
| 10206 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10207 | if (token == NULL) { |
| 10208 | return NULL; |
| 10209 | } |
| 10210 | int end_lineno = token->end_lineno; |
| 10211 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10212 | int end_col_offset = token->end_col_offset; |
| 10213 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10214 | res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 10215 | if (res == NULL && PyErr_Occurred()) { |
| 10216 | p->error_indicator = 1; |
| 10217 | return NULL; |
| 10218 | } |
| 10219 | goto done; |
| 10220 | } |
| 10221 | p->mark = mark; |
| 10222 | } |
| 10223 | { // t_primary '[' slices ']' &t_lookahead |
| 10224 | expr_ty a; |
| 10225 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10226 | Token * literal; |
| 10227 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10228 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10229 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10230 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10231 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10232 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10233 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10234 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10235 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10236 | && |
| 10237 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10238 | ) |
| 10239 | { |
| 10240 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10241 | if (token == NULL) { |
| 10242 | return NULL; |
| 10243 | } |
| 10244 | int end_lineno = token->end_lineno; |
| 10245 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10246 | int end_col_offset = token->end_col_offset; |
| 10247 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10248 | res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 10249 | if (res == NULL && PyErr_Occurred()) { |
| 10250 | p->error_indicator = 1; |
| 10251 | return NULL; |
| 10252 | } |
| 10253 | goto done; |
| 10254 | } |
| 10255 | p->mark = mark; |
| 10256 | } |
| 10257 | { // t_primary genexp &t_lookahead |
| 10258 | expr_ty a; |
| 10259 | expr_ty b; |
| 10260 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10261 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10262 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10263 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10264 | && |
| 10265 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10266 | ) |
| 10267 | { |
| 10268 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10269 | if (token == NULL) { |
| 10270 | return NULL; |
| 10271 | } |
| 10272 | int end_lineno = token->end_lineno; |
| 10273 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10274 | int end_col_offset = token->end_col_offset; |
| 10275 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10276 | res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 10277 | if (res == NULL && PyErr_Occurred()) { |
| 10278 | p->error_indicator = 1; |
| 10279 | return NULL; |
| 10280 | } |
| 10281 | goto done; |
| 10282 | } |
| 10283 | p->mark = mark; |
| 10284 | } |
| 10285 | { // t_primary '(' arguments? ')' &t_lookahead |
| 10286 | expr_ty a; |
| 10287 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10288 | Token * literal; |
| 10289 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10290 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10291 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10292 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10293 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10294 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10295 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10296 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10297 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10298 | && |
| 10299 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10300 | ) |
| 10301 | { |
| 10302 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10303 | if (token == NULL) { |
| 10304 | return NULL; |
| 10305 | } |
| 10306 | int end_lineno = token->end_lineno; |
| 10307 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10308 | int end_col_offset = token->end_col_offset; |
| 10309 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10310 | res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 10311 | if (res == NULL && PyErr_Occurred()) { |
| 10312 | p->error_indicator = 1; |
| 10313 | return NULL; |
| 10314 | } |
| 10315 | goto done; |
| 10316 | } |
| 10317 | p->mark = mark; |
| 10318 | } |
| 10319 | { // atom &t_lookahead |
| 10320 | expr_ty a; |
| 10321 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10322 | (a = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10323 | && |
| 10324 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10325 | ) |
| 10326 | { |
| 10327 | res = a; |
| 10328 | if (res == NULL && PyErr_Occurred()) { |
| 10329 | p->error_indicator = 1; |
| 10330 | return NULL; |
| 10331 | } |
| 10332 | goto done; |
| 10333 | } |
| 10334 | p->mark = mark; |
| 10335 | } |
| 10336 | res = NULL; |
| 10337 | done: |
| 10338 | return res; |
| 10339 | } |
| 10340 | |
| 10341 | // t_lookahead: '(' | '[' | '.' |
| 10342 | static void * |
| 10343 | t_lookahead_rule(Parser *p) |
| 10344 | { |
| 10345 | if (p->error_indicator) { |
| 10346 | return NULL; |
| 10347 | } |
| 10348 | void * res = NULL; |
| 10349 | int mark = p->mark; |
| 10350 | { // '(' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10351 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10352 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10353 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10354 | ) |
| 10355 | { |
| 10356 | res = literal; |
| 10357 | goto done; |
| 10358 | } |
| 10359 | p->mark = mark; |
| 10360 | } |
| 10361 | { // '[' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10362 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10363 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10364 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10365 | ) |
| 10366 | { |
| 10367 | res = literal; |
| 10368 | goto done; |
| 10369 | } |
| 10370 | p->mark = mark; |
| 10371 | } |
| 10372 | { // '.' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10373 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10374 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10375 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10376 | ) |
| 10377 | { |
| 10378 | res = literal; |
| 10379 | goto done; |
| 10380 | } |
| 10381 | p->mark = mark; |
| 10382 | } |
| 10383 | res = NULL; |
| 10384 | done: |
| 10385 | return res; |
| 10386 | } |
| 10387 | |
| 10388 | // t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' |
| 10389 | static expr_ty |
| 10390 | t_atom_rule(Parser *p) |
| 10391 | { |
| 10392 | if (p->error_indicator) { |
| 10393 | return NULL; |
| 10394 | } |
| 10395 | expr_ty res = NULL; |
| 10396 | int mark = p->mark; |
| 10397 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10398 | p->error_indicator = 1; |
| 10399 | return NULL; |
| 10400 | } |
| 10401 | int start_lineno = p->tokens[mark]->lineno; |
| 10402 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 10403 | int start_col_offset = p->tokens[mark]->col_offset; |
| 10404 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 10405 | { // NAME |
| 10406 | expr_ty a; |
| 10407 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10408 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10409 | ) |
| 10410 | { |
| 10411 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10412 | if (res == NULL && PyErr_Occurred()) { |
| 10413 | p->error_indicator = 1; |
| 10414 | return NULL; |
| 10415 | } |
| 10416 | goto done; |
| 10417 | } |
| 10418 | p->mark = mark; |
| 10419 | } |
| 10420 | { // '(' target ')' |
| 10421 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10422 | Token * literal; |
| 10423 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10424 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10425 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10426 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10427 | (a = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10428 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10429 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10430 | ) |
| 10431 | { |
| 10432 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10433 | if (res == NULL && PyErr_Occurred()) { |
| 10434 | p->error_indicator = 1; |
| 10435 | return NULL; |
| 10436 | } |
| 10437 | goto done; |
| 10438 | } |
| 10439 | p->mark = mark; |
| 10440 | } |
| 10441 | { // '(' targets? ')' |
| 10442 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10443 | Token * literal; |
| 10444 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10445 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10446 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10447 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10448 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10449 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10450 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10451 | ) |
| 10452 | { |
| 10453 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10454 | if (token == NULL) { |
| 10455 | return NULL; |
| 10456 | } |
| 10457 | int end_lineno = token->end_lineno; |
| 10458 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10459 | int end_col_offset = token->end_col_offset; |
| 10460 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10461 | res = _Py_Tuple ( b , Store , EXTRA ); |
| 10462 | if (res == NULL && PyErr_Occurred()) { |
| 10463 | p->error_indicator = 1; |
| 10464 | return NULL; |
| 10465 | } |
| 10466 | goto done; |
| 10467 | } |
| 10468 | p->mark = mark; |
| 10469 | } |
| 10470 | { // '[' targets? ']' |
| 10471 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10472 | Token * literal; |
| 10473 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10474 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10475 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10476 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10477 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10478 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10479 | (literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10480 | ) |
| 10481 | { |
| 10482 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10483 | if (token == NULL) { |
| 10484 | return NULL; |
| 10485 | } |
| 10486 | int end_lineno = token->end_lineno; |
| 10487 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10488 | int end_col_offset = token->end_col_offset; |
| 10489 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10490 | res = _Py_List ( b , Store , EXTRA ); |
| 10491 | if (res == NULL && PyErr_Occurred()) { |
| 10492 | p->error_indicator = 1; |
| 10493 | return NULL; |
| 10494 | } |
| 10495 | goto done; |
| 10496 | } |
| 10497 | p->mark = mark; |
| 10498 | } |
| 10499 | res = NULL; |
| 10500 | done: |
| 10501 | return res; |
| 10502 | } |
| 10503 | |
| 10504 | // incorrect_arguments: |
| 10505 | // | args ',' '*' |
| 10506 | // | expression for_if_clauses ',' [args | expression for_if_clauses] |
| 10507 | // | args ',' args |
| 10508 | static void * |
| 10509 | incorrect_arguments_rule(Parser *p) |
| 10510 | { |
| 10511 | if (p->error_indicator) { |
| 10512 | return NULL; |
| 10513 | } |
| 10514 | void * res = NULL; |
| 10515 | int mark = p->mark; |
| 10516 | { // args ',' '*' |
| 10517 | expr_ty args_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10518 | Token * literal; |
| 10519 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10520 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10521 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10522 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10523 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10524 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10525 | (literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10526 | ) |
| 10527 | { |
| 10528 | res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); |
| 10529 | if (res == NULL && PyErr_Occurred()) { |
| 10530 | p->error_indicator = 1; |
| 10531 | return NULL; |
| 10532 | } |
| 10533 | goto done; |
| 10534 | } |
| 10535 | p->mark = mark; |
| 10536 | } |
| 10537 | { // expression for_if_clauses ',' [args | expression for_if_clauses] |
| 10538 | expr_ty expression_var; |
| 10539 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10540 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10541 | void *opt_var; |
| 10542 | UNUSED(opt_var); // Silence compiler warnings |
| 10543 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10544 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10545 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10546 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10547 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10548 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10549 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10550 | (opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10551 | ) |
| 10552 | { |
| 10553 | res = RAISE_SYNTAX_ERROR ( "Generator expression must be parenthesized" ); |
| 10554 | if (res == NULL && PyErr_Occurred()) { |
| 10555 | p->error_indicator = 1; |
| 10556 | return NULL; |
| 10557 | } |
| 10558 | goto done; |
| 10559 | } |
| 10560 | p->mark = mark; |
| 10561 | } |
| 10562 | { // args ',' args |
| 10563 | expr_ty a; |
| 10564 | expr_ty args_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10565 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10566 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10567 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10568 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10569 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10570 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10571 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10572 | ) |
| 10573 | { |
| 10574 | res = _PyPegen_arguments_parsing_error ( p , a ); |
| 10575 | if (res == NULL && PyErr_Occurred()) { |
| 10576 | p->error_indicator = 1; |
| 10577 | return NULL; |
| 10578 | } |
| 10579 | goto done; |
| 10580 | } |
| 10581 | p->mark = mark; |
| 10582 | } |
| 10583 | res = NULL; |
| 10584 | done: |
| 10585 | return res; |
| 10586 | } |
| 10587 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame^] | 10588 | // invalid_kwarg: expression '=' |
| 10589 | static void * |
| 10590 | invalid_kwarg_rule(Parser *p) |
| 10591 | { |
| 10592 | if (p->error_indicator) { |
| 10593 | return NULL; |
| 10594 | } |
| 10595 | void * res = NULL; |
| 10596 | int mark = p->mark; |
| 10597 | { // expression '=' |
| 10598 | expr_ty expression_var; |
| 10599 | Token * literal; |
| 10600 | if ( |
| 10601 | (expression_var = expression_rule(p)) // expression |
| 10602 | && |
| 10603 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 10604 | ) |
| 10605 | { |
| 10606 | res = RAISE_SYNTAX_ERROR ( "expression cannot contain assignment, perhaps you meant \"==\"?" ); |
| 10607 | if (res == NULL && PyErr_Occurred()) { |
| 10608 | p->error_indicator = 1; |
| 10609 | return NULL; |
| 10610 | } |
| 10611 | goto done; |
| 10612 | } |
| 10613 | p->mark = mark; |
| 10614 | } |
| 10615 | res = NULL; |
| 10616 | done: |
| 10617 | return res; |
| 10618 | } |
| 10619 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10620 | // invalid_named_expression: expression ':=' expression |
| 10621 | static void * |
| 10622 | invalid_named_expression_rule(Parser *p) |
| 10623 | { |
| 10624 | if (p->error_indicator) { |
| 10625 | return NULL; |
| 10626 | } |
| 10627 | void * res = NULL; |
| 10628 | int mark = p->mark; |
| 10629 | { // expression ':=' expression |
| 10630 | expr_ty a; |
| 10631 | expr_ty expression_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10632 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10633 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10634 | (a = expression_rule(p)) // expression |
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, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10637 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10638 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10639 | ) |
| 10640 | { |
| 10641 | res = RAISE_SYNTAX_ERROR ( "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); |
| 10642 | if (res == NULL && PyErr_Occurred()) { |
| 10643 | p->error_indicator = 1; |
| 10644 | return NULL; |
| 10645 | } |
| 10646 | goto done; |
| 10647 | } |
| 10648 | p->mark = mark; |
| 10649 | } |
| 10650 | res = NULL; |
| 10651 | done: |
| 10652 | return res; |
| 10653 | } |
| 10654 | |
| 10655 | // invalid_assignment: |
| 10656 | // | list ':' |
| 10657 | // | tuple ':' |
| 10658 | // | expression ':' expression ['=' annotated_rhs] |
| 10659 | // | expression ('=' | augassign) (yield_expr | star_expressions) |
| 10660 | static void * |
| 10661 | invalid_assignment_rule(Parser *p) |
| 10662 | { |
| 10663 | if (p->error_indicator) { |
| 10664 | return NULL; |
| 10665 | } |
| 10666 | void * res = NULL; |
| 10667 | int mark = p->mark; |
| 10668 | { // list ':' |
| 10669 | expr_ty list_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10670 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10671 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10672 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10673 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10674 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10675 | ) |
| 10676 | { |
| 10677 | res = RAISE_SYNTAX_ERROR ( "only single target (not list) can be annotated" ); |
| 10678 | if (res == NULL && PyErr_Occurred()) { |
| 10679 | p->error_indicator = 1; |
| 10680 | return NULL; |
| 10681 | } |
| 10682 | goto done; |
| 10683 | } |
| 10684 | p->mark = mark; |
| 10685 | } |
| 10686 | { // tuple ':' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10687 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10688 | expr_ty tuple_var; |
| 10689 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10690 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10691 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10692 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10693 | ) |
| 10694 | { |
| 10695 | res = RAISE_SYNTAX_ERROR ( "only single target (not tuple) can be annotated" ); |
| 10696 | if (res == NULL && PyErr_Occurred()) { |
| 10697 | p->error_indicator = 1; |
| 10698 | return NULL; |
| 10699 | } |
| 10700 | goto done; |
| 10701 | } |
| 10702 | p->mark = mark; |
| 10703 | } |
| 10704 | { // expression ':' expression ['=' annotated_rhs] |
| 10705 | expr_ty expression_var; |
| 10706 | expr_ty expression_var_1; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10707 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10708 | void *opt_var; |
| 10709 | UNUSED(opt_var); // Silence compiler warnings |
| 10710 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10711 | (expression_var = expression_rule(p)) // expression |
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 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10714 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10715 | (expression_var_1 = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10716 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10717 | (opt_var = _tmp_126_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10718 | ) |
| 10719 | { |
| 10720 | res = RAISE_SYNTAX_ERROR ( "illegal target for annotation" ); |
| 10721 | if (res == NULL && PyErr_Occurred()) { |
| 10722 | p->error_indicator = 1; |
| 10723 | return NULL; |
| 10724 | } |
| 10725 | goto done; |
| 10726 | } |
| 10727 | p->mark = mark; |
| 10728 | } |
| 10729 | { // expression ('=' | augassign) (yield_expr | star_expressions) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10730 | void *_tmp_127_var; |
| 10731 | void *_tmp_128_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10732 | expr_ty a; |
| 10733 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10734 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10735 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10736 | (_tmp_127_var = _tmp_127_rule(p)) // '=' | augassign |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10737 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10738 | (_tmp_128_var = _tmp_128_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10739 | ) |
| 10740 | { |
Batuhan Taskaya | 76c1b4d | 2020-05-01 16:13:43 +0300 | [diff] [blame] | 10741 | 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] | 10742 | if (res == NULL && PyErr_Occurred()) { |
| 10743 | p->error_indicator = 1; |
| 10744 | return NULL; |
| 10745 | } |
| 10746 | goto done; |
| 10747 | } |
| 10748 | p->mark = mark; |
| 10749 | } |
| 10750 | res = NULL; |
| 10751 | done: |
| 10752 | return res; |
| 10753 | } |
| 10754 | |
| 10755 | // invalid_block: NEWLINE !INDENT |
| 10756 | static void * |
| 10757 | invalid_block_rule(Parser *p) |
| 10758 | { |
| 10759 | if (p->error_indicator) { |
| 10760 | return NULL; |
| 10761 | } |
| 10762 | void * res = NULL; |
| 10763 | int mark = p->mark; |
| 10764 | { // NEWLINE !INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10765 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10766 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10767 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10768 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10769 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10770 | ) |
| 10771 | { |
| 10772 | res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); |
| 10773 | if (res == NULL && PyErr_Occurred()) { |
| 10774 | p->error_indicator = 1; |
| 10775 | return NULL; |
| 10776 | } |
| 10777 | goto done; |
| 10778 | } |
| 10779 | p->mark = mark; |
| 10780 | } |
| 10781 | res = NULL; |
| 10782 | done: |
| 10783 | return res; |
| 10784 | } |
| 10785 | |
| 10786 | // invalid_comprehension: ('[' | '(' | '{') '*' expression for_if_clauses |
| 10787 | static void * |
| 10788 | invalid_comprehension_rule(Parser *p) |
| 10789 | { |
| 10790 | if (p->error_indicator) { |
| 10791 | return NULL; |
| 10792 | } |
| 10793 | void * res = NULL; |
| 10794 | int mark = p->mark; |
| 10795 | { // ('[' | '(' | '{') '*' expression for_if_clauses |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10796 | void *_tmp_129_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10797 | expr_ty expression_var; |
| 10798 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10799 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10800 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10801 | (_tmp_129_var = _tmp_129_rule(p)) // '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10802 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10803 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10804 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10805 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10806 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10807 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10808 | ) |
| 10809 | { |
| 10810 | res = RAISE_SYNTAX_ERROR ( "iterable unpacking cannot be used in comprehension" ); |
| 10811 | if (res == NULL && PyErr_Occurred()) { |
| 10812 | p->error_indicator = 1; |
| 10813 | return NULL; |
| 10814 | } |
| 10815 | goto done; |
| 10816 | } |
| 10817 | p->mark = mark; |
| 10818 | } |
| 10819 | res = NULL; |
| 10820 | done: |
| 10821 | return res; |
| 10822 | } |
| 10823 | |
| 10824 | // invalid_parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10825 | // | param_no_default* (slash_with_default | param_with_default+) param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10826 | static void * |
| 10827 | invalid_parameters_rule(Parser *p) |
| 10828 | { |
| 10829 | if (p->error_indicator) { |
| 10830 | return NULL; |
| 10831 | } |
| 10832 | void * res = NULL; |
| 10833 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10834 | { // 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] | 10835 | asdl_seq * _loop0_130_var; |
| 10836 | void *_tmp_131_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10837 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10838 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10839 | (_loop0_130_var = _loop0_130_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10840 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10841 | (_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] | 10842 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10843 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10844 | ) |
| 10845 | { |
| 10846 | res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 10847 | if (res == NULL && PyErr_Occurred()) { |
| 10848 | p->error_indicator = 1; |
| 10849 | return NULL; |
| 10850 | } |
| 10851 | goto done; |
| 10852 | } |
| 10853 | p->mark = mark; |
| 10854 | } |
| 10855 | res = NULL; |
| 10856 | done: |
| 10857 | return res; |
| 10858 | } |
| 10859 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10860 | // invalid_star_etc: '*' (')' | ',' (')' | '**')) |
| 10861 | static void * |
| 10862 | invalid_star_etc_rule(Parser *p) |
| 10863 | { |
| 10864 | if (p->error_indicator) { |
| 10865 | return NULL; |
| 10866 | } |
| 10867 | void * res = NULL; |
| 10868 | int mark = p->mark; |
| 10869 | { // '*' (')' | ',' (')' | '**')) |
| 10870 | void *_tmp_132_var; |
| 10871 | Token * literal; |
| 10872 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10873 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10874 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10875 | (_tmp_132_var = _tmp_132_rule(p)) // ')' | ',' (')' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10876 | ) |
| 10877 | { |
| 10878 | res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 10879 | if (res == NULL && PyErr_Occurred()) { |
| 10880 | p->error_indicator = 1; |
| 10881 | return NULL; |
| 10882 | } |
| 10883 | goto done; |
| 10884 | } |
| 10885 | p->mark = mark; |
| 10886 | } |
| 10887 | res = NULL; |
| 10888 | done: |
| 10889 | return res; |
| 10890 | } |
| 10891 | |
| 10892 | // invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) |
| 10893 | static void * |
| 10894 | invalid_lambda_star_etc_rule(Parser *p) |
| 10895 | { |
| 10896 | if (p->error_indicator) { |
| 10897 | return NULL; |
| 10898 | } |
| 10899 | void * res = NULL; |
| 10900 | int mark = p->mark; |
| 10901 | { // '*' (':' | ',' (':' | '**')) |
| 10902 | void *_tmp_133_var; |
| 10903 | Token * literal; |
| 10904 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10905 | (literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10906 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10907 | (_tmp_133_var = _tmp_133_rule(p)) // ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10908 | ) |
| 10909 | { |
| 10910 | res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 10911 | if (res == NULL && PyErr_Occurred()) { |
| 10912 | p->error_indicator = 1; |
| 10913 | return NULL; |
| 10914 | } |
| 10915 | goto done; |
| 10916 | } |
| 10917 | p->mark = mark; |
| 10918 | } |
| 10919 | res = NULL; |
| 10920 | done: |
| 10921 | return res; |
| 10922 | } |
| 10923 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10924 | // invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 10925 | static void * |
| 10926 | invalid_double_type_comments_rule(Parser *p) |
| 10927 | { |
| 10928 | if (p->error_indicator) { |
| 10929 | return NULL; |
| 10930 | } |
| 10931 | void * res = NULL; |
| 10932 | int mark = p->mark; |
| 10933 | { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10934 | Token * indent_var; |
| 10935 | Token * newline_var; |
| 10936 | Token * newline_var_1; |
| 10937 | Token * type_comment_var; |
| 10938 | Token * type_comment_var_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10939 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10940 | (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] | 10941 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10942 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10943 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10944 | (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] | 10945 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10946 | (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10947 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10948 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10949 | ) |
| 10950 | { |
| 10951 | res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); |
| 10952 | if (res == NULL && PyErr_Occurred()) { |
| 10953 | p->error_indicator = 1; |
| 10954 | return NULL; |
| 10955 | } |
| 10956 | goto done; |
| 10957 | } |
| 10958 | p->mark = mark; |
| 10959 | } |
| 10960 | res = NULL; |
| 10961 | done: |
| 10962 | return res; |
| 10963 | } |
| 10964 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10965 | // _loop0_1: NEWLINE |
| 10966 | static asdl_seq * |
| 10967 | _loop0_1_rule(Parser *p) |
| 10968 | { |
| 10969 | if (p->error_indicator) { |
| 10970 | return NULL; |
| 10971 | } |
| 10972 | void *res = NULL; |
| 10973 | int mark = p->mark; |
| 10974 | int start_mark = p->mark; |
| 10975 | void **children = PyMem_Malloc(sizeof(void *)); |
| 10976 | if (!children) { |
| 10977 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 10978 | return NULL; |
| 10979 | } |
| 10980 | ssize_t children_capacity = 1; |
| 10981 | ssize_t n = 0; |
| 10982 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10983 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10984 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10985 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10986 | ) |
| 10987 | { |
| 10988 | res = newline_var; |
| 10989 | if (n == children_capacity) { |
| 10990 | children_capacity *= 2; |
| 10991 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 10992 | if (!children) { |
| 10993 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 10994 | return NULL; |
| 10995 | } |
| 10996 | } |
| 10997 | children[n++] = res; |
| 10998 | mark = p->mark; |
| 10999 | } |
| 11000 | p->mark = mark; |
| 11001 | } |
| 11002 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11003 | if (!seq) { |
| 11004 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1"); |
| 11005 | PyMem_Free(children); |
| 11006 | return NULL; |
| 11007 | } |
| 11008 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11009 | PyMem_Free(children); |
| 11010 | _PyPegen_insert_memo(p, start_mark, _loop0_1_type, seq); |
| 11011 | return seq; |
| 11012 | } |
| 11013 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11014 | // _loop0_2: NEWLINE |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11015 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11016 | _loop0_2_rule(Parser *p) |
| 11017 | { |
| 11018 | if (p->error_indicator) { |
| 11019 | return NULL; |
| 11020 | } |
| 11021 | void *res = NULL; |
| 11022 | int mark = p->mark; |
| 11023 | int start_mark = p->mark; |
| 11024 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11025 | if (!children) { |
| 11026 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11027 | return NULL; |
| 11028 | } |
| 11029 | ssize_t children_capacity = 1; |
| 11030 | ssize_t n = 0; |
| 11031 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11032 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11033 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11034 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11035 | ) |
| 11036 | { |
| 11037 | res = newline_var; |
| 11038 | if (n == children_capacity) { |
| 11039 | children_capacity *= 2; |
| 11040 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11041 | if (!children) { |
| 11042 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11043 | return NULL; |
| 11044 | } |
| 11045 | } |
| 11046 | children[n++] = res; |
| 11047 | mark = p->mark; |
| 11048 | } |
| 11049 | p->mark = mark; |
| 11050 | } |
| 11051 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11052 | if (!seq) { |
| 11053 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2"); |
| 11054 | PyMem_Free(children); |
| 11055 | return NULL; |
| 11056 | } |
| 11057 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11058 | PyMem_Free(children); |
| 11059 | _PyPegen_insert_memo(p, start_mark, _loop0_2_type, seq); |
| 11060 | return seq; |
| 11061 | } |
| 11062 | |
| 11063 | // _loop0_4: ',' expression |
| 11064 | static asdl_seq * |
| 11065 | _loop0_4_rule(Parser *p) |
| 11066 | { |
| 11067 | if (p->error_indicator) { |
| 11068 | return NULL; |
| 11069 | } |
| 11070 | void *res = NULL; |
| 11071 | int mark = p->mark; |
| 11072 | int start_mark = p->mark; |
| 11073 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11074 | if (!children) { |
| 11075 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11076 | return NULL; |
| 11077 | } |
| 11078 | ssize_t children_capacity = 1; |
| 11079 | ssize_t n = 0; |
| 11080 | { // ',' expression |
| 11081 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11082 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11083 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11084 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11085 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11086 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11087 | ) |
| 11088 | { |
| 11089 | res = elem; |
| 11090 | if (res == NULL && PyErr_Occurred()) { |
| 11091 | p->error_indicator = 1; |
| 11092 | PyMem_Free(children); |
| 11093 | return NULL; |
| 11094 | } |
| 11095 | if (n == children_capacity) { |
| 11096 | children_capacity *= 2; |
| 11097 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11098 | if (!children) { |
| 11099 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11100 | return NULL; |
| 11101 | } |
| 11102 | } |
| 11103 | children[n++] = res; |
| 11104 | mark = p->mark; |
| 11105 | } |
| 11106 | p->mark = mark; |
| 11107 | } |
| 11108 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11109 | if (!seq) { |
| 11110 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4"); |
| 11111 | PyMem_Free(children); |
| 11112 | return NULL; |
| 11113 | } |
| 11114 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11115 | PyMem_Free(children); |
| 11116 | _PyPegen_insert_memo(p, start_mark, _loop0_4_type, seq); |
| 11117 | return seq; |
| 11118 | } |
| 11119 | |
| 11120 | // _gather_3: expression _loop0_4 |
| 11121 | static asdl_seq * |
| 11122 | _gather_3_rule(Parser *p) |
| 11123 | { |
| 11124 | if (p->error_indicator) { |
| 11125 | return NULL; |
| 11126 | } |
| 11127 | asdl_seq * res = NULL; |
| 11128 | int mark = p->mark; |
| 11129 | { // expression _loop0_4 |
| 11130 | expr_ty elem; |
| 11131 | asdl_seq * seq; |
| 11132 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11133 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11134 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11135 | (seq = _loop0_4_rule(p)) // _loop0_4 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11136 | ) |
| 11137 | { |
| 11138 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11139 | goto done; |
| 11140 | } |
| 11141 | p->mark = mark; |
| 11142 | } |
| 11143 | res = NULL; |
| 11144 | done: |
| 11145 | return res; |
| 11146 | } |
| 11147 | |
| 11148 | // _loop0_6: ',' expression |
| 11149 | static asdl_seq * |
| 11150 | _loop0_6_rule(Parser *p) |
| 11151 | { |
| 11152 | if (p->error_indicator) { |
| 11153 | return NULL; |
| 11154 | } |
| 11155 | void *res = NULL; |
| 11156 | int mark = p->mark; |
| 11157 | int start_mark = p->mark; |
| 11158 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11159 | if (!children) { |
| 11160 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11161 | return NULL; |
| 11162 | } |
| 11163 | ssize_t children_capacity = 1; |
| 11164 | ssize_t n = 0; |
| 11165 | { // ',' expression |
| 11166 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11167 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11168 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11169 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11170 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11171 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11172 | ) |
| 11173 | { |
| 11174 | res = elem; |
| 11175 | if (res == NULL && PyErr_Occurred()) { |
| 11176 | p->error_indicator = 1; |
| 11177 | PyMem_Free(children); |
| 11178 | return NULL; |
| 11179 | } |
| 11180 | if (n == children_capacity) { |
| 11181 | children_capacity *= 2; |
| 11182 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11183 | if (!children) { |
| 11184 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11185 | return NULL; |
| 11186 | } |
| 11187 | } |
| 11188 | children[n++] = res; |
| 11189 | mark = p->mark; |
| 11190 | } |
| 11191 | p->mark = mark; |
| 11192 | } |
| 11193 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11194 | if (!seq) { |
| 11195 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6"); |
| 11196 | PyMem_Free(children); |
| 11197 | return NULL; |
| 11198 | } |
| 11199 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11200 | PyMem_Free(children); |
| 11201 | _PyPegen_insert_memo(p, start_mark, _loop0_6_type, seq); |
| 11202 | return seq; |
| 11203 | } |
| 11204 | |
| 11205 | // _gather_5: expression _loop0_6 |
| 11206 | static asdl_seq * |
| 11207 | _gather_5_rule(Parser *p) |
| 11208 | { |
| 11209 | if (p->error_indicator) { |
| 11210 | return NULL; |
| 11211 | } |
| 11212 | asdl_seq * res = NULL; |
| 11213 | int mark = p->mark; |
| 11214 | { // expression _loop0_6 |
| 11215 | expr_ty elem; |
| 11216 | asdl_seq * seq; |
| 11217 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11218 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11219 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11220 | (seq = _loop0_6_rule(p)) // _loop0_6 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11221 | ) |
| 11222 | { |
| 11223 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11224 | goto done; |
| 11225 | } |
| 11226 | p->mark = mark; |
| 11227 | } |
| 11228 | res = NULL; |
| 11229 | done: |
| 11230 | return res; |
| 11231 | } |
| 11232 | |
| 11233 | // _loop0_8: ',' expression |
| 11234 | static asdl_seq * |
| 11235 | _loop0_8_rule(Parser *p) |
| 11236 | { |
| 11237 | if (p->error_indicator) { |
| 11238 | return NULL; |
| 11239 | } |
| 11240 | void *res = NULL; |
| 11241 | int mark = p->mark; |
| 11242 | int start_mark = p->mark; |
| 11243 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11244 | if (!children) { |
| 11245 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11246 | return NULL; |
| 11247 | } |
| 11248 | ssize_t children_capacity = 1; |
| 11249 | ssize_t n = 0; |
| 11250 | { // ',' expression |
| 11251 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11252 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11253 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11254 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11255 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11256 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11257 | ) |
| 11258 | { |
| 11259 | res = elem; |
| 11260 | if (res == NULL && PyErr_Occurred()) { |
| 11261 | p->error_indicator = 1; |
| 11262 | PyMem_Free(children); |
| 11263 | return NULL; |
| 11264 | } |
| 11265 | if (n == children_capacity) { |
| 11266 | children_capacity *= 2; |
| 11267 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11268 | if (!children) { |
| 11269 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11270 | return NULL; |
| 11271 | } |
| 11272 | } |
| 11273 | children[n++] = res; |
| 11274 | mark = p->mark; |
| 11275 | } |
| 11276 | p->mark = mark; |
| 11277 | } |
| 11278 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11279 | if (!seq) { |
| 11280 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8"); |
| 11281 | PyMem_Free(children); |
| 11282 | return NULL; |
| 11283 | } |
| 11284 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11285 | PyMem_Free(children); |
| 11286 | _PyPegen_insert_memo(p, start_mark, _loop0_8_type, seq); |
| 11287 | return seq; |
| 11288 | } |
| 11289 | |
| 11290 | // _gather_7: expression _loop0_8 |
| 11291 | static asdl_seq * |
| 11292 | _gather_7_rule(Parser *p) |
| 11293 | { |
| 11294 | if (p->error_indicator) { |
| 11295 | return NULL; |
| 11296 | } |
| 11297 | asdl_seq * res = NULL; |
| 11298 | int mark = p->mark; |
| 11299 | { // expression _loop0_8 |
| 11300 | expr_ty elem; |
| 11301 | asdl_seq * seq; |
| 11302 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11303 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11304 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11305 | (seq = _loop0_8_rule(p)) // _loop0_8 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11306 | ) |
| 11307 | { |
| 11308 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11309 | goto done; |
| 11310 | } |
| 11311 | p->mark = mark; |
| 11312 | } |
| 11313 | res = NULL; |
| 11314 | done: |
| 11315 | return res; |
| 11316 | } |
| 11317 | |
| 11318 | // _loop0_10: ',' expression |
| 11319 | static asdl_seq * |
| 11320 | _loop0_10_rule(Parser *p) |
| 11321 | { |
| 11322 | if (p->error_indicator) { |
| 11323 | return NULL; |
| 11324 | } |
| 11325 | void *res = NULL; |
| 11326 | int mark = p->mark; |
| 11327 | int start_mark = p->mark; |
| 11328 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11329 | if (!children) { |
| 11330 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11331 | return NULL; |
| 11332 | } |
| 11333 | ssize_t children_capacity = 1; |
| 11334 | ssize_t n = 0; |
| 11335 | { // ',' expression |
| 11336 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11337 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11338 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11339 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11340 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11341 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11342 | ) |
| 11343 | { |
| 11344 | res = elem; |
| 11345 | if (res == NULL && PyErr_Occurred()) { |
| 11346 | p->error_indicator = 1; |
| 11347 | PyMem_Free(children); |
| 11348 | return NULL; |
| 11349 | } |
| 11350 | if (n == children_capacity) { |
| 11351 | children_capacity *= 2; |
| 11352 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11353 | if (!children) { |
| 11354 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11355 | return NULL; |
| 11356 | } |
| 11357 | } |
| 11358 | children[n++] = res; |
| 11359 | mark = p->mark; |
| 11360 | } |
| 11361 | p->mark = mark; |
| 11362 | } |
| 11363 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11364 | if (!seq) { |
| 11365 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10"); |
| 11366 | PyMem_Free(children); |
| 11367 | return NULL; |
| 11368 | } |
| 11369 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11370 | PyMem_Free(children); |
| 11371 | _PyPegen_insert_memo(p, start_mark, _loop0_10_type, seq); |
| 11372 | return seq; |
| 11373 | } |
| 11374 | |
| 11375 | // _gather_9: expression _loop0_10 |
| 11376 | static asdl_seq * |
| 11377 | _gather_9_rule(Parser *p) |
| 11378 | { |
| 11379 | if (p->error_indicator) { |
| 11380 | return NULL; |
| 11381 | } |
| 11382 | asdl_seq * res = NULL; |
| 11383 | int mark = p->mark; |
| 11384 | { // expression _loop0_10 |
| 11385 | expr_ty elem; |
| 11386 | asdl_seq * seq; |
| 11387 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11388 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11389 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11390 | (seq = _loop0_10_rule(p)) // _loop0_10 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11391 | ) |
| 11392 | { |
| 11393 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11394 | goto done; |
| 11395 | } |
| 11396 | p->mark = mark; |
| 11397 | } |
| 11398 | res = NULL; |
| 11399 | done: |
| 11400 | return res; |
| 11401 | } |
| 11402 | |
| 11403 | // _loop1_11: statement |
| 11404 | static asdl_seq * |
| 11405 | _loop1_11_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11406 | { |
| 11407 | if (p->error_indicator) { |
| 11408 | return NULL; |
| 11409 | } |
| 11410 | void *res = NULL; |
| 11411 | int mark = p->mark; |
| 11412 | int start_mark = p->mark; |
| 11413 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11414 | if (!children) { |
| 11415 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11416 | return NULL; |
| 11417 | } |
| 11418 | ssize_t children_capacity = 1; |
| 11419 | ssize_t n = 0; |
| 11420 | { // statement |
| 11421 | asdl_seq* statement_var; |
| 11422 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11423 | (statement_var = statement_rule(p)) // statement |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11424 | ) |
| 11425 | { |
| 11426 | res = statement_var; |
| 11427 | if (n == children_capacity) { |
| 11428 | children_capacity *= 2; |
| 11429 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11430 | if (!children) { |
| 11431 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11432 | return NULL; |
| 11433 | } |
| 11434 | } |
| 11435 | children[n++] = res; |
| 11436 | mark = p->mark; |
| 11437 | } |
| 11438 | p->mark = mark; |
| 11439 | } |
| 11440 | if (n == 0) { |
| 11441 | PyMem_Free(children); |
| 11442 | return NULL; |
| 11443 | } |
| 11444 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11445 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11446 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11447 | PyMem_Free(children); |
| 11448 | return NULL; |
| 11449 | } |
| 11450 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11451 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11452 | _PyPegen_insert_memo(p, start_mark, _loop1_11_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11453 | return seq; |
| 11454 | } |
| 11455 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11456 | // _loop0_13: ';' small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11457 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11458 | _loop0_13_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11459 | { |
| 11460 | if (p->error_indicator) { |
| 11461 | return NULL; |
| 11462 | } |
| 11463 | void *res = NULL; |
| 11464 | int mark = p->mark; |
| 11465 | int start_mark = p->mark; |
| 11466 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11467 | if (!children) { |
| 11468 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11469 | return NULL; |
| 11470 | } |
| 11471 | ssize_t children_capacity = 1; |
| 11472 | ssize_t n = 0; |
| 11473 | { // ';' small_stmt |
| 11474 | stmt_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11475 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11476 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11477 | (literal = _PyPegen_expect_token(p, 13)) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11478 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11479 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11480 | ) |
| 11481 | { |
| 11482 | res = elem; |
| 11483 | if (res == NULL && PyErr_Occurred()) { |
| 11484 | p->error_indicator = 1; |
| 11485 | PyMem_Free(children); |
| 11486 | return NULL; |
| 11487 | } |
| 11488 | if (n == children_capacity) { |
| 11489 | children_capacity *= 2; |
| 11490 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11491 | if (!children) { |
| 11492 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11493 | return NULL; |
| 11494 | } |
| 11495 | } |
| 11496 | children[n++] = res; |
| 11497 | mark = p->mark; |
| 11498 | } |
| 11499 | p->mark = mark; |
| 11500 | } |
| 11501 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11502 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11503 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11504 | PyMem_Free(children); |
| 11505 | return NULL; |
| 11506 | } |
| 11507 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11508 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11509 | _PyPegen_insert_memo(p, start_mark, _loop0_13_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11510 | return seq; |
| 11511 | } |
| 11512 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11513 | // _gather_12: small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11514 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11515 | _gather_12_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11516 | { |
| 11517 | if (p->error_indicator) { |
| 11518 | return NULL; |
| 11519 | } |
| 11520 | asdl_seq * res = NULL; |
| 11521 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11522 | { // small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11523 | stmt_ty elem; |
| 11524 | asdl_seq * seq; |
| 11525 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11526 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11527 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11528 | (seq = _loop0_13_rule(p)) // _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11529 | ) |
| 11530 | { |
| 11531 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11532 | goto done; |
| 11533 | } |
| 11534 | p->mark = mark; |
| 11535 | } |
| 11536 | res = NULL; |
| 11537 | done: |
| 11538 | return res; |
| 11539 | } |
| 11540 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11541 | // _tmp_14: 'import' | 'from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11542 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11543 | _tmp_14_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11544 | { |
| 11545 | if (p->error_indicator) { |
| 11546 | return NULL; |
| 11547 | } |
| 11548 | void * res = NULL; |
| 11549 | int mark = p->mark; |
| 11550 | { // 'import' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11551 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11552 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11553 | (keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11554 | ) |
| 11555 | { |
| 11556 | res = keyword; |
| 11557 | goto done; |
| 11558 | } |
| 11559 | p->mark = mark; |
| 11560 | } |
| 11561 | { // 'from' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11562 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11563 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11564 | (keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11565 | ) |
| 11566 | { |
| 11567 | res = keyword; |
| 11568 | goto done; |
| 11569 | } |
| 11570 | p->mark = mark; |
| 11571 | } |
| 11572 | res = NULL; |
| 11573 | done: |
| 11574 | return res; |
| 11575 | } |
| 11576 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11577 | // _tmp_15: 'def' | '@' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11578 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11579 | _tmp_15_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11580 | { |
| 11581 | if (p->error_indicator) { |
| 11582 | return NULL; |
| 11583 | } |
| 11584 | void * res = NULL; |
| 11585 | int mark = p->mark; |
| 11586 | { // 'def' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11587 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11588 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11589 | (keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11590 | ) |
| 11591 | { |
| 11592 | res = keyword; |
| 11593 | goto done; |
| 11594 | } |
| 11595 | p->mark = mark; |
| 11596 | } |
| 11597 | { // '@' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11598 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11599 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11600 | (literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11601 | ) |
| 11602 | { |
| 11603 | res = literal; |
| 11604 | goto done; |
| 11605 | } |
| 11606 | p->mark = mark; |
| 11607 | } |
| 11608 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11609 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11610 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11611 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11612 | ) |
| 11613 | { |
| 11614 | res = async_var; |
| 11615 | goto done; |
| 11616 | } |
| 11617 | p->mark = mark; |
| 11618 | } |
| 11619 | res = NULL; |
| 11620 | done: |
| 11621 | return res; |
| 11622 | } |
| 11623 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11624 | // _tmp_16: 'class' | '@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11625 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11626 | _tmp_16_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11627 | { |
| 11628 | if (p->error_indicator) { |
| 11629 | return NULL; |
| 11630 | } |
| 11631 | void * res = NULL; |
| 11632 | int mark = p->mark; |
| 11633 | { // 'class' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11634 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11635 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11636 | (keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11637 | ) |
| 11638 | { |
| 11639 | res = keyword; |
| 11640 | goto done; |
| 11641 | } |
| 11642 | p->mark = mark; |
| 11643 | } |
| 11644 | { // '@' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11645 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11646 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11647 | (literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11648 | ) |
| 11649 | { |
| 11650 | res = literal; |
| 11651 | goto done; |
| 11652 | } |
| 11653 | p->mark = mark; |
| 11654 | } |
| 11655 | res = NULL; |
| 11656 | done: |
| 11657 | return res; |
| 11658 | } |
| 11659 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11660 | // _tmp_17: 'with' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11661 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11662 | _tmp_17_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11663 | { |
| 11664 | if (p->error_indicator) { |
| 11665 | return NULL; |
| 11666 | } |
| 11667 | void * res = NULL; |
| 11668 | int mark = p->mark; |
| 11669 | { // 'with' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11670 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11671 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11672 | (keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11673 | ) |
| 11674 | { |
| 11675 | res = keyword; |
| 11676 | goto done; |
| 11677 | } |
| 11678 | p->mark = mark; |
| 11679 | } |
| 11680 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11681 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11682 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11683 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11684 | ) |
| 11685 | { |
| 11686 | res = async_var; |
| 11687 | goto done; |
| 11688 | } |
| 11689 | p->mark = mark; |
| 11690 | } |
| 11691 | res = NULL; |
| 11692 | done: |
| 11693 | return res; |
| 11694 | } |
| 11695 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11696 | // _tmp_18: 'for' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11697 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11698 | _tmp_18_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11699 | { |
| 11700 | if (p->error_indicator) { |
| 11701 | return NULL; |
| 11702 | } |
| 11703 | void * res = NULL; |
| 11704 | int mark = p->mark; |
| 11705 | { // 'for' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11706 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11707 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11708 | (keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11709 | ) |
| 11710 | { |
| 11711 | res = keyword; |
| 11712 | goto done; |
| 11713 | } |
| 11714 | p->mark = mark; |
| 11715 | } |
| 11716 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11717 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11718 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11719 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11720 | ) |
| 11721 | { |
| 11722 | res = async_var; |
| 11723 | goto done; |
| 11724 | } |
| 11725 | p->mark = mark; |
| 11726 | } |
| 11727 | res = NULL; |
| 11728 | done: |
| 11729 | return res; |
| 11730 | } |
| 11731 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11732 | // _tmp_19: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11733 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11734 | _tmp_19_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11735 | { |
| 11736 | if (p->error_indicator) { |
| 11737 | return NULL; |
| 11738 | } |
| 11739 | void * res = NULL; |
| 11740 | int mark = p->mark; |
| 11741 | { // '=' annotated_rhs |
| 11742 | expr_ty d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11743 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11744 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11745 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11746 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11747 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11748 | ) |
| 11749 | { |
| 11750 | res = d; |
| 11751 | if (res == NULL && PyErr_Occurred()) { |
| 11752 | p->error_indicator = 1; |
| 11753 | return NULL; |
| 11754 | } |
| 11755 | goto done; |
| 11756 | } |
| 11757 | p->mark = mark; |
| 11758 | } |
| 11759 | res = NULL; |
| 11760 | done: |
| 11761 | return res; |
| 11762 | } |
| 11763 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11764 | // _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11765 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11766 | _tmp_20_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11767 | { |
| 11768 | if (p->error_indicator) { |
| 11769 | return NULL; |
| 11770 | } |
| 11771 | void * res = NULL; |
| 11772 | int mark = p->mark; |
| 11773 | { // '(' inside_paren_ann_assign_target ')' |
| 11774 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11775 | Token * literal; |
| 11776 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11777 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11778 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11779 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11780 | (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] | 11781 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11782 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11783 | ) |
| 11784 | { |
| 11785 | res = b; |
| 11786 | if (res == NULL && PyErr_Occurred()) { |
| 11787 | p->error_indicator = 1; |
| 11788 | return NULL; |
| 11789 | } |
| 11790 | goto done; |
| 11791 | } |
| 11792 | p->mark = mark; |
| 11793 | } |
| 11794 | { // ann_assign_subscript_attribute_target |
| 11795 | expr_ty ann_assign_subscript_attribute_target_var; |
| 11796 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11797 | (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] | 11798 | ) |
| 11799 | { |
| 11800 | res = ann_assign_subscript_attribute_target_var; |
| 11801 | goto done; |
| 11802 | } |
| 11803 | p->mark = mark; |
| 11804 | } |
| 11805 | res = NULL; |
| 11806 | done: |
| 11807 | return res; |
| 11808 | } |
| 11809 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11810 | // _tmp_21: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11811 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11812 | _tmp_21_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11813 | { |
| 11814 | if (p->error_indicator) { |
| 11815 | return NULL; |
| 11816 | } |
| 11817 | void * res = NULL; |
| 11818 | int mark = p->mark; |
| 11819 | { // '=' annotated_rhs |
| 11820 | expr_ty d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11821 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11822 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11823 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11824 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11825 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11826 | ) |
| 11827 | { |
| 11828 | res = d; |
| 11829 | if (res == NULL && PyErr_Occurred()) { |
| 11830 | p->error_indicator = 1; |
| 11831 | return NULL; |
| 11832 | } |
| 11833 | goto done; |
| 11834 | } |
| 11835 | p->mark = mark; |
| 11836 | } |
| 11837 | res = NULL; |
| 11838 | done: |
| 11839 | return res; |
| 11840 | } |
| 11841 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11842 | // _loop1_22: (star_targets '=') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11843 | static asdl_seq * |
| 11844 | _loop1_22_rule(Parser *p) |
| 11845 | { |
| 11846 | if (p->error_indicator) { |
| 11847 | return NULL; |
| 11848 | } |
| 11849 | void *res = NULL; |
| 11850 | int mark = p->mark; |
| 11851 | int start_mark = p->mark; |
| 11852 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11853 | if (!children) { |
| 11854 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11855 | return NULL; |
| 11856 | } |
| 11857 | ssize_t children_capacity = 1; |
| 11858 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11859 | { // (star_targets '=') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11860 | void *_tmp_134_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11861 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11862 | (_tmp_134_var = _tmp_134_rule(p)) // star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11863 | ) |
| 11864 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11865 | res = _tmp_134_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11866 | if (n == children_capacity) { |
| 11867 | children_capacity *= 2; |
| 11868 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11869 | if (!children) { |
| 11870 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11871 | return NULL; |
| 11872 | } |
| 11873 | } |
| 11874 | children[n++] = res; |
| 11875 | mark = p->mark; |
| 11876 | } |
| 11877 | p->mark = mark; |
| 11878 | } |
| 11879 | if (n == 0) { |
| 11880 | PyMem_Free(children); |
| 11881 | return NULL; |
| 11882 | } |
| 11883 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11884 | if (!seq) { |
| 11885 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22"); |
| 11886 | PyMem_Free(children); |
| 11887 | return NULL; |
| 11888 | } |
| 11889 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11890 | PyMem_Free(children); |
| 11891 | _PyPegen_insert_memo(p, start_mark, _loop1_22_type, seq); |
| 11892 | return seq; |
| 11893 | } |
| 11894 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11895 | // _tmp_23: yield_expr | star_expressions |
| 11896 | static void * |
| 11897 | _tmp_23_rule(Parser *p) |
| 11898 | { |
| 11899 | if (p->error_indicator) { |
| 11900 | return NULL; |
| 11901 | } |
| 11902 | void * res = NULL; |
| 11903 | int mark = p->mark; |
| 11904 | { // yield_expr |
| 11905 | expr_ty yield_expr_var; |
| 11906 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11907 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11908 | ) |
| 11909 | { |
| 11910 | res = yield_expr_var; |
| 11911 | goto done; |
| 11912 | } |
| 11913 | p->mark = mark; |
| 11914 | } |
| 11915 | { // star_expressions |
| 11916 | expr_ty star_expressions_var; |
| 11917 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11918 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11919 | ) |
| 11920 | { |
| 11921 | res = star_expressions_var; |
| 11922 | goto done; |
| 11923 | } |
| 11924 | p->mark = mark; |
| 11925 | } |
| 11926 | res = NULL; |
| 11927 | done: |
| 11928 | return res; |
| 11929 | } |
| 11930 | |
| 11931 | // _tmp_24: yield_expr | star_expressions |
| 11932 | static void * |
| 11933 | _tmp_24_rule(Parser *p) |
| 11934 | { |
| 11935 | if (p->error_indicator) { |
| 11936 | return NULL; |
| 11937 | } |
| 11938 | void * res = NULL; |
| 11939 | int mark = p->mark; |
| 11940 | { // yield_expr |
| 11941 | expr_ty yield_expr_var; |
| 11942 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11943 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11944 | ) |
| 11945 | { |
| 11946 | res = yield_expr_var; |
| 11947 | goto done; |
| 11948 | } |
| 11949 | p->mark = mark; |
| 11950 | } |
| 11951 | { // star_expressions |
| 11952 | expr_ty star_expressions_var; |
| 11953 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11954 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11955 | ) |
| 11956 | { |
| 11957 | res = star_expressions_var; |
| 11958 | goto done; |
| 11959 | } |
| 11960 | p->mark = mark; |
| 11961 | } |
| 11962 | res = NULL; |
| 11963 | done: |
| 11964 | return res; |
| 11965 | } |
| 11966 | |
| 11967 | // _loop0_26: ',' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11968 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11969 | _loop0_26_rule(Parser *p) |
| 11970 | { |
| 11971 | if (p->error_indicator) { |
| 11972 | return NULL; |
| 11973 | } |
| 11974 | void *res = NULL; |
| 11975 | int mark = p->mark; |
| 11976 | int start_mark = p->mark; |
| 11977 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11978 | if (!children) { |
| 11979 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11980 | return NULL; |
| 11981 | } |
| 11982 | ssize_t children_capacity = 1; |
| 11983 | ssize_t n = 0; |
| 11984 | { // ',' NAME |
| 11985 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11986 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11987 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11988 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11989 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11990 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11991 | ) |
| 11992 | { |
| 11993 | res = elem; |
| 11994 | if (res == NULL && PyErr_Occurred()) { |
| 11995 | p->error_indicator = 1; |
| 11996 | PyMem_Free(children); |
| 11997 | return NULL; |
| 11998 | } |
| 11999 | if (n == children_capacity) { |
| 12000 | children_capacity *= 2; |
| 12001 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12002 | if (!children) { |
| 12003 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12004 | return NULL; |
| 12005 | } |
| 12006 | } |
| 12007 | children[n++] = res; |
| 12008 | mark = p->mark; |
| 12009 | } |
| 12010 | p->mark = mark; |
| 12011 | } |
| 12012 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12013 | if (!seq) { |
| 12014 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26"); |
| 12015 | PyMem_Free(children); |
| 12016 | return NULL; |
| 12017 | } |
| 12018 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12019 | PyMem_Free(children); |
| 12020 | _PyPegen_insert_memo(p, start_mark, _loop0_26_type, seq); |
| 12021 | return seq; |
| 12022 | } |
| 12023 | |
| 12024 | // _gather_25: NAME _loop0_26 |
| 12025 | static asdl_seq * |
| 12026 | _gather_25_rule(Parser *p) |
| 12027 | { |
| 12028 | if (p->error_indicator) { |
| 12029 | return NULL; |
| 12030 | } |
| 12031 | asdl_seq * res = NULL; |
| 12032 | int mark = p->mark; |
| 12033 | { // NAME _loop0_26 |
| 12034 | expr_ty elem; |
| 12035 | asdl_seq * seq; |
| 12036 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12037 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12038 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12039 | (seq = _loop0_26_rule(p)) // _loop0_26 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12040 | ) |
| 12041 | { |
| 12042 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12043 | goto done; |
| 12044 | } |
| 12045 | p->mark = mark; |
| 12046 | } |
| 12047 | res = NULL; |
| 12048 | done: |
| 12049 | return res; |
| 12050 | } |
| 12051 | |
| 12052 | // _loop0_28: ',' NAME |
| 12053 | static asdl_seq * |
| 12054 | _loop0_28_rule(Parser *p) |
| 12055 | { |
| 12056 | if (p->error_indicator) { |
| 12057 | return NULL; |
| 12058 | } |
| 12059 | void *res = NULL; |
| 12060 | int mark = p->mark; |
| 12061 | int start_mark = p->mark; |
| 12062 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12063 | if (!children) { |
| 12064 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12065 | return NULL; |
| 12066 | } |
| 12067 | ssize_t children_capacity = 1; |
| 12068 | ssize_t n = 0; |
| 12069 | { // ',' NAME |
| 12070 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12071 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12072 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12073 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12074 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12075 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12076 | ) |
| 12077 | { |
| 12078 | res = elem; |
| 12079 | if (res == NULL && PyErr_Occurred()) { |
| 12080 | p->error_indicator = 1; |
| 12081 | PyMem_Free(children); |
| 12082 | return NULL; |
| 12083 | } |
| 12084 | if (n == children_capacity) { |
| 12085 | children_capacity *= 2; |
| 12086 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12087 | if (!children) { |
| 12088 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12089 | return NULL; |
| 12090 | } |
| 12091 | } |
| 12092 | children[n++] = res; |
| 12093 | mark = p->mark; |
| 12094 | } |
| 12095 | p->mark = mark; |
| 12096 | } |
| 12097 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12098 | if (!seq) { |
| 12099 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28"); |
| 12100 | PyMem_Free(children); |
| 12101 | return NULL; |
| 12102 | } |
| 12103 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12104 | PyMem_Free(children); |
| 12105 | _PyPegen_insert_memo(p, start_mark, _loop0_28_type, seq); |
| 12106 | return seq; |
| 12107 | } |
| 12108 | |
| 12109 | // _gather_27: NAME _loop0_28 |
| 12110 | static asdl_seq * |
| 12111 | _gather_27_rule(Parser *p) |
| 12112 | { |
| 12113 | if (p->error_indicator) { |
| 12114 | return NULL; |
| 12115 | } |
| 12116 | asdl_seq * res = NULL; |
| 12117 | int mark = p->mark; |
| 12118 | { // NAME _loop0_28 |
| 12119 | expr_ty elem; |
| 12120 | asdl_seq * seq; |
| 12121 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12122 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12123 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12124 | (seq = _loop0_28_rule(p)) // _loop0_28 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12125 | ) |
| 12126 | { |
| 12127 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12128 | goto done; |
| 12129 | } |
| 12130 | p->mark = mark; |
| 12131 | } |
| 12132 | res = NULL; |
| 12133 | done: |
| 12134 | return res; |
| 12135 | } |
| 12136 | |
| 12137 | // _tmp_29: ',' expression |
| 12138 | static void * |
| 12139 | _tmp_29_rule(Parser *p) |
| 12140 | { |
| 12141 | if (p->error_indicator) { |
| 12142 | return NULL; |
| 12143 | } |
| 12144 | void * res = NULL; |
| 12145 | int mark = p->mark; |
| 12146 | { // ',' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12147 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12148 | expr_ty z; |
| 12149 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12150 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12151 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12152 | (z = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12153 | ) |
| 12154 | { |
| 12155 | res = z; |
| 12156 | if (res == NULL && PyErr_Occurred()) { |
| 12157 | p->error_indicator = 1; |
| 12158 | return NULL; |
| 12159 | } |
| 12160 | goto done; |
| 12161 | } |
| 12162 | p->mark = mark; |
| 12163 | } |
| 12164 | res = NULL; |
| 12165 | done: |
| 12166 | return res; |
| 12167 | } |
| 12168 | |
| 12169 | // _loop0_30: ('.' | '...') |
| 12170 | static asdl_seq * |
| 12171 | _loop0_30_rule(Parser *p) |
| 12172 | { |
| 12173 | if (p->error_indicator) { |
| 12174 | return NULL; |
| 12175 | } |
| 12176 | void *res = NULL; |
| 12177 | int mark = p->mark; |
| 12178 | int start_mark = p->mark; |
| 12179 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12180 | if (!children) { |
| 12181 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12182 | return NULL; |
| 12183 | } |
| 12184 | ssize_t children_capacity = 1; |
| 12185 | ssize_t n = 0; |
| 12186 | { // ('.' | '...') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12187 | void *_tmp_135_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12188 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12189 | (_tmp_135_var = _tmp_135_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12190 | ) |
| 12191 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12192 | res = _tmp_135_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12193 | if (n == children_capacity) { |
| 12194 | children_capacity *= 2; |
| 12195 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12196 | if (!children) { |
| 12197 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12198 | return NULL; |
| 12199 | } |
| 12200 | } |
| 12201 | children[n++] = res; |
| 12202 | mark = p->mark; |
| 12203 | } |
| 12204 | p->mark = mark; |
| 12205 | } |
| 12206 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12207 | if (!seq) { |
| 12208 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30"); |
| 12209 | PyMem_Free(children); |
| 12210 | return NULL; |
| 12211 | } |
| 12212 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12213 | PyMem_Free(children); |
| 12214 | _PyPegen_insert_memo(p, start_mark, _loop0_30_type, seq); |
| 12215 | return seq; |
| 12216 | } |
| 12217 | |
| 12218 | // _loop1_31: ('.' | '...') |
| 12219 | static asdl_seq * |
| 12220 | _loop1_31_rule(Parser *p) |
| 12221 | { |
| 12222 | if (p->error_indicator) { |
| 12223 | return NULL; |
| 12224 | } |
| 12225 | void *res = NULL; |
| 12226 | int mark = p->mark; |
| 12227 | int start_mark = p->mark; |
| 12228 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12229 | if (!children) { |
| 12230 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12231 | return NULL; |
| 12232 | } |
| 12233 | ssize_t children_capacity = 1; |
| 12234 | ssize_t n = 0; |
| 12235 | { // ('.' | '...') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12236 | void *_tmp_136_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12237 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12238 | (_tmp_136_var = _tmp_136_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12239 | ) |
| 12240 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12241 | res = _tmp_136_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12242 | if (n == children_capacity) { |
| 12243 | children_capacity *= 2; |
| 12244 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12245 | if (!children) { |
| 12246 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12247 | return NULL; |
| 12248 | } |
| 12249 | } |
| 12250 | children[n++] = res; |
| 12251 | mark = p->mark; |
| 12252 | } |
| 12253 | p->mark = mark; |
| 12254 | } |
| 12255 | if (n == 0) { |
| 12256 | PyMem_Free(children); |
| 12257 | return NULL; |
| 12258 | } |
| 12259 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12260 | if (!seq) { |
| 12261 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31"); |
| 12262 | PyMem_Free(children); |
| 12263 | return NULL; |
| 12264 | } |
| 12265 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12266 | PyMem_Free(children); |
| 12267 | _PyPegen_insert_memo(p, start_mark, _loop1_31_type, seq); |
| 12268 | return seq; |
| 12269 | } |
| 12270 | |
| 12271 | // _loop0_33: ',' import_from_as_name |
| 12272 | static asdl_seq * |
| 12273 | _loop0_33_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12274 | { |
| 12275 | if (p->error_indicator) { |
| 12276 | return NULL; |
| 12277 | } |
| 12278 | void *res = NULL; |
| 12279 | int mark = p->mark; |
| 12280 | int start_mark = p->mark; |
| 12281 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12282 | if (!children) { |
| 12283 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12284 | return NULL; |
| 12285 | } |
| 12286 | ssize_t children_capacity = 1; |
| 12287 | ssize_t n = 0; |
| 12288 | { // ',' import_from_as_name |
| 12289 | alias_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12290 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12291 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12292 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12293 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12294 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12295 | ) |
| 12296 | { |
| 12297 | res = elem; |
| 12298 | if (res == NULL && PyErr_Occurred()) { |
| 12299 | p->error_indicator = 1; |
| 12300 | PyMem_Free(children); |
| 12301 | return NULL; |
| 12302 | } |
| 12303 | if (n == children_capacity) { |
| 12304 | children_capacity *= 2; |
| 12305 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12306 | if (!children) { |
| 12307 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12308 | return NULL; |
| 12309 | } |
| 12310 | } |
| 12311 | children[n++] = res; |
| 12312 | mark = p->mark; |
| 12313 | } |
| 12314 | p->mark = mark; |
| 12315 | } |
| 12316 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12317 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12318 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12319 | PyMem_Free(children); |
| 12320 | return NULL; |
| 12321 | } |
| 12322 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12323 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12324 | _PyPegen_insert_memo(p, start_mark, _loop0_33_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12325 | return seq; |
| 12326 | } |
| 12327 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12328 | // _gather_32: import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12329 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12330 | _gather_32_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12331 | { |
| 12332 | if (p->error_indicator) { |
| 12333 | return NULL; |
| 12334 | } |
| 12335 | asdl_seq * res = NULL; |
| 12336 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12337 | { // import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12338 | alias_ty elem; |
| 12339 | asdl_seq * seq; |
| 12340 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12341 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12342 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12343 | (seq = _loop0_33_rule(p)) // _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12344 | ) |
| 12345 | { |
| 12346 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12347 | goto done; |
| 12348 | } |
| 12349 | p->mark = mark; |
| 12350 | } |
| 12351 | res = NULL; |
| 12352 | done: |
| 12353 | return res; |
| 12354 | } |
| 12355 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12356 | // _tmp_34: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12357 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12358 | _tmp_34_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12359 | { |
| 12360 | if (p->error_indicator) { |
| 12361 | return NULL; |
| 12362 | } |
| 12363 | void * res = NULL; |
| 12364 | int mark = p->mark; |
| 12365 | { // 'as' NAME |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12366 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12367 | expr_ty z; |
| 12368 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12369 | (keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12370 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12371 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12372 | ) |
| 12373 | { |
| 12374 | res = z; |
| 12375 | if (res == NULL && PyErr_Occurred()) { |
| 12376 | p->error_indicator = 1; |
| 12377 | return NULL; |
| 12378 | } |
| 12379 | goto done; |
| 12380 | } |
| 12381 | p->mark = mark; |
| 12382 | } |
| 12383 | res = NULL; |
| 12384 | done: |
| 12385 | return res; |
| 12386 | } |
| 12387 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12388 | // _loop0_36: ',' dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12389 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12390 | _loop0_36_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12391 | { |
| 12392 | if (p->error_indicator) { |
| 12393 | return NULL; |
| 12394 | } |
| 12395 | void *res = NULL; |
| 12396 | int mark = p->mark; |
| 12397 | int start_mark = p->mark; |
| 12398 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12399 | if (!children) { |
| 12400 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12401 | return NULL; |
| 12402 | } |
| 12403 | ssize_t children_capacity = 1; |
| 12404 | ssize_t n = 0; |
| 12405 | { // ',' dotted_as_name |
| 12406 | alias_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12407 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12408 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12409 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12410 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12411 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12412 | ) |
| 12413 | { |
| 12414 | res = elem; |
| 12415 | if (res == NULL && PyErr_Occurred()) { |
| 12416 | p->error_indicator = 1; |
| 12417 | PyMem_Free(children); |
| 12418 | return NULL; |
| 12419 | } |
| 12420 | if (n == children_capacity) { |
| 12421 | children_capacity *= 2; |
| 12422 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12423 | if (!children) { |
| 12424 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12425 | return NULL; |
| 12426 | } |
| 12427 | } |
| 12428 | children[n++] = res; |
| 12429 | mark = p->mark; |
| 12430 | } |
| 12431 | p->mark = mark; |
| 12432 | } |
| 12433 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12434 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12435 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12436 | PyMem_Free(children); |
| 12437 | return NULL; |
| 12438 | } |
| 12439 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12440 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12441 | _PyPegen_insert_memo(p, start_mark, _loop0_36_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12442 | return seq; |
| 12443 | } |
| 12444 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12445 | // _gather_35: dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12446 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12447 | _gather_35_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12448 | { |
| 12449 | if (p->error_indicator) { |
| 12450 | return NULL; |
| 12451 | } |
| 12452 | asdl_seq * res = NULL; |
| 12453 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12454 | { // dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12455 | alias_ty elem; |
| 12456 | asdl_seq * seq; |
| 12457 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12458 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12459 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12460 | (seq = _loop0_36_rule(p)) // _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12461 | ) |
| 12462 | { |
| 12463 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12464 | goto done; |
| 12465 | } |
| 12466 | p->mark = mark; |
| 12467 | } |
| 12468 | res = NULL; |
| 12469 | done: |
| 12470 | return res; |
| 12471 | } |
| 12472 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12473 | // _tmp_37: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12474 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12475 | _tmp_37_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12476 | { |
| 12477 | if (p->error_indicator) { |
| 12478 | return NULL; |
| 12479 | } |
| 12480 | void * res = NULL; |
| 12481 | int mark = p->mark; |
| 12482 | { // 'as' NAME |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12483 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12484 | expr_ty z; |
| 12485 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12486 | (keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12487 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12488 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12489 | ) |
| 12490 | { |
| 12491 | res = z; |
| 12492 | if (res == NULL && PyErr_Occurred()) { |
| 12493 | p->error_indicator = 1; |
| 12494 | return NULL; |
| 12495 | } |
| 12496 | goto done; |
| 12497 | } |
| 12498 | p->mark = mark; |
| 12499 | } |
| 12500 | res = NULL; |
| 12501 | done: |
| 12502 | return res; |
| 12503 | } |
| 12504 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12505 | // _loop0_39: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12506 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12507 | _loop0_39_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12508 | { |
| 12509 | if (p->error_indicator) { |
| 12510 | return NULL; |
| 12511 | } |
| 12512 | void *res = NULL; |
| 12513 | int mark = p->mark; |
| 12514 | int start_mark = p->mark; |
| 12515 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12516 | if (!children) { |
| 12517 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12518 | return NULL; |
| 12519 | } |
| 12520 | ssize_t children_capacity = 1; |
| 12521 | ssize_t n = 0; |
| 12522 | { // ',' with_item |
| 12523 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12524 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12525 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12526 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12527 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12528 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12529 | ) |
| 12530 | { |
| 12531 | res = elem; |
| 12532 | if (res == NULL && PyErr_Occurred()) { |
| 12533 | p->error_indicator = 1; |
| 12534 | PyMem_Free(children); |
| 12535 | return NULL; |
| 12536 | } |
| 12537 | if (n == children_capacity) { |
| 12538 | children_capacity *= 2; |
| 12539 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12540 | if (!children) { |
| 12541 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12542 | return NULL; |
| 12543 | } |
| 12544 | } |
| 12545 | children[n++] = res; |
| 12546 | mark = p->mark; |
| 12547 | } |
| 12548 | p->mark = mark; |
| 12549 | } |
| 12550 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12551 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12552 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12553 | PyMem_Free(children); |
| 12554 | return NULL; |
| 12555 | } |
| 12556 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12557 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12558 | _PyPegen_insert_memo(p, start_mark, _loop0_39_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12559 | return seq; |
| 12560 | } |
| 12561 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12562 | // _gather_38: with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12563 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12564 | _gather_38_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12565 | { |
| 12566 | if (p->error_indicator) { |
| 12567 | return NULL; |
| 12568 | } |
| 12569 | asdl_seq * res = NULL; |
| 12570 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12571 | { // with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12572 | withitem_ty elem; |
| 12573 | asdl_seq * seq; |
| 12574 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12575 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12576 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12577 | (seq = _loop0_39_rule(p)) // _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12578 | ) |
| 12579 | { |
| 12580 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12581 | goto done; |
| 12582 | } |
| 12583 | p->mark = mark; |
| 12584 | } |
| 12585 | res = NULL; |
| 12586 | done: |
| 12587 | return res; |
| 12588 | } |
| 12589 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12590 | // _loop0_41: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12591 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12592 | _loop0_41_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12593 | { |
| 12594 | if (p->error_indicator) { |
| 12595 | return NULL; |
| 12596 | } |
| 12597 | void *res = NULL; |
| 12598 | int mark = p->mark; |
| 12599 | int start_mark = p->mark; |
| 12600 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12601 | if (!children) { |
| 12602 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12603 | return NULL; |
| 12604 | } |
| 12605 | ssize_t children_capacity = 1; |
| 12606 | ssize_t n = 0; |
| 12607 | { // ',' with_item |
| 12608 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12609 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12610 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12611 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12612 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12613 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12614 | ) |
| 12615 | { |
| 12616 | res = elem; |
| 12617 | if (res == NULL && PyErr_Occurred()) { |
| 12618 | p->error_indicator = 1; |
| 12619 | PyMem_Free(children); |
| 12620 | return NULL; |
| 12621 | } |
| 12622 | if (n == children_capacity) { |
| 12623 | children_capacity *= 2; |
| 12624 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12625 | if (!children) { |
| 12626 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12627 | return NULL; |
| 12628 | } |
| 12629 | } |
| 12630 | children[n++] = res; |
| 12631 | mark = p->mark; |
| 12632 | } |
| 12633 | p->mark = mark; |
| 12634 | } |
| 12635 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12636 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12637 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12638 | PyMem_Free(children); |
| 12639 | return NULL; |
| 12640 | } |
| 12641 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12642 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12643 | _PyPegen_insert_memo(p, start_mark, _loop0_41_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12644 | return seq; |
| 12645 | } |
| 12646 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12647 | // _gather_40: with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12648 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12649 | _gather_40_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12650 | { |
| 12651 | if (p->error_indicator) { |
| 12652 | return NULL; |
| 12653 | } |
| 12654 | asdl_seq * res = NULL; |
| 12655 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12656 | { // with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12657 | withitem_ty elem; |
| 12658 | asdl_seq * seq; |
| 12659 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12660 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12661 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12662 | (seq = _loop0_41_rule(p)) // _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12663 | ) |
| 12664 | { |
| 12665 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12666 | goto done; |
| 12667 | } |
| 12668 | p->mark = mark; |
| 12669 | } |
| 12670 | res = NULL; |
| 12671 | done: |
| 12672 | return res; |
| 12673 | } |
| 12674 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12675 | // _loop0_43: ',' with_item |
| 12676 | static asdl_seq * |
| 12677 | _loop0_43_rule(Parser *p) |
| 12678 | { |
| 12679 | if (p->error_indicator) { |
| 12680 | return NULL; |
| 12681 | } |
| 12682 | void *res = NULL; |
| 12683 | int mark = p->mark; |
| 12684 | int start_mark = p->mark; |
| 12685 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12686 | if (!children) { |
| 12687 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12688 | return NULL; |
| 12689 | } |
| 12690 | ssize_t children_capacity = 1; |
| 12691 | ssize_t n = 0; |
| 12692 | { // ',' with_item |
| 12693 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12694 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12695 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12696 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12697 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12698 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12699 | ) |
| 12700 | { |
| 12701 | res = elem; |
| 12702 | if (res == NULL && PyErr_Occurred()) { |
| 12703 | p->error_indicator = 1; |
| 12704 | PyMem_Free(children); |
| 12705 | return NULL; |
| 12706 | } |
| 12707 | if (n == children_capacity) { |
| 12708 | children_capacity *= 2; |
| 12709 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12710 | if (!children) { |
| 12711 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12712 | return NULL; |
| 12713 | } |
| 12714 | } |
| 12715 | children[n++] = res; |
| 12716 | mark = p->mark; |
| 12717 | } |
| 12718 | p->mark = mark; |
| 12719 | } |
| 12720 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12721 | if (!seq) { |
| 12722 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43"); |
| 12723 | PyMem_Free(children); |
| 12724 | return NULL; |
| 12725 | } |
| 12726 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12727 | PyMem_Free(children); |
| 12728 | _PyPegen_insert_memo(p, start_mark, _loop0_43_type, seq); |
| 12729 | return seq; |
| 12730 | } |
| 12731 | |
| 12732 | // _gather_42: with_item _loop0_43 |
| 12733 | static asdl_seq * |
| 12734 | _gather_42_rule(Parser *p) |
| 12735 | { |
| 12736 | if (p->error_indicator) { |
| 12737 | return NULL; |
| 12738 | } |
| 12739 | asdl_seq * res = NULL; |
| 12740 | int mark = p->mark; |
| 12741 | { // with_item _loop0_43 |
| 12742 | withitem_ty elem; |
| 12743 | asdl_seq * seq; |
| 12744 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12745 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12746 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12747 | (seq = _loop0_43_rule(p)) // _loop0_43 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12748 | ) |
| 12749 | { |
| 12750 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12751 | goto done; |
| 12752 | } |
| 12753 | p->mark = mark; |
| 12754 | } |
| 12755 | res = NULL; |
| 12756 | done: |
| 12757 | return res; |
| 12758 | } |
| 12759 | |
| 12760 | // _loop0_45: ',' with_item |
| 12761 | static asdl_seq * |
| 12762 | _loop0_45_rule(Parser *p) |
| 12763 | { |
| 12764 | if (p->error_indicator) { |
| 12765 | return NULL; |
| 12766 | } |
| 12767 | void *res = NULL; |
| 12768 | int mark = p->mark; |
| 12769 | int start_mark = p->mark; |
| 12770 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12771 | if (!children) { |
| 12772 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12773 | return NULL; |
| 12774 | } |
| 12775 | ssize_t children_capacity = 1; |
| 12776 | ssize_t n = 0; |
| 12777 | { // ',' with_item |
| 12778 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12779 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12780 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12781 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12782 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12783 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12784 | ) |
| 12785 | { |
| 12786 | res = elem; |
| 12787 | if (res == NULL && PyErr_Occurred()) { |
| 12788 | p->error_indicator = 1; |
| 12789 | PyMem_Free(children); |
| 12790 | return NULL; |
| 12791 | } |
| 12792 | if (n == children_capacity) { |
| 12793 | children_capacity *= 2; |
| 12794 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12795 | if (!children) { |
| 12796 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12797 | return NULL; |
| 12798 | } |
| 12799 | } |
| 12800 | children[n++] = res; |
| 12801 | mark = p->mark; |
| 12802 | } |
| 12803 | p->mark = mark; |
| 12804 | } |
| 12805 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12806 | if (!seq) { |
| 12807 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45"); |
| 12808 | PyMem_Free(children); |
| 12809 | return NULL; |
| 12810 | } |
| 12811 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12812 | PyMem_Free(children); |
| 12813 | _PyPegen_insert_memo(p, start_mark, _loop0_45_type, seq); |
| 12814 | return seq; |
| 12815 | } |
| 12816 | |
| 12817 | // _gather_44: with_item _loop0_45 |
| 12818 | static asdl_seq * |
| 12819 | _gather_44_rule(Parser *p) |
| 12820 | { |
| 12821 | if (p->error_indicator) { |
| 12822 | return NULL; |
| 12823 | } |
| 12824 | asdl_seq * res = NULL; |
| 12825 | int mark = p->mark; |
| 12826 | { // with_item _loop0_45 |
| 12827 | withitem_ty elem; |
| 12828 | asdl_seq * seq; |
| 12829 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12830 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12831 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12832 | (seq = _loop0_45_rule(p)) // _loop0_45 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12833 | ) |
| 12834 | { |
| 12835 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12836 | goto done; |
| 12837 | } |
| 12838 | p->mark = mark; |
| 12839 | } |
| 12840 | res = NULL; |
| 12841 | done: |
| 12842 | return res; |
| 12843 | } |
| 12844 | |
| 12845 | // _tmp_46: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12846 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12847 | _tmp_46_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12848 | { |
| 12849 | if (p->error_indicator) { |
| 12850 | return NULL; |
| 12851 | } |
| 12852 | void * res = NULL; |
| 12853 | int mark = p->mark; |
| 12854 | { // 'as' target |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12855 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12856 | expr_ty t; |
| 12857 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12858 | (keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12859 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12860 | (t = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12861 | ) |
| 12862 | { |
| 12863 | res = t; |
| 12864 | if (res == NULL && PyErr_Occurred()) { |
| 12865 | p->error_indicator = 1; |
| 12866 | return NULL; |
| 12867 | } |
| 12868 | goto done; |
| 12869 | } |
| 12870 | p->mark = mark; |
| 12871 | } |
| 12872 | res = NULL; |
| 12873 | done: |
| 12874 | return res; |
| 12875 | } |
| 12876 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12877 | // _loop1_47: except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12878 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12879 | _loop1_47_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12880 | { |
| 12881 | if (p->error_indicator) { |
| 12882 | return NULL; |
| 12883 | } |
| 12884 | void *res = NULL; |
| 12885 | int mark = p->mark; |
| 12886 | int start_mark = p->mark; |
| 12887 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12888 | if (!children) { |
| 12889 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12890 | return NULL; |
| 12891 | } |
| 12892 | ssize_t children_capacity = 1; |
| 12893 | ssize_t n = 0; |
| 12894 | { // except_block |
| 12895 | excepthandler_ty except_block_var; |
| 12896 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12897 | (except_block_var = except_block_rule(p)) // except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12898 | ) |
| 12899 | { |
| 12900 | res = except_block_var; |
| 12901 | if (n == children_capacity) { |
| 12902 | children_capacity *= 2; |
| 12903 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12904 | if (!children) { |
| 12905 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12906 | return NULL; |
| 12907 | } |
| 12908 | } |
| 12909 | children[n++] = res; |
| 12910 | mark = p->mark; |
| 12911 | } |
| 12912 | p->mark = mark; |
| 12913 | } |
| 12914 | if (n == 0) { |
| 12915 | PyMem_Free(children); |
| 12916 | return NULL; |
| 12917 | } |
| 12918 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12919 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12920 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12921 | PyMem_Free(children); |
| 12922 | return NULL; |
| 12923 | } |
| 12924 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12925 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12926 | _PyPegen_insert_memo(p, start_mark, _loop1_47_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12927 | return seq; |
| 12928 | } |
| 12929 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12930 | // _tmp_48: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12931 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12932 | _tmp_48_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12933 | { |
| 12934 | if (p->error_indicator) { |
| 12935 | return NULL; |
| 12936 | } |
| 12937 | void * res = NULL; |
| 12938 | int mark = p->mark; |
| 12939 | { // 'as' target |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12940 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12941 | expr_ty z; |
| 12942 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12943 | (keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12944 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12945 | (z = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12946 | ) |
| 12947 | { |
| 12948 | res = z; |
| 12949 | if (res == NULL && PyErr_Occurred()) { |
| 12950 | p->error_indicator = 1; |
| 12951 | return NULL; |
| 12952 | } |
| 12953 | goto done; |
| 12954 | } |
| 12955 | p->mark = mark; |
| 12956 | } |
| 12957 | res = NULL; |
| 12958 | done: |
| 12959 | return res; |
| 12960 | } |
| 12961 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12962 | // _tmp_49: 'from' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12963 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12964 | _tmp_49_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12965 | { |
| 12966 | if (p->error_indicator) { |
| 12967 | return NULL; |
| 12968 | } |
| 12969 | void * res = NULL; |
| 12970 | int mark = p->mark; |
| 12971 | { // 'from' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12972 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12973 | expr_ty z; |
| 12974 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12975 | (keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12976 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12977 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12978 | ) |
| 12979 | { |
| 12980 | res = z; |
| 12981 | if (res == NULL && PyErr_Occurred()) { |
| 12982 | p->error_indicator = 1; |
| 12983 | return NULL; |
| 12984 | } |
| 12985 | goto done; |
| 12986 | } |
| 12987 | p->mark = mark; |
| 12988 | } |
| 12989 | res = NULL; |
| 12990 | done: |
| 12991 | return res; |
| 12992 | } |
| 12993 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12994 | // _tmp_50: '->' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12995 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12996 | _tmp_50_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12997 | { |
| 12998 | if (p->error_indicator) { |
| 12999 | return NULL; |
| 13000 | } |
| 13001 | void * res = NULL; |
| 13002 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13003 | { // '->' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13004 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13005 | expr_ty z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13006 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13007 | (literal = _PyPegen_expect_token(p, 51)) // token='->' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13008 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13009 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13010 | ) |
| 13011 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13012 | res = z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13013 | if (res == NULL && PyErr_Occurred()) { |
| 13014 | p->error_indicator = 1; |
| 13015 | return NULL; |
| 13016 | } |
| 13017 | goto done; |
| 13018 | } |
| 13019 | p->mark = mark; |
| 13020 | } |
| 13021 | res = NULL; |
| 13022 | done: |
| 13023 | return res; |
| 13024 | } |
| 13025 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13026 | // _tmp_51: '->' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13027 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13028 | _tmp_51_rule(Parser *p) |
| 13029 | { |
| 13030 | if (p->error_indicator) { |
| 13031 | return NULL; |
| 13032 | } |
| 13033 | void * res = NULL; |
| 13034 | int mark = p->mark; |
| 13035 | { // '->' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13036 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13037 | expr_ty z; |
| 13038 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13039 | (literal = _PyPegen_expect_token(p, 51)) // token='->' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13040 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13041 | (z = expression_rule(p)) // expression |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13042 | ) |
| 13043 | { |
| 13044 | res = z; |
| 13045 | if (res == NULL && PyErr_Occurred()) { |
| 13046 | p->error_indicator = 1; |
| 13047 | return NULL; |
| 13048 | } |
| 13049 | goto done; |
| 13050 | } |
| 13051 | p->mark = mark; |
| 13052 | } |
| 13053 | res = NULL; |
| 13054 | done: |
| 13055 | return res; |
| 13056 | } |
| 13057 | |
| 13058 | // _tmp_52: NEWLINE INDENT |
| 13059 | static void * |
| 13060 | _tmp_52_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13061 | { |
| 13062 | if (p->error_indicator) { |
| 13063 | return NULL; |
| 13064 | } |
| 13065 | void * res = NULL; |
| 13066 | int mark = p->mark; |
| 13067 | { // NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13068 | Token * indent_var; |
| 13069 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13070 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13071 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13072 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13073 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13074 | ) |
| 13075 | { |
| 13076 | res = _PyPegen_dummy_name(p, newline_var, indent_var); |
| 13077 | goto done; |
| 13078 | } |
| 13079 | p->mark = mark; |
| 13080 | } |
| 13081 | res = NULL; |
| 13082 | done: |
| 13083 | return res; |
| 13084 | } |
| 13085 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13086 | // _loop0_53: param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13087 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13088 | _loop0_53_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13089 | { |
| 13090 | if (p->error_indicator) { |
| 13091 | return NULL; |
| 13092 | } |
| 13093 | void *res = NULL; |
| 13094 | int mark = p->mark; |
| 13095 | int start_mark = p->mark; |
| 13096 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13097 | if (!children) { |
| 13098 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13099 | return NULL; |
| 13100 | } |
| 13101 | ssize_t children_capacity = 1; |
| 13102 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13103 | { // param_no_default |
| 13104 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13105 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13106 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13107 | ) |
| 13108 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13109 | res = param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13110 | if (n == children_capacity) { |
| 13111 | children_capacity *= 2; |
| 13112 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13113 | if (!children) { |
| 13114 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13115 | return NULL; |
| 13116 | } |
| 13117 | } |
| 13118 | children[n++] = res; |
| 13119 | mark = p->mark; |
| 13120 | } |
| 13121 | p->mark = mark; |
| 13122 | } |
| 13123 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13124 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13125 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13126 | PyMem_Free(children); |
| 13127 | return NULL; |
| 13128 | } |
| 13129 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13130 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13131 | _PyPegen_insert_memo(p, start_mark, _loop0_53_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13132 | return seq; |
| 13133 | } |
| 13134 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13135 | // _loop0_54: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13136 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13137 | _loop0_54_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13138 | { |
| 13139 | if (p->error_indicator) { |
| 13140 | return NULL; |
| 13141 | } |
| 13142 | void *res = NULL; |
| 13143 | int mark = p->mark; |
| 13144 | int start_mark = p->mark; |
| 13145 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13146 | if (!children) { |
| 13147 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13148 | return NULL; |
| 13149 | } |
| 13150 | ssize_t children_capacity = 1; |
| 13151 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13152 | { // param_with_default |
| 13153 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13154 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13155 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13156 | ) |
| 13157 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13158 | res = param_with_default_var; |
| 13159 | if (n == children_capacity) { |
| 13160 | children_capacity *= 2; |
| 13161 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13162 | if (!children) { |
| 13163 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13164 | return NULL; |
| 13165 | } |
| 13166 | } |
| 13167 | children[n++] = res; |
| 13168 | mark = p->mark; |
| 13169 | } |
| 13170 | p->mark = mark; |
| 13171 | } |
| 13172 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13173 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13174 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13175 | PyMem_Free(children); |
| 13176 | return NULL; |
| 13177 | } |
| 13178 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13179 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13180 | _PyPegen_insert_memo(p, start_mark, _loop0_54_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13181 | return seq; |
| 13182 | } |
| 13183 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13184 | // _loop0_55: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13185 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13186 | _loop0_55_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13187 | { |
| 13188 | if (p->error_indicator) { |
| 13189 | return NULL; |
| 13190 | } |
| 13191 | void *res = NULL; |
| 13192 | int mark = p->mark; |
| 13193 | int start_mark = p->mark; |
| 13194 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13195 | if (!children) { |
| 13196 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13197 | return NULL; |
| 13198 | } |
| 13199 | ssize_t children_capacity = 1; |
| 13200 | ssize_t n = 0; |
| 13201 | { // param_with_default |
| 13202 | NameDefaultPair* param_with_default_var; |
| 13203 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13204 | (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] | 13205 | ) |
| 13206 | { |
| 13207 | res = param_with_default_var; |
| 13208 | if (n == children_capacity) { |
| 13209 | children_capacity *= 2; |
| 13210 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13211 | if (!children) { |
| 13212 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13213 | return NULL; |
| 13214 | } |
| 13215 | } |
| 13216 | children[n++] = res; |
| 13217 | mark = p->mark; |
| 13218 | } |
| 13219 | p->mark = mark; |
| 13220 | } |
| 13221 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13222 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13223 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13224 | PyMem_Free(children); |
| 13225 | return NULL; |
| 13226 | } |
| 13227 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13228 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13229 | _PyPegen_insert_memo(p, start_mark, _loop0_55_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13230 | return seq; |
| 13231 | } |
| 13232 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13233 | // _loop1_56: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13234 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13235 | _loop1_56_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13236 | { |
| 13237 | if (p->error_indicator) { |
| 13238 | return NULL; |
| 13239 | } |
| 13240 | void *res = NULL; |
| 13241 | int mark = p->mark; |
| 13242 | int start_mark = p->mark; |
| 13243 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13244 | if (!children) { |
| 13245 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13246 | return NULL; |
| 13247 | } |
| 13248 | ssize_t children_capacity = 1; |
| 13249 | ssize_t n = 0; |
| 13250 | { // param_no_default |
| 13251 | arg_ty param_no_default_var; |
| 13252 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13253 | (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] | 13254 | ) |
| 13255 | { |
| 13256 | res = param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13257 | if (n == children_capacity) { |
| 13258 | children_capacity *= 2; |
| 13259 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13260 | if (!children) { |
| 13261 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13262 | return NULL; |
| 13263 | } |
| 13264 | } |
| 13265 | children[n++] = res; |
| 13266 | mark = p->mark; |
| 13267 | } |
| 13268 | p->mark = mark; |
| 13269 | } |
| 13270 | if (n == 0) { |
| 13271 | PyMem_Free(children); |
| 13272 | return NULL; |
| 13273 | } |
| 13274 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13275 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13276 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13277 | PyMem_Free(children); |
| 13278 | return NULL; |
| 13279 | } |
| 13280 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13281 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13282 | _PyPegen_insert_memo(p, start_mark, _loop1_56_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13283 | return seq; |
| 13284 | } |
| 13285 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13286 | // _loop0_57: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13287 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13288 | _loop0_57_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13289 | { |
| 13290 | if (p->error_indicator) { |
| 13291 | return NULL; |
| 13292 | } |
| 13293 | void *res = NULL; |
| 13294 | int mark = p->mark; |
| 13295 | int start_mark = p->mark; |
| 13296 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13297 | if (!children) { |
| 13298 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13299 | return NULL; |
| 13300 | } |
| 13301 | ssize_t children_capacity = 1; |
| 13302 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13303 | { // param_with_default |
| 13304 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13305 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13306 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13307 | ) |
| 13308 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13309 | res = param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13310 | if (n == children_capacity) { |
| 13311 | children_capacity *= 2; |
| 13312 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13313 | if (!children) { |
| 13314 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13315 | return NULL; |
| 13316 | } |
| 13317 | } |
| 13318 | children[n++] = res; |
| 13319 | mark = p->mark; |
| 13320 | } |
| 13321 | p->mark = mark; |
| 13322 | } |
| 13323 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13324 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13325 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13326 | PyMem_Free(children); |
| 13327 | return NULL; |
| 13328 | } |
| 13329 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13330 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13331 | _PyPegen_insert_memo(p, start_mark, _loop0_57_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13332 | return seq; |
| 13333 | } |
| 13334 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13335 | // _loop1_58: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13336 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13337 | _loop1_58_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13338 | { |
| 13339 | if (p->error_indicator) { |
| 13340 | return NULL; |
| 13341 | } |
| 13342 | void *res = NULL; |
| 13343 | int mark = p->mark; |
| 13344 | int start_mark = p->mark; |
| 13345 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13346 | if (!children) { |
| 13347 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13348 | return NULL; |
| 13349 | } |
| 13350 | ssize_t children_capacity = 1; |
| 13351 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13352 | { // param_with_default |
| 13353 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13354 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13355 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13356 | ) |
| 13357 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13358 | res = param_with_default_var; |
| 13359 | if (n == children_capacity) { |
| 13360 | children_capacity *= 2; |
| 13361 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13362 | if (!children) { |
| 13363 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13364 | return NULL; |
| 13365 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13366 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13367 | children[n++] = res; |
| 13368 | mark = p->mark; |
| 13369 | } |
| 13370 | p->mark = mark; |
| 13371 | } |
| 13372 | if (n == 0) { |
| 13373 | PyMem_Free(children); |
| 13374 | return NULL; |
| 13375 | } |
| 13376 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13377 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13378 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13379 | PyMem_Free(children); |
| 13380 | return NULL; |
| 13381 | } |
| 13382 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13383 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13384 | _PyPegen_insert_memo(p, start_mark, _loop1_58_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13385 | return seq; |
| 13386 | } |
| 13387 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13388 | // _loop1_59: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13389 | static asdl_seq * |
| 13390 | _loop1_59_rule(Parser *p) |
| 13391 | { |
| 13392 | if (p->error_indicator) { |
| 13393 | return NULL; |
| 13394 | } |
| 13395 | void *res = NULL; |
| 13396 | int mark = p->mark; |
| 13397 | int start_mark = p->mark; |
| 13398 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13399 | if (!children) { |
| 13400 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13401 | return NULL; |
| 13402 | } |
| 13403 | ssize_t children_capacity = 1; |
| 13404 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13405 | { // param_no_default |
| 13406 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13407 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13408 | (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] | 13409 | ) |
| 13410 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13411 | res = param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13412 | if (n == children_capacity) { |
| 13413 | children_capacity *= 2; |
| 13414 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13415 | if (!children) { |
| 13416 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13417 | return NULL; |
| 13418 | } |
| 13419 | } |
| 13420 | children[n++] = res; |
| 13421 | mark = p->mark; |
| 13422 | } |
| 13423 | p->mark = mark; |
| 13424 | } |
| 13425 | if (n == 0) { |
| 13426 | PyMem_Free(children); |
| 13427 | return NULL; |
| 13428 | } |
| 13429 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13430 | if (!seq) { |
| 13431 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59"); |
| 13432 | PyMem_Free(children); |
| 13433 | return NULL; |
| 13434 | } |
| 13435 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13436 | PyMem_Free(children); |
| 13437 | _PyPegen_insert_memo(p, start_mark, _loop1_59_type, seq); |
| 13438 | return seq; |
| 13439 | } |
| 13440 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13441 | // _loop1_60: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13442 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13443 | _loop1_60_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13444 | { |
| 13445 | if (p->error_indicator) { |
| 13446 | return NULL; |
| 13447 | } |
| 13448 | void *res = NULL; |
| 13449 | int mark = p->mark; |
| 13450 | int start_mark = p->mark; |
| 13451 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13452 | if (!children) { |
| 13453 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13454 | return NULL; |
| 13455 | } |
| 13456 | ssize_t children_capacity = 1; |
| 13457 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13458 | { // param_no_default |
| 13459 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13460 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13461 | (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] | 13462 | ) |
| 13463 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13464 | res = param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13465 | if (n == children_capacity) { |
| 13466 | children_capacity *= 2; |
| 13467 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13468 | if (!children) { |
| 13469 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13470 | return NULL; |
| 13471 | } |
| 13472 | } |
| 13473 | children[n++] = res; |
| 13474 | mark = p->mark; |
| 13475 | } |
| 13476 | p->mark = mark; |
| 13477 | } |
| 13478 | if (n == 0) { |
| 13479 | PyMem_Free(children); |
| 13480 | return NULL; |
| 13481 | } |
| 13482 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13483 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13484 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13485 | PyMem_Free(children); |
| 13486 | return NULL; |
| 13487 | } |
| 13488 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13489 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13490 | _PyPegen_insert_memo(p, start_mark, _loop1_60_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13491 | return seq; |
| 13492 | } |
| 13493 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13494 | // _loop0_61: param_no_default |
| 13495 | static asdl_seq * |
| 13496 | _loop0_61_rule(Parser *p) |
| 13497 | { |
| 13498 | if (p->error_indicator) { |
| 13499 | return NULL; |
| 13500 | } |
| 13501 | void *res = NULL; |
| 13502 | int mark = p->mark; |
| 13503 | int start_mark = p->mark; |
| 13504 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13505 | if (!children) { |
| 13506 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13507 | return NULL; |
| 13508 | } |
| 13509 | ssize_t children_capacity = 1; |
| 13510 | ssize_t n = 0; |
| 13511 | { // param_no_default |
| 13512 | arg_ty param_no_default_var; |
| 13513 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13514 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13515 | ) |
| 13516 | { |
| 13517 | res = param_no_default_var; |
| 13518 | if (n == children_capacity) { |
| 13519 | children_capacity *= 2; |
| 13520 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13521 | if (!children) { |
| 13522 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13523 | return NULL; |
| 13524 | } |
| 13525 | } |
| 13526 | children[n++] = res; |
| 13527 | mark = p->mark; |
| 13528 | } |
| 13529 | p->mark = mark; |
| 13530 | } |
| 13531 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13532 | if (!seq) { |
| 13533 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61"); |
| 13534 | PyMem_Free(children); |
| 13535 | return NULL; |
| 13536 | } |
| 13537 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13538 | PyMem_Free(children); |
| 13539 | _PyPegen_insert_memo(p, start_mark, _loop0_61_type, seq); |
| 13540 | return seq; |
| 13541 | } |
| 13542 | |
| 13543 | // _loop1_62: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13544 | static asdl_seq * |
| 13545 | _loop1_62_rule(Parser *p) |
| 13546 | { |
| 13547 | if (p->error_indicator) { |
| 13548 | return NULL; |
| 13549 | } |
| 13550 | void *res = NULL; |
| 13551 | int mark = p->mark; |
| 13552 | int start_mark = p->mark; |
| 13553 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13554 | if (!children) { |
| 13555 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13556 | return NULL; |
| 13557 | } |
| 13558 | ssize_t children_capacity = 1; |
| 13559 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13560 | { // param_with_default |
| 13561 | NameDefaultPair* param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13562 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13563 | (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] | 13564 | ) |
| 13565 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13566 | res = param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13567 | if (n == children_capacity) { |
| 13568 | children_capacity *= 2; |
| 13569 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13570 | if (!children) { |
| 13571 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13572 | return NULL; |
| 13573 | } |
| 13574 | } |
| 13575 | children[n++] = res; |
| 13576 | mark = p->mark; |
| 13577 | } |
| 13578 | p->mark = mark; |
| 13579 | } |
| 13580 | if (n == 0) { |
| 13581 | PyMem_Free(children); |
| 13582 | return NULL; |
| 13583 | } |
| 13584 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13585 | if (!seq) { |
| 13586 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62"); |
| 13587 | PyMem_Free(children); |
| 13588 | return NULL; |
| 13589 | } |
| 13590 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13591 | PyMem_Free(children); |
| 13592 | _PyPegen_insert_memo(p, start_mark, _loop1_62_type, seq); |
| 13593 | return seq; |
| 13594 | } |
| 13595 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13596 | // _loop0_63: param_no_default |
| 13597 | static asdl_seq * |
| 13598 | _loop0_63_rule(Parser *p) |
| 13599 | { |
| 13600 | if (p->error_indicator) { |
| 13601 | return NULL; |
| 13602 | } |
| 13603 | void *res = NULL; |
| 13604 | int mark = p->mark; |
| 13605 | int start_mark = p->mark; |
| 13606 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13607 | if (!children) { |
| 13608 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13609 | return NULL; |
| 13610 | } |
| 13611 | ssize_t children_capacity = 1; |
| 13612 | ssize_t n = 0; |
| 13613 | { // param_no_default |
| 13614 | arg_ty param_no_default_var; |
| 13615 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13616 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13617 | ) |
| 13618 | { |
| 13619 | res = param_no_default_var; |
| 13620 | if (n == children_capacity) { |
| 13621 | children_capacity *= 2; |
| 13622 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13623 | if (!children) { |
| 13624 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13625 | return NULL; |
| 13626 | } |
| 13627 | } |
| 13628 | children[n++] = res; |
| 13629 | mark = p->mark; |
| 13630 | } |
| 13631 | p->mark = mark; |
| 13632 | } |
| 13633 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13634 | if (!seq) { |
| 13635 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63"); |
| 13636 | PyMem_Free(children); |
| 13637 | return NULL; |
| 13638 | } |
| 13639 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13640 | PyMem_Free(children); |
| 13641 | _PyPegen_insert_memo(p, start_mark, _loop0_63_type, seq); |
| 13642 | return seq; |
| 13643 | } |
| 13644 | |
| 13645 | // _loop1_64: param_with_default |
| 13646 | static asdl_seq * |
| 13647 | _loop1_64_rule(Parser *p) |
| 13648 | { |
| 13649 | if (p->error_indicator) { |
| 13650 | return NULL; |
| 13651 | } |
| 13652 | void *res = NULL; |
| 13653 | int mark = p->mark; |
| 13654 | int start_mark = p->mark; |
| 13655 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13656 | if (!children) { |
| 13657 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13658 | return NULL; |
| 13659 | } |
| 13660 | ssize_t children_capacity = 1; |
| 13661 | ssize_t n = 0; |
| 13662 | { // param_with_default |
| 13663 | NameDefaultPair* param_with_default_var; |
| 13664 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13665 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13666 | ) |
| 13667 | { |
| 13668 | res = param_with_default_var; |
| 13669 | if (n == children_capacity) { |
| 13670 | children_capacity *= 2; |
| 13671 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13672 | if (!children) { |
| 13673 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13674 | return NULL; |
| 13675 | } |
| 13676 | } |
| 13677 | children[n++] = res; |
| 13678 | mark = p->mark; |
| 13679 | } |
| 13680 | p->mark = mark; |
| 13681 | } |
| 13682 | if (n == 0) { |
| 13683 | PyMem_Free(children); |
| 13684 | return NULL; |
| 13685 | } |
| 13686 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13687 | if (!seq) { |
| 13688 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64"); |
| 13689 | PyMem_Free(children); |
| 13690 | return NULL; |
| 13691 | } |
| 13692 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13693 | PyMem_Free(children); |
| 13694 | _PyPegen_insert_memo(p, start_mark, _loop1_64_type, seq); |
| 13695 | return seq; |
| 13696 | } |
| 13697 | |
| 13698 | // _loop0_65: param_maybe_default |
| 13699 | static asdl_seq * |
| 13700 | _loop0_65_rule(Parser *p) |
| 13701 | { |
| 13702 | if (p->error_indicator) { |
| 13703 | return NULL; |
| 13704 | } |
| 13705 | void *res = NULL; |
| 13706 | int mark = p->mark; |
| 13707 | int start_mark = p->mark; |
| 13708 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13709 | if (!children) { |
| 13710 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13711 | return NULL; |
| 13712 | } |
| 13713 | ssize_t children_capacity = 1; |
| 13714 | ssize_t n = 0; |
| 13715 | { // param_maybe_default |
| 13716 | NameDefaultPair* param_maybe_default_var; |
| 13717 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13718 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13719 | ) |
| 13720 | { |
| 13721 | res = param_maybe_default_var; |
| 13722 | if (n == children_capacity) { |
| 13723 | children_capacity *= 2; |
| 13724 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13725 | if (!children) { |
| 13726 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13727 | return NULL; |
| 13728 | } |
| 13729 | } |
| 13730 | children[n++] = res; |
| 13731 | mark = p->mark; |
| 13732 | } |
| 13733 | p->mark = mark; |
| 13734 | } |
| 13735 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13736 | if (!seq) { |
| 13737 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65"); |
| 13738 | PyMem_Free(children); |
| 13739 | return NULL; |
| 13740 | } |
| 13741 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13742 | PyMem_Free(children); |
| 13743 | _PyPegen_insert_memo(p, start_mark, _loop0_65_type, seq); |
| 13744 | return seq; |
| 13745 | } |
| 13746 | |
| 13747 | // _loop1_66: param_maybe_default |
| 13748 | static asdl_seq * |
| 13749 | _loop1_66_rule(Parser *p) |
| 13750 | { |
| 13751 | if (p->error_indicator) { |
| 13752 | return NULL; |
| 13753 | } |
| 13754 | void *res = NULL; |
| 13755 | int mark = p->mark; |
| 13756 | int start_mark = p->mark; |
| 13757 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13758 | if (!children) { |
| 13759 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13760 | return NULL; |
| 13761 | } |
| 13762 | ssize_t children_capacity = 1; |
| 13763 | ssize_t n = 0; |
| 13764 | { // param_maybe_default |
| 13765 | NameDefaultPair* param_maybe_default_var; |
| 13766 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13767 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13768 | ) |
| 13769 | { |
| 13770 | res = param_maybe_default_var; |
| 13771 | if (n == children_capacity) { |
| 13772 | children_capacity *= 2; |
| 13773 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13774 | if (!children) { |
| 13775 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13776 | return NULL; |
| 13777 | } |
| 13778 | } |
| 13779 | children[n++] = res; |
| 13780 | mark = p->mark; |
| 13781 | } |
| 13782 | p->mark = mark; |
| 13783 | } |
| 13784 | if (n == 0) { |
| 13785 | PyMem_Free(children); |
| 13786 | return NULL; |
| 13787 | } |
| 13788 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13789 | if (!seq) { |
| 13790 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66"); |
| 13791 | PyMem_Free(children); |
| 13792 | return NULL; |
| 13793 | } |
| 13794 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13795 | PyMem_Free(children); |
| 13796 | _PyPegen_insert_memo(p, start_mark, _loop1_66_type, seq); |
| 13797 | return seq; |
| 13798 | } |
| 13799 | |
| 13800 | // _loop1_67: ('@' named_expression NEWLINE) |
| 13801 | static asdl_seq * |
| 13802 | _loop1_67_rule(Parser *p) |
| 13803 | { |
| 13804 | if (p->error_indicator) { |
| 13805 | return NULL; |
| 13806 | } |
| 13807 | void *res = NULL; |
| 13808 | int mark = p->mark; |
| 13809 | int start_mark = p->mark; |
| 13810 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13811 | if (!children) { |
| 13812 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13813 | return NULL; |
| 13814 | } |
| 13815 | ssize_t children_capacity = 1; |
| 13816 | ssize_t n = 0; |
| 13817 | { // ('@' named_expression NEWLINE) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13818 | void *_tmp_137_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13819 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13820 | (_tmp_137_var = _tmp_137_rule(p)) // '@' named_expression NEWLINE |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13821 | ) |
| 13822 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13823 | res = _tmp_137_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13824 | if (n == children_capacity) { |
| 13825 | children_capacity *= 2; |
| 13826 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13827 | if (!children) { |
| 13828 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13829 | return NULL; |
| 13830 | } |
| 13831 | } |
| 13832 | children[n++] = res; |
| 13833 | mark = p->mark; |
| 13834 | } |
| 13835 | p->mark = mark; |
| 13836 | } |
| 13837 | if (n == 0) { |
| 13838 | PyMem_Free(children); |
| 13839 | return NULL; |
| 13840 | } |
| 13841 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13842 | if (!seq) { |
| 13843 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67"); |
| 13844 | PyMem_Free(children); |
| 13845 | return NULL; |
| 13846 | } |
| 13847 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13848 | PyMem_Free(children); |
| 13849 | _PyPegen_insert_memo(p, start_mark, _loop1_67_type, seq); |
| 13850 | return seq; |
| 13851 | } |
| 13852 | |
| 13853 | // _tmp_68: '(' arguments? ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13854 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13855 | _tmp_68_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13856 | { |
| 13857 | if (p->error_indicator) { |
| 13858 | return NULL; |
| 13859 | } |
| 13860 | void * res = NULL; |
| 13861 | int mark = p->mark; |
| 13862 | { // '(' arguments? ')' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13863 | Token * literal; |
| 13864 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13865 | void *z; |
| 13866 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13867 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13868 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13869 | (z = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13870 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13871 | (literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13872 | ) |
| 13873 | { |
| 13874 | res = z; |
| 13875 | if (res == NULL && PyErr_Occurred()) { |
| 13876 | p->error_indicator = 1; |
| 13877 | return NULL; |
| 13878 | } |
| 13879 | goto done; |
| 13880 | } |
| 13881 | p->mark = mark; |
| 13882 | } |
| 13883 | res = NULL; |
| 13884 | done: |
| 13885 | return res; |
| 13886 | } |
| 13887 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13888 | // _loop0_70: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13889 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13890 | _loop0_70_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13891 | { |
| 13892 | if (p->error_indicator) { |
| 13893 | return NULL; |
| 13894 | } |
| 13895 | void *res = NULL; |
| 13896 | int mark = p->mark; |
| 13897 | int start_mark = p->mark; |
| 13898 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13899 | if (!children) { |
| 13900 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13901 | return NULL; |
| 13902 | } |
| 13903 | ssize_t children_capacity = 1; |
| 13904 | ssize_t n = 0; |
| 13905 | { // ',' star_expression |
| 13906 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13907 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13908 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13909 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13910 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13911 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13912 | ) |
| 13913 | { |
| 13914 | res = elem; |
| 13915 | if (res == NULL && PyErr_Occurred()) { |
| 13916 | p->error_indicator = 1; |
| 13917 | PyMem_Free(children); |
| 13918 | return NULL; |
| 13919 | } |
| 13920 | if (n == children_capacity) { |
| 13921 | children_capacity *= 2; |
| 13922 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13923 | if (!children) { |
| 13924 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13925 | return NULL; |
| 13926 | } |
| 13927 | } |
| 13928 | children[n++] = res; |
| 13929 | mark = p->mark; |
| 13930 | } |
| 13931 | p->mark = mark; |
| 13932 | } |
| 13933 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13934 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13935 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13936 | PyMem_Free(children); |
| 13937 | return NULL; |
| 13938 | } |
| 13939 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13940 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13941 | _PyPegen_insert_memo(p, start_mark, _loop0_70_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13942 | return seq; |
| 13943 | } |
| 13944 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13945 | // _gather_69: star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13946 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13947 | _gather_69_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13948 | { |
| 13949 | if (p->error_indicator) { |
| 13950 | return NULL; |
| 13951 | } |
| 13952 | asdl_seq * res = NULL; |
| 13953 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13954 | { // star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13955 | expr_ty elem; |
| 13956 | asdl_seq * seq; |
| 13957 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13958 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13959 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13960 | (seq = _loop0_70_rule(p)) // _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13961 | ) |
| 13962 | { |
| 13963 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 13964 | goto done; |
| 13965 | } |
| 13966 | p->mark = mark; |
| 13967 | } |
| 13968 | res = NULL; |
| 13969 | done: |
| 13970 | return res; |
| 13971 | } |
| 13972 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13973 | // _loop1_71: (',' star_expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13974 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13975 | _loop1_71_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13976 | { |
| 13977 | if (p->error_indicator) { |
| 13978 | return NULL; |
| 13979 | } |
| 13980 | void *res = NULL; |
| 13981 | int mark = p->mark; |
| 13982 | int start_mark = p->mark; |
| 13983 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13984 | if (!children) { |
| 13985 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13986 | return NULL; |
| 13987 | } |
| 13988 | ssize_t children_capacity = 1; |
| 13989 | ssize_t n = 0; |
| 13990 | { // (',' star_expression) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13991 | void *_tmp_138_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13992 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13993 | (_tmp_138_var = _tmp_138_rule(p)) // ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13994 | ) |
| 13995 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13996 | res = _tmp_138_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13997 | if (n == children_capacity) { |
| 13998 | children_capacity *= 2; |
| 13999 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14000 | if (!children) { |
| 14001 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14002 | return NULL; |
| 14003 | } |
| 14004 | } |
| 14005 | children[n++] = res; |
| 14006 | mark = p->mark; |
| 14007 | } |
| 14008 | p->mark = mark; |
| 14009 | } |
| 14010 | if (n == 0) { |
| 14011 | PyMem_Free(children); |
| 14012 | return NULL; |
| 14013 | } |
| 14014 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14015 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14016 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14017 | PyMem_Free(children); |
| 14018 | return NULL; |
| 14019 | } |
| 14020 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14021 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14022 | _PyPegen_insert_memo(p, start_mark, _loop1_71_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14023 | return seq; |
| 14024 | } |
| 14025 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14026 | // _loop0_73: ',' star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14027 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14028 | _loop0_73_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14029 | { |
| 14030 | if (p->error_indicator) { |
| 14031 | return NULL; |
| 14032 | } |
| 14033 | void *res = NULL; |
| 14034 | int mark = p->mark; |
| 14035 | int start_mark = p->mark; |
| 14036 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14037 | if (!children) { |
| 14038 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14039 | return NULL; |
| 14040 | } |
| 14041 | ssize_t children_capacity = 1; |
| 14042 | ssize_t n = 0; |
| 14043 | { // ',' star_named_expression |
| 14044 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 14045 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14046 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14047 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14048 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14049 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14050 | ) |
| 14051 | { |
| 14052 | res = elem; |
| 14053 | if (res == NULL && PyErr_Occurred()) { |
| 14054 | p->error_indicator = 1; |
| 14055 | PyMem_Free(children); |
| 14056 | return NULL; |
| 14057 | } |
| 14058 | if (n == children_capacity) { |
| 14059 | children_capacity *= 2; |
| 14060 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14061 | if (!children) { |
| 14062 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14063 | return NULL; |
| 14064 | } |
| 14065 | } |
| 14066 | children[n++] = res; |
| 14067 | mark = p->mark; |
| 14068 | } |
| 14069 | p->mark = mark; |
| 14070 | } |
| 14071 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14072 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14073 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14074 | PyMem_Free(children); |
| 14075 | return NULL; |
| 14076 | } |
| 14077 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14078 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14079 | _PyPegen_insert_memo(p, start_mark, _loop0_73_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14080 | return seq; |
| 14081 | } |
| 14082 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14083 | // _gather_72: star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14084 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14085 | _gather_72_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14086 | { |
| 14087 | if (p->error_indicator) { |
| 14088 | return NULL; |
| 14089 | } |
| 14090 | asdl_seq * res = NULL; |
| 14091 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14092 | { // star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14093 | expr_ty elem; |
| 14094 | asdl_seq * seq; |
| 14095 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14096 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14097 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14098 | (seq = _loop0_73_rule(p)) // _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14099 | ) |
| 14100 | { |
| 14101 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 14102 | goto done; |
| 14103 | } |
| 14104 | p->mark = mark; |
| 14105 | } |
| 14106 | res = NULL; |
| 14107 | done: |
| 14108 | return res; |
| 14109 | } |
| 14110 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14111 | // _loop1_74: (',' expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14112 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14113 | _loop1_74_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14114 | { |
| 14115 | if (p->error_indicator) { |
| 14116 | return NULL; |
| 14117 | } |
| 14118 | void *res = NULL; |
| 14119 | int mark = p->mark; |
| 14120 | int start_mark = p->mark; |
| 14121 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14122 | if (!children) { |
| 14123 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14124 | return NULL; |
| 14125 | } |
| 14126 | ssize_t children_capacity = 1; |
| 14127 | ssize_t n = 0; |
| 14128 | { // (',' expression) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14129 | void *_tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14130 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14131 | (_tmp_139_var = _tmp_139_rule(p)) // ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14132 | ) |
| 14133 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14134 | res = _tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14135 | if (n == children_capacity) { |
| 14136 | children_capacity *= 2; |
| 14137 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14138 | if (!children) { |
| 14139 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14140 | return NULL; |
| 14141 | } |
| 14142 | } |
| 14143 | children[n++] = res; |
| 14144 | mark = p->mark; |
| 14145 | } |
| 14146 | p->mark = mark; |
| 14147 | } |
| 14148 | if (n == 0) { |
| 14149 | PyMem_Free(children); |
| 14150 | return NULL; |
| 14151 | } |
| 14152 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14153 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14154 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14155 | PyMem_Free(children); |
| 14156 | return NULL; |
| 14157 | } |
| 14158 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14159 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14160 | _PyPegen_insert_memo(p, start_mark, _loop1_74_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14161 | return seq; |
| 14162 | } |
| 14163 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14164 | // _loop0_75: lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14165 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14166 | _loop0_75_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14167 | { |
| 14168 | if (p->error_indicator) { |
| 14169 | return NULL; |
| 14170 | } |
| 14171 | void *res = NULL; |
| 14172 | int mark = p->mark; |
| 14173 | int start_mark = p->mark; |
| 14174 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14175 | if (!children) { |
| 14176 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14177 | return NULL; |
| 14178 | } |
| 14179 | ssize_t children_capacity = 1; |
| 14180 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14181 | { // lambda_param_no_default |
| 14182 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14183 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14184 | (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] | 14185 | ) |
| 14186 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14187 | res = lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14188 | if (n == children_capacity) { |
| 14189 | children_capacity *= 2; |
| 14190 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14191 | if (!children) { |
| 14192 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14193 | return NULL; |
| 14194 | } |
| 14195 | } |
| 14196 | children[n++] = res; |
| 14197 | mark = p->mark; |
| 14198 | } |
| 14199 | p->mark = mark; |
| 14200 | } |
| 14201 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14202 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14203 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14204 | PyMem_Free(children); |
| 14205 | return NULL; |
| 14206 | } |
| 14207 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14208 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14209 | _PyPegen_insert_memo(p, start_mark, _loop0_75_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14210 | return seq; |
| 14211 | } |
| 14212 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14213 | // _loop0_76: lambda_param_with_default |
| 14214 | static asdl_seq * |
| 14215 | _loop0_76_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14216 | { |
| 14217 | if (p->error_indicator) { |
| 14218 | return NULL; |
| 14219 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14220 | void *res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14221 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14222 | int start_mark = p->mark; |
| 14223 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14224 | if (!children) { |
| 14225 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14226 | return NULL; |
| 14227 | } |
| 14228 | ssize_t children_capacity = 1; |
| 14229 | ssize_t n = 0; |
| 14230 | { // lambda_param_with_default |
| 14231 | NameDefaultPair* lambda_param_with_default_var; |
| 14232 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14233 | (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] | 14234 | ) |
| 14235 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14236 | res = lambda_param_with_default_var; |
| 14237 | if (n == children_capacity) { |
| 14238 | children_capacity *= 2; |
| 14239 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14240 | if (!children) { |
| 14241 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14242 | return NULL; |
| 14243 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14244 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14245 | children[n++] = res; |
| 14246 | mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14247 | } |
| 14248 | p->mark = mark; |
| 14249 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14250 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14251 | if (!seq) { |
| 14252 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76"); |
| 14253 | PyMem_Free(children); |
| 14254 | return NULL; |
| 14255 | } |
| 14256 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14257 | PyMem_Free(children); |
| 14258 | _PyPegen_insert_memo(p, start_mark, _loop0_76_type, seq); |
| 14259 | return seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14260 | } |
| 14261 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14262 | // _loop0_77: lambda_param_with_default |
| 14263 | static asdl_seq * |
| 14264 | _loop0_77_rule(Parser *p) |
| 14265 | { |
| 14266 | if (p->error_indicator) { |
| 14267 | return NULL; |
| 14268 | } |
| 14269 | void *res = NULL; |
| 14270 | int mark = p->mark; |
| 14271 | int start_mark = p->mark; |
| 14272 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14273 | if (!children) { |
| 14274 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14275 | return NULL; |
| 14276 | } |
| 14277 | ssize_t children_capacity = 1; |
| 14278 | ssize_t n = 0; |
| 14279 | { // lambda_param_with_default |
| 14280 | NameDefaultPair* lambda_param_with_default_var; |
| 14281 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14282 | (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] | 14283 | ) |
| 14284 | { |
| 14285 | res = lambda_param_with_default_var; |
| 14286 | if (n == children_capacity) { |
| 14287 | children_capacity *= 2; |
| 14288 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14289 | if (!children) { |
| 14290 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14291 | return NULL; |
| 14292 | } |
| 14293 | } |
| 14294 | children[n++] = res; |
| 14295 | mark = p->mark; |
| 14296 | } |
| 14297 | p->mark = mark; |
| 14298 | } |
| 14299 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14300 | if (!seq) { |
| 14301 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77"); |
| 14302 | PyMem_Free(children); |
| 14303 | return NULL; |
| 14304 | } |
| 14305 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14306 | PyMem_Free(children); |
| 14307 | _PyPegen_insert_memo(p, start_mark, _loop0_77_type, seq); |
| 14308 | return seq; |
| 14309 | } |
| 14310 | |
| 14311 | // _loop1_78: lambda_param_no_default |
| 14312 | static asdl_seq * |
| 14313 | _loop1_78_rule(Parser *p) |
| 14314 | { |
| 14315 | if (p->error_indicator) { |
| 14316 | return NULL; |
| 14317 | } |
| 14318 | void *res = NULL; |
| 14319 | int mark = p->mark; |
| 14320 | int start_mark = p->mark; |
| 14321 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14322 | if (!children) { |
| 14323 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14324 | return NULL; |
| 14325 | } |
| 14326 | ssize_t children_capacity = 1; |
| 14327 | ssize_t n = 0; |
| 14328 | { // lambda_param_no_default |
| 14329 | arg_ty lambda_param_no_default_var; |
| 14330 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14331 | (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] | 14332 | ) |
| 14333 | { |
| 14334 | res = lambda_param_no_default_var; |
| 14335 | if (n == children_capacity) { |
| 14336 | children_capacity *= 2; |
| 14337 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14338 | if (!children) { |
| 14339 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14340 | return NULL; |
| 14341 | } |
| 14342 | } |
| 14343 | children[n++] = res; |
| 14344 | mark = p->mark; |
| 14345 | } |
| 14346 | p->mark = mark; |
| 14347 | } |
| 14348 | if (n == 0) { |
| 14349 | PyMem_Free(children); |
| 14350 | return NULL; |
| 14351 | } |
| 14352 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14353 | if (!seq) { |
| 14354 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78"); |
| 14355 | PyMem_Free(children); |
| 14356 | return NULL; |
| 14357 | } |
| 14358 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14359 | PyMem_Free(children); |
| 14360 | _PyPegen_insert_memo(p, start_mark, _loop1_78_type, seq); |
| 14361 | return seq; |
| 14362 | } |
| 14363 | |
| 14364 | // _loop0_79: lambda_param_with_default |
| 14365 | static asdl_seq * |
| 14366 | _loop0_79_rule(Parser *p) |
| 14367 | { |
| 14368 | if (p->error_indicator) { |
| 14369 | return NULL; |
| 14370 | } |
| 14371 | void *res = NULL; |
| 14372 | int mark = p->mark; |
| 14373 | int start_mark = p->mark; |
| 14374 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14375 | if (!children) { |
| 14376 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14377 | return NULL; |
| 14378 | } |
| 14379 | ssize_t children_capacity = 1; |
| 14380 | ssize_t n = 0; |
| 14381 | { // lambda_param_with_default |
| 14382 | NameDefaultPair* lambda_param_with_default_var; |
| 14383 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14384 | (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] | 14385 | ) |
| 14386 | { |
| 14387 | res = lambda_param_with_default_var; |
| 14388 | if (n == children_capacity) { |
| 14389 | children_capacity *= 2; |
| 14390 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14391 | if (!children) { |
| 14392 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14393 | return NULL; |
| 14394 | } |
| 14395 | } |
| 14396 | children[n++] = res; |
| 14397 | mark = p->mark; |
| 14398 | } |
| 14399 | p->mark = mark; |
| 14400 | } |
| 14401 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14402 | if (!seq) { |
| 14403 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79"); |
| 14404 | PyMem_Free(children); |
| 14405 | return NULL; |
| 14406 | } |
| 14407 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14408 | PyMem_Free(children); |
| 14409 | _PyPegen_insert_memo(p, start_mark, _loop0_79_type, seq); |
| 14410 | return seq; |
| 14411 | } |
| 14412 | |
| 14413 | // _loop1_80: lambda_param_with_default |
| 14414 | static asdl_seq * |
| 14415 | _loop1_80_rule(Parser *p) |
| 14416 | { |
| 14417 | if (p->error_indicator) { |
| 14418 | return NULL; |
| 14419 | } |
| 14420 | void *res = NULL; |
| 14421 | int mark = p->mark; |
| 14422 | int start_mark = p->mark; |
| 14423 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14424 | if (!children) { |
| 14425 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14426 | return NULL; |
| 14427 | } |
| 14428 | ssize_t children_capacity = 1; |
| 14429 | ssize_t n = 0; |
| 14430 | { // lambda_param_with_default |
| 14431 | NameDefaultPair* lambda_param_with_default_var; |
| 14432 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14433 | (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] | 14434 | ) |
| 14435 | { |
| 14436 | res = lambda_param_with_default_var; |
| 14437 | if (n == children_capacity) { |
| 14438 | children_capacity *= 2; |
| 14439 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14440 | if (!children) { |
| 14441 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14442 | return NULL; |
| 14443 | } |
| 14444 | } |
| 14445 | children[n++] = res; |
| 14446 | mark = p->mark; |
| 14447 | } |
| 14448 | p->mark = mark; |
| 14449 | } |
| 14450 | if (n == 0) { |
| 14451 | PyMem_Free(children); |
| 14452 | return NULL; |
| 14453 | } |
| 14454 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14455 | if (!seq) { |
| 14456 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80"); |
| 14457 | PyMem_Free(children); |
| 14458 | return NULL; |
| 14459 | } |
| 14460 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14461 | PyMem_Free(children); |
| 14462 | _PyPegen_insert_memo(p, start_mark, _loop1_80_type, seq); |
| 14463 | return seq; |
| 14464 | } |
| 14465 | |
| 14466 | // _loop1_81: lambda_param_no_default |
| 14467 | static asdl_seq * |
| 14468 | _loop1_81_rule(Parser *p) |
| 14469 | { |
| 14470 | if (p->error_indicator) { |
| 14471 | return NULL; |
| 14472 | } |
| 14473 | void *res = NULL; |
| 14474 | int mark = p->mark; |
| 14475 | int start_mark = p->mark; |
| 14476 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14477 | if (!children) { |
| 14478 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14479 | return NULL; |
| 14480 | } |
| 14481 | ssize_t children_capacity = 1; |
| 14482 | ssize_t n = 0; |
| 14483 | { // lambda_param_no_default |
| 14484 | arg_ty lambda_param_no_default_var; |
| 14485 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14486 | (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] | 14487 | ) |
| 14488 | { |
| 14489 | res = lambda_param_no_default_var; |
| 14490 | if (n == children_capacity) { |
| 14491 | children_capacity *= 2; |
| 14492 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14493 | if (!children) { |
| 14494 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14495 | return NULL; |
| 14496 | } |
| 14497 | } |
| 14498 | children[n++] = res; |
| 14499 | mark = p->mark; |
| 14500 | } |
| 14501 | p->mark = mark; |
| 14502 | } |
| 14503 | if (n == 0) { |
| 14504 | PyMem_Free(children); |
| 14505 | return NULL; |
| 14506 | } |
| 14507 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14508 | if (!seq) { |
| 14509 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81"); |
| 14510 | PyMem_Free(children); |
| 14511 | return NULL; |
| 14512 | } |
| 14513 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14514 | PyMem_Free(children); |
| 14515 | _PyPegen_insert_memo(p, start_mark, _loop1_81_type, seq); |
| 14516 | return seq; |
| 14517 | } |
| 14518 | |
| 14519 | // _loop1_82: lambda_param_no_default |
| 14520 | static asdl_seq * |
| 14521 | _loop1_82_rule(Parser *p) |
| 14522 | { |
| 14523 | if (p->error_indicator) { |
| 14524 | return NULL; |
| 14525 | } |
| 14526 | void *res = NULL; |
| 14527 | int mark = p->mark; |
| 14528 | int start_mark = p->mark; |
| 14529 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14530 | if (!children) { |
| 14531 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14532 | return NULL; |
| 14533 | } |
| 14534 | ssize_t children_capacity = 1; |
| 14535 | ssize_t n = 0; |
| 14536 | { // lambda_param_no_default |
| 14537 | arg_ty lambda_param_no_default_var; |
| 14538 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14539 | (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] | 14540 | ) |
| 14541 | { |
| 14542 | res = lambda_param_no_default_var; |
| 14543 | if (n == children_capacity) { |
| 14544 | children_capacity *= 2; |
| 14545 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14546 | if (!children) { |
| 14547 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14548 | return NULL; |
| 14549 | } |
| 14550 | } |
| 14551 | children[n++] = res; |
| 14552 | mark = p->mark; |
| 14553 | } |
| 14554 | p->mark = mark; |
| 14555 | } |
| 14556 | if (n == 0) { |
| 14557 | PyMem_Free(children); |
| 14558 | return NULL; |
| 14559 | } |
| 14560 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14561 | if (!seq) { |
| 14562 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82"); |
| 14563 | PyMem_Free(children); |
| 14564 | return NULL; |
| 14565 | } |
| 14566 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14567 | PyMem_Free(children); |
| 14568 | _PyPegen_insert_memo(p, start_mark, _loop1_82_type, seq); |
| 14569 | return seq; |
| 14570 | } |
| 14571 | |
| 14572 | // _loop0_83: lambda_param_no_default |
| 14573 | static asdl_seq * |
| 14574 | _loop0_83_rule(Parser *p) |
| 14575 | { |
| 14576 | if (p->error_indicator) { |
| 14577 | return NULL; |
| 14578 | } |
| 14579 | void *res = NULL; |
| 14580 | int mark = p->mark; |
| 14581 | int start_mark = p->mark; |
| 14582 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14583 | if (!children) { |
| 14584 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14585 | return NULL; |
| 14586 | } |
| 14587 | ssize_t children_capacity = 1; |
| 14588 | ssize_t n = 0; |
| 14589 | { // lambda_param_no_default |
| 14590 | arg_ty lambda_param_no_default_var; |
| 14591 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14592 | (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] | 14593 | ) |
| 14594 | { |
| 14595 | res = lambda_param_no_default_var; |
| 14596 | if (n == children_capacity) { |
| 14597 | children_capacity *= 2; |
| 14598 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14599 | if (!children) { |
| 14600 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14601 | return NULL; |
| 14602 | } |
| 14603 | } |
| 14604 | children[n++] = res; |
| 14605 | mark = p->mark; |
| 14606 | } |
| 14607 | p->mark = mark; |
| 14608 | } |
| 14609 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14610 | if (!seq) { |
| 14611 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83"); |
| 14612 | PyMem_Free(children); |
| 14613 | return NULL; |
| 14614 | } |
| 14615 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14616 | PyMem_Free(children); |
| 14617 | _PyPegen_insert_memo(p, start_mark, _loop0_83_type, seq); |
| 14618 | return seq; |
| 14619 | } |
| 14620 | |
| 14621 | // _loop1_84: lambda_param_with_default |
| 14622 | static asdl_seq * |
| 14623 | _loop1_84_rule(Parser *p) |
| 14624 | { |
| 14625 | if (p->error_indicator) { |
| 14626 | return NULL; |
| 14627 | } |
| 14628 | void *res = NULL; |
| 14629 | int mark = p->mark; |
| 14630 | int start_mark = p->mark; |
| 14631 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14632 | if (!children) { |
| 14633 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14634 | return NULL; |
| 14635 | } |
| 14636 | ssize_t children_capacity = 1; |
| 14637 | ssize_t n = 0; |
| 14638 | { // lambda_param_with_default |
| 14639 | NameDefaultPair* lambda_param_with_default_var; |
| 14640 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14641 | (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] | 14642 | ) |
| 14643 | { |
| 14644 | res = lambda_param_with_default_var; |
| 14645 | if (n == children_capacity) { |
| 14646 | children_capacity *= 2; |
| 14647 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14648 | if (!children) { |
| 14649 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14650 | return NULL; |
| 14651 | } |
| 14652 | } |
| 14653 | children[n++] = res; |
| 14654 | mark = p->mark; |
| 14655 | } |
| 14656 | p->mark = mark; |
| 14657 | } |
| 14658 | if (n == 0) { |
| 14659 | PyMem_Free(children); |
| 14660 | return NULL; |
| 14661 | } |
| 14662 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14663 | if (!seq) { |
| 14664 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84"); |
| 14665 | PyMem_Free(children); |
| 14666 | return NULL; |
| 14667 | } |
| 14668 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14669 | PyMem_Free(children); |
| 14670 | _PyPegen_insert_memo(p, start_mark, _loop1_84_type, seq); |
| 14671 | return seq; |
| 14672 | } |
| 14673 | |
| 14674 | // _loop0_85: lambda_param_no_default |
| 14675 | static asdl_seq * |
| 14676 | _loop0_85_rule(Parser *p) |
| 14677 | { |
| 14678 | if (p->error_indicator) { |
| 14679 | return NULL; |
| 14680 | } |
| 14681 | void *res = NULL; |
| 14682 | int mark = p->mark; |
| 14683 | int start_mark = p->mark; |
| 14684 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14685 | if (!children) { |
| 14686 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14687 | return NULL; |
| 14688 | } |
| 14689 | ssize_t children_capacity = 1; |
| 14690 | ssize_t n = 0; |
| 14691 | { // lambda_param_no_default |
| 14692 | arg_ty lambda_param_no_default_var; |
| 14693 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14694 | (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] | 14695 | ) |
| 14696 | { |
| 14697 | res = lambda_param_no_default_var; |
| 14698 | if (n == children_capacity) { |
| 14699 | children_capacity *= 2; |
| 14700 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14701 | if (!children) { |
| 14702 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14703 | return NULL; |
| 14704 | } |
| 14705 | } |
| 14706 | children[n++] = res; |
| 14707 | mark = p->mark; |
| 14708 | } |
| 14709 | p->mark = mark; |
| 14710 | } |
| 14711 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14712 | if (!seq) { |
| 14713 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85"); |
| 14714 | PyMem_Free(children); |
| 14715 | return NULL; |
| 14716 | } |
| 14717 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14718 | PyMem_Free(children); |
| 14719 | _PyPegen_insert_memo(p, start_mark, _loop0_85_type, seq); |
| 14720 | return seq; |
| 14721 | } |
| 14722 | |
| 14723 | // _loop1_86: lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14724 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14725 | _loop1_86_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14726 | { |
| 14727 | if (p->error_indicator) { |
| 14728 | return NULL; |
| 14729 | } |
| 14730 | void *res = NULL; |
| 14731 | int mark = p->mark; |
| 14732 | int start_mark = p->mark; |
| 14733 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14734 | if (!children) { |
| 14735 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14736 | return NULL; |
| 14737 | } |
| 14738 | ssize_t children_capacity = 1; |
| 14739 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14740 | { // lambda_param_with_default |
| 14741 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14742 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14743 | (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] | 14744 | ) |
| 14745 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14746 | res = lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14747 | if (n == children_capacity) { |
| 14748 | children_capacity *= 2; |
| 14749 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14750 | if (!children) { |
| 14751 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14752 | return NULL; |
| 14753 | } |
| 14754 | } |
| 14755 | children[n++] = res; |
| 14756 | mark = p->mark; |
| 14757 | } |
| 14758 | p->mark = mark; |
| 14759 | } |
| 14760 | if (n == 0) { |
| 14761 | PyMem_Free(children); |
| 14762 | return NULL; |
| 14763 | } |
| 14764 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14765 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14766 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14767 | PyMem_Free(children); |
| 14768 | return NULL; |
| 14769 | } |
| 14770 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14771 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14772 | _PyPegen_insert_memo(p, start_mark, _loop1_86_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14773 | return seq; |
| 14774 | } |
| 14775 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14776 | // _loop0_87: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14777 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14778 | _loop0_87_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14779 | { |
| 14780 | if (p->error_indicator) { |
| 14781 | return NULL; |
| 14782 | } |
| 14783 | void *res = NULL; |
| 14784 | int mark = p->mark; |
| 14785 | int start_mark = p->mark; |
| 14786 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14787 | if (!children) { |
| 14788 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14789 | return NULL; |
| 14790 | } |
| 14791 | ssize_t children_capacity = 1; |
| 14792 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14793 | { // lambda_param_maybe_default |
| 14794 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14795 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14796 | (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] | 14797 | ) |
| 14798 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14799 | res = lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14800 | if (n == children_capacity) { |
| 14801 | children_capacity *= 2; |
| 14802 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14803 | if (!children) { |
| 14804 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14805 | return NULL; |
| 14806 | } |
| 14807 | } |
| 14808 | children[n++] = res; |
| 14809 | mark = p->mark; |
| 14810 | } |
| 14811 | p->mark = mark; |
| 14812 | } |
| 14813 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14814 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14815 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14816 | PyMem_Free(children); |
| 14817 | return NULL; |
| 14818 | } |
| 14819 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14820 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14821 | _PyPegen_insert_memo(p, start_mark, _loop0_87_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14822 | return seq; |
| 14823 | } |
| 14824 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14825 | // _loop1_88: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14826 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14827 | _loop1_88_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14828 | { |
| 14829 | if (p->error_indicator) { |
| 14830 | return NULL; |
| 14831 | } |
| 14832 | void *res = NULL; |
| 14833 | int mark = p->mark; |
| 14834 | int start_mark = p->mark; |
| 14835 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14836 | if (!children) { |
| 14837 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14838 | return NULL; |
| 14839 | } |
| 14840 | ssize_t children_capacity = 1; |
| 14841 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14842 | { // lambda_param_maybe_default |
| 14843 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14844 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14845 | (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] | 14846 | ) |
| 14847 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14848 | res = lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14849 | if (n == children_capacity) { |
| 14850 | children_capacity *= 2; |
| 14851 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14852 | if (!children) { |
| 14853 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14854 | return NULL; |
| 14855 | } |
| 14856 | } |
| 14857 | children[n++] = res; |
| 14858 | mark = p->mark; |
| 14859 | } |
| 14860 | p->mark = mark; |
| 14861 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14862 | if (n == 0) { |
| 14863 | PyMem_Free(children); |
| 14864 | return NULL; |
| 14865 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14866 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14867 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14868 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14869 | PyMem_Free(children); |
| 14870 | return NULL; |
| 14871 | } |
| 14872 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14873 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14874 | _PyPegen_insert_memo(p, start_mark, _loop1_88_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14875 | return seq; |
| 14876 | } |
| 14877 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14878 | // _loop1_89: ('or' conjunction) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14879 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14880 | _loop1_89_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14881 | { |
| 14882 | if (p->error_indicator) { |
| 14883 | return NULL; |
| 14884 | } |
| 14885 | void *res = NULL; |
| 14886 | int mark = p->mark; |
| 14887 | int start_mark = p->mark; |
| 14888 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14889 | if (!children) { |
| 14890 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14891 | return NULL; |
| 14892 | } |
| 14893 | ssize_t children_capacity = 1; |
| 14894 | ssize_t n = 0; |
| 14895 | { // ('or' conjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14896 | void *_tmp_140_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14897 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14898 | (_tmp_140_var = _tmp_140_rule(p)) // 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14899 | ) |
| 14900 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14901 | res = _tmp_140_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14902 | if (n == children_capacity) { |
| 14903 | children_capacity *= 2; |
| 14904 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14905 | if (!children) { |
| 14906 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14907 | return NULL; |
| 14908 | } |
| 14909 | } |
| 14910 | children[n++] = res; |
| 14911 | mark = p->mark; |
| 14912 | } |
| 14913 | p->mark = mark; |
| 14914 | } |
| 14915 | if (n == 0) { |
| 14916 | PyMem_Free(children); |
| 14917 | return NULL; |
| 14918 | } |
| 14919 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14920 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14921 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14922 | PyMem_Free(children); |
| 14923 | return NULL; |
| 14924 | } |
| 14925 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14926 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14927 | _PyPegen_insert_memo(p, start_mark, _loop1_89_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14928 | return seq; |
| 14929 | } |
| 14930 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14931 | // _loop1_90: ('and' inversion) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14932 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14933 | _loop1_90_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14934 | { |
| 14935 | if (p->error_indicator) { |
| 14936 | return NULL; |
| 14937 | } |
| 14938 | void *res = NULL; |
| 14939 | int mark = p->mark; |
| 14940 | int start_mark = p->mark; |
| 14941 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14942 | if (!children) { |
| 14943 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14944 | return NULL; |
| 14945 | } |
| 14946 | ssize_t children_capacity = 1; |
| 14947 | ssize_t n = 0; |
| 14948 | { // ('and' inversion) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14949 | void *_tmp_141_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14950 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14951 | (_tmp_141_var = _tmp_141_rule(p)) // 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14952 | ) |
| 14953 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14954 | res = _tmp_141_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14955 | if (n == children_capacity) { |
| 14956 | children_capacity *= 2; |
| 14957 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14958 | if (!children) { |
| 14959 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14960 | return NULL; |
| 14961 | } |
| 14962 | } |
| 14963 | children[n++] = res; |
| 14964 | mark = p->mark; |
| 14965 | } |
| 14966 | p->mark = mark; |
| 14967 | } |
| 14968 | if (n == 0) { |
| 14969 | PyMem_Free(children); |
| 14970 | return NULL; |
| 14971 | } |
| 14972 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14973 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14974 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14975 | PyMem_Free(children); |
| 14976 | return NULL; |
| 14977 | } |
| 14978 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14979 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14980 | _PyPegen_insert_memo(p, start_mark, _loop1_90_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14981 | return seq; |
| 14982 | } |
| 14983 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14984 | // _loop1_91: compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14985 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14986 | _loop1_91_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14987 | { |
| 14988 | if (p->error_indicator) { |
| 14989 | return NULL; |
| 14990 | } |
| 14991 | void *res = NULL; |
| 14992 | int mark = p->mark; |
| 14993 | int start_mark = p->mark; |
| 14994 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14995 | if (!children) { |
| 14996 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14997 | return NULL; |
| 14998 | } |
| 14999 | ssize_t children_capacity = 1; |
| 15000 | ssize_t n = 0; |
| 15001 | { // compare_op_bitwise_or_pair |
| 15002 | CmpopExprPair* compare_op_bitwise_or_pair_var; |
| 15003 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15004 | (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] | 15005 | ) |
| 15006 | { |
| 15007 | res = compare_op_bitwise_or_pair_var; |
| 15008 | if (n == children_capacity) { |
| 15009 | children_capacity *= 2; |
| 15010 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15011 | if (!children) { |
| 15012 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15013 | return NULL; |
| 15014 | } |
| 15015 | } |
| 15016 | children[n++] = res; |
| 15017 | mark = p->mark; |
| 15018 | } |
| 15019 | p->mark = mark; |
| 15020 | } |
| 15021 | if (n == 0) { |
| 15022 | PyMem_Free(children); |
| 15023 | return NULL; |
| 15024 | } |
| 15025 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15026 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15027 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15028 | PyMem_Free(children); |
| 15029 | return NULL; |
| 15030 | } |
| 15031 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15032 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15033 | _PyPegen_insert_memo(p, start_mark, _loop1_91_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15034 | return seq; |
| 15035 | } |
| 15036 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15037 | // _tmp_92: '!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15038 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15039 | _tmp_92_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15040 | { |
| 15041 | if (p->error_indicator) { |
| 15042 | return NULL; |
| 15043 | } |
| 15044 | void * res = NULL; |
| 15045 | int mark = p->mark; |
| 15046 | { // '!=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15047 | Token * tok; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15048 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15049 | (tok = _PyPegen_expect_token(p, 28)) // token='!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15050 | ) |
| 15051 | { |
| 15052 | res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; |
| 15053 | if (res == NULL && PyErr_Occurred()) { |
| 15054 | p->error_indicator = 1; |
| 15055 | return NULL; |
| 15056 | } |
| 15057 | goto done; |
| 15058 | } |
| 15059 | p->mark = mark; |
| 15060 | } |
| 15061 | res = NULL; |
| 15062 | done: |
| 15063 | return res; |
| 15064 | } |
| 15065 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15066 | // _loop0_94: ',' slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15067 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15068 | _loop0_94_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15069 | { |
| 15070 | if (p->error_indicator) { |
| 15071 | return NULL; |
| 15072 | } |
| 15073 | void *res = NULL; |
| 15074 | int mark = p->mark; |
| 15075 | int start_mark = p->mark; |
| 15076 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15077 | if (!children) { |
| 15078 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15079 | return NULL; |
| 15080 | } |
| 15081 | ssize_t children_capacity = 1; |
| 15082 | ssize_t n = 0; |
| 15083 | { // ',' slice |
| 15084 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15085 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15086 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15087 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15088 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15089 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15090 | ) |
| 15091 | { |
| 15092 | res = elem; |
| 15093 | if (res == NULL && PyErr_Occurred()) { |
| 15094 | p->error_indicator = 1; |
| 15095 | PyMem_Free(children); |
| 15096 | return NULL; |
| 15097 | } |
| 15098 | if (n == children_capacity) { |
| 15099 | children_capacity *= 2; |
| 15100 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15101 | if (!children) { |
| 15102 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15103 | return NULL; |
| 15104 | } |
| 15105 | } |
| 15106 | children[n++] = res; |
| 15107 | mark = p->mark; |
| 15108 | } |
| 15109 | p->mark = mark; |
| 15110 | } |
| 15111 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15112 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15113 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15114 | PyMem_Free(children); |
| 15115 | return NULL; |
| 15116 | } |
| 15117 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15118 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15119 | _PyPegen_insert_memo(p, start_mark, _loop0_94_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15120 | return seq; |
| 15121 | } |
| 15122 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15123 | // _gather_93: slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15124 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15125 | _gather_93_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15126 | { |
| 15127 | if (p->error_indicator) { |
| 15128 | return NULL; |
| 15129 | } |
| 15130 | asdl_seq * res = NULL; |
| 15131 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15132 | { // slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15133 | expr_ty elem; |
| 15134 | asdl_seq * seq; |
| 15135 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15136 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15137 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15138 | (seq = _loop0_94_rule(p)) // _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15139 | ) |
| 15140 | { |
| 15141 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15142 | goto done; |
| 15143 | } |
| 15144 | p->mark = mark; |
| 15145 | } |
| 15146 | res = NULL; |
| 15147 | done: |
| 15148 | return res; |
| 15149 | } |
| 15150 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15151 | // _tmp_95: ':' expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15152 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15153 | _tmp_95_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15154 | { |
| 15155 | if (p->error_indicator) { |
| 15156 | return NULL; |
| 15157 | } |
| 15158 | void * res = NULL; |
| 15159 | int mark = p->mark; |
| 15160 | { // ':' expression? |
| 15161 | void *d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15162 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15163 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15164 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15165 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15166 | (d = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15167 | ) |
| 15168 | { |
| 15169 | res = d; |
| 15170 | if (res == NULL && PyErr_Occurred()) { |
| 15171 | p->error_indicator = 1; |
| 15172 | return NULL; |
| 15173 | } |
| 15174 | goto done; |
| 15175 | } |
| 15176 | p->mark = mark; |
| 15177 | } |
| 15178 | res = NULL; |
| 15179 | done: |
| 15180 | return res; |
| 15181 | } |
| 15182 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15183 | // _tmp_96: tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15184 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15185 | _tmp_96_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15186 | { |
| 15187 | if (p->error_indicator) { |
| 15188 | return NULL; |
| 15189 | } |
| 15190 | void * res = NULL; |
| 15191 | int mark = p->mark; |
| 15192 | { // tuple |
| 15193 | expr_ty tuple_var; |
| 15194 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15195 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15196 | ) |
| 15197 | { |
| 15198 | res = tuple_var; |
| 15199 | goto done; |
| 15200 | } |
| 15201 | p->mark = mark; |
| 15202 | } |
| 15203 | { // group |
| 15204 | expr_ty group_var; |
| 15205 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15206 | (group_var = group_rule(p)) // group |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15207 | ) |
| 15208 | { |
| 15209 | res = group_var; |
| 15210 | goto done; |
| 15211 | } |
| 15212 | p->mark = mark; |
| 15213 | } |
| 15214 | { // genexp |
| 15215 | expr_ty genexp_var; |
| 15216 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15217 | (genexp_var = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15218 | ) |
| 15219 | { |
| 15220 | res = genexp_var; |
| 15221 | goto done; |
| 15222 | } |
| 15223 | p->mark = mark; |
| 15224 | } |
| 15225 | res = NULL; |
| 15226 | done: |
| 15227 | return res; |
| 15228 | } |
| 15229 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15230 | // _tmp_97: list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15231 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15232 | _tmp_97_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15233 | { |
| 15234 | if (p->error_indicator) { |
| 15235 | return NULL; |
| 15236 | } |
| 15237 | void * res = NULL; |
| 15238 | int mark = p->mark; |
| 15239 | { // list |
| 15240 | expr_ty list_var; |
| 15241 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15242 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15243 | ) |
| 15244 | { |
| 15245 | res = list_var; |
| 15246 | goto done; |
| 15247 | } |
| 15248 | p->mark = mark; |
| 15249 | } |
| 15250 | { // listcomp |
| 15251 | expr_ty listcomp_var; |
| 15252 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15253 | (listcomp_var = listcomp_rule(p)) // listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15254 | ) |
| 15255 | { |
| 15256 | res = listcomp_var; |
| 15257 | goto done; |
| 15258 | } |
| 15259 | p->mark = mark; |
| 15260 | } |
| 15261 | res = NULL; |
| 15262 | done: |
| 15263 | return res; |
| 15264 | } |
| 15265 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15266 | // _tmp_98: dict | set | dictcomp | setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15267 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15268 | _tmp_98_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15269 | { |
| 15270 | if (p->error_indicator) { |
| 15271 | return NULL; |
| 15272 | } |
| 15273 | void * res = NULL; |
| 15274 | int mark = p->mark; |
| 15275 | { // dict |
| 15276 | expr_ty dict_var; |
| 15277 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15278 | (dict_var = dict_rule(p)) // dict |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15279 | ) |
| 15280 | { |
| 15281 | res = dict_var; |
| 15282 | goto done; |
| 15283 | } |
| 15284 | p->mark = mark; |
| 15285 | } |
| 15286 | { // set |
| 15287 | expr_ty set_var; |
| 15288 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15289 | (set_var = set_rule(p)) // set |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15290 | ) |
| 15291 | { |
| 15292 | res = set_var; |
| 15293 | goto done; |
| 15294 | } |
| 15295 | p->mark = mark; |
| 15296 | } |
| 15297 | { // dictcomp |
| 15298 | expr_ty dictcomp_var; |
| 15299 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15300 | (dictcomp_var = dictcomp_rule(p)) // dictcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15301 | ) |
| 15302 | { |
| 15303 | res = dictcomp_var; |
| 15304 | goto done; |
| 15305 | } |
| 15306 | p->mark = mark; |
| 15307 | } |
| 15308 | { // setcomp |
| 15309 | expr_ty setcomp_var; |
| 15310 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15311 | (setcomp_var = setcomp_rule(p)) // setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15312 | ) |
| 15313 | { |
| 15314 | res = setcomp_var; |
| 15315 | goto done; |
| 15316 | } |
| 15317 | p->mark = mark; |
| 15318 | } |
| 15319 | res = NULL; |
| 15320 | done: |
| 15321 | return res; |
| 15322 | } |
| 15323 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15324 | // _loop1_99: STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15325 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15326 | _loop1_99_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15327 | { |
| 15328 | if (p->error_indicator) { |
| 15329 | return NULL; |
| 15330 | } |
| 15331 | void *res = NULL; |
| 15332 | int mark = p->mark; |
| 15333 | int start_mark = p->mark; |
| 15334 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15335 | if (!children) { |
| 15336 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15337 | return NULL; |
| 15338 | } |
| 15339 | ssize_t children_capacity = 1; |
| 15340 | ssize_t n = 0; |
| 15341 | { // STRING |
| 15342 | expr_ty string_var; |
| 15343 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15344 | (string_var = _PyPegen_string_token(p)) // STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15345 | ) |
| 15346 | { |
| 15347 | res = string_var; |
| 15348 | if (n == children_capacity) { |
| 15349 | children_capacity *= 2; |
| 15350 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15351 | if (!children) { |
| 15352 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15353 | return NULL; |
| 15354 | } |
| 15355 | } |
| 15356 | children[n++] = res; |
| 15357 | mark = p->mark; |
| 15358 | } |
| 15359 | p->mark = mark; |
| 15360 | } |
| 15361 | if (n == 0) { |
| 15362 | PyMem_Free(children); |
| 15363 | return NULL; |
| 15364 | } |
| 15365 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15366 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15367 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15368 | PyMem_Free(children); |
| 15369 | return NULL; |
| 15370 | } |
| 15371 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15372 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15373 | _PyPegen_insert_memo(p, start_mark, _loop1_99_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15374 | return seq; |
| 15375 | } |
| 15376 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15377 | // _tmp_100: star_named_expression ',' star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15378 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15379 | _tmp_100_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15380 | { |
| 15381 | if (p->error_indicator) { |
| 15382 | return NULL; |
| 15383 | } |
| 15384 | void * res = NULL; |
| 15385 | int mark = p->mark; |
| 15386 | { // star_named_expression ',' star_named_expressions? |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15387 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15388 | expr_ty y; |
| 15389 | void *z; |
| 15390 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15391 | (y = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15392 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15393 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15394 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15395 | (z = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15396 | ) |
| 15397 | { |
| 15398 | res = _PyPegen_seq_insert_in_front ( p , y , z ); |
| 15399 | if (res == NULL && PyErr_Occurred()) { |
| 15400 | p->error_indicator = 1; |
| 15401 | return NULL; |
| 15402 | } |
| 15403 | goto done; |
| 15404 | } |
| 15405 | p->mark = mark; |
| 15406 | } |
| 15407 | res = NULL; |
| 15408 | done: |
| 15409 | return res; |
| 15410 | } |
| 15411 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15412 | // _tmp_101: yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15413 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15414 | _tmp_101_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15415 | { |
| 15416 | if (p->error_indicator) { |
| 15417 | return NULL; |
| 15418 | } |
| 15419 | void * res = NULL; |
| 15420 | int mark = p->mark; |
| 15421 | { // yield_expr |
| 15422 | expr_ty yield_expr_var; |
| 15423 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15424 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15425 | ) |
| 15426 | { |
| 15427 | res = yield_expr_var; |
| 15428 | goto done; |
| 15429 | } |
| 15430 | p->mark = mark; |
| 15431 | } |
| 15432 | { // named_expression |
| 15433 | expr_ty named_expression_var; |
| 15434 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15435 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15436 | ) |
| 15437 | { |
| 15438 | res = named_expression_var; |
| 15439 | goto done; |
| 15440 | } |
| 15441 | p->mark = mark; |
| 15442 | } |
| 15443 | res = NULL; |
| 15444 | done: |
| 15445 | return res; |
| 15446 | } |
| 15447 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15448 | // _loop0_103: ',' kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15449 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15450 | _loop0_103_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15451 | { |
| 15452 | if (p->error_indicator) { |
| 15453 | return NULL; |
| 15454 | } |
| 15455 | void *res = NULL; |
| 15456 | int mark = p->mark; |
| 15457 | int start_mark = p->mark; |
| 15458 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15459 | if (!children) { |
| 15460 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15461 | return NULL; |
| 15462 | } |
| 15463 | ssize_t children_capacity = 1; |
| 15464 | ssize_t n = 0; |
| 15465 | { // ',' kvpair |
| 15466 | KeyValuePair* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15467 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15468 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15469 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15470 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15471 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15472 | ) |
| 15473 | { |
| 15474 | res = elem; |
| 15475 | if (res == NULL && PyErr_Occurred()) { |
| 15476 | p->error_indicator = 1; |
| 15477 | PyMem_Free(children); |
| 15478 | return NULL; |
| 15479 | } |
| 15480 | if (n == children_capacity) { |
| 15481 | children_capacity *= 2; |
| 15482 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15483 | if (!children) { |
| 15484 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15485 | return NULL; |
| 15486 | } |
| 15487 | } |
| 15488 | children[n++] = res; |
| 15489 | mark = p->mark; |
| 15490 | } |
| 15491 | p->mark = mark; |
| 15492 | } |
| 15493 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15494 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15495 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15496 | PyMem_Free(children); |
| 15497 | return NULL; |
| 15498 | } |
| 15499 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15500 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15501 | _PyPegen_insert_memo(p, start_mark, _loop0_103_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15502 | return seq; |
| 15503 | } |
| 15504 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15505 | // _gather_102: kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15506 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15507 | _gather_102_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15508 | { |
| 15509 | if (p->error_indicator) { |
| 15510 | return NULL; |
| 15511 | } |
| 15512 | asdl_seq * res = NULL; |
| 15513 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15514 | { // kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15515 | KeyValuePair* elem; |
| 15516 | asdl_seq * seq; |
| 15517 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15518 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15519 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15520 | (seq = _loop0_103_rule(p)) // _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15521 | ) |
| 15522 | { |
| 15523 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15524 | goto done; |
| 15525 | } |
| 15526 | p->mark = mark; |
| 15527 | } |
| 15528 | res = NULL; |
| 15529 | done: |
| 15530 | return res; |
| 15531 | } |
| 15532 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15533 | // _loop1_104: for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15534 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15535 | _loop1_104_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15536 | { |
| 15537 | if (p->error_indicator) { |
| 15538 | return NULL; |
| 15539 | } |
| 15540 | void *res = NULL; |
| 15541 | int mark = p->mark; |
| 15542 | int start_mark = p->mark; |
| 15543 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15544 | if (!children) { |
| 15545 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15546 | return NULL; |
| 15547 | } |
| 15548 | ssize_t children_capacity = 1; |
| 15549 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15550 | { // for_if_clause |
| 15551 | comprehension_ty for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15552 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15553 | (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15554 | ) |
| 15555 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15556 | res = for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15557 | if (n == children_capacity) { |
| 15558 | children_capacity *= 2; |
| 15559 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15560 | if (!children) { |
| 15561 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15562 | return NULL; |
| 15563 | } |
| 15564 | } |
| 15565 | children[n++] = res; |
| 15566 | mark = p->mark; |
| 15567 | } |
| 15568 | p->mark = mark; |
| 15569 | } |
| 15570 | if (n == 0) { |
| 15571 | PyMem_Free(children); |
| 15572 | return NULL; |
| 15573 | } |
| 15574 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15575 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15576 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15577 | PyMem_Free(children); |
| 15578 | return NULL; |
| 15579 | } |
| 15580 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15581 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15582 | _PyPegen_insert_memo(p, start_mark, _loop1_104_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15583 | return seq; |
| 15584 | } |
| 15585 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15586 | // _loop0_105: ('if' disjunction) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15587 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15588 | _loop0_105_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15589 | { |
| 15590 | if (p->error_indicator) { |
| 15591 | return NULL; |
| 15592 | } |
| 15593 | void *res = NULL; |
| 15594 | int mark = p->mark; |
| 15595 | int start_mark = p->mark; |
| 15596 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15597 | if (!children) { |
| 15598 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15599 | return NULL; |
| 15600 | } |
| 15601 | ssize_t children_capacity = 1; |
| 15602 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15603 | { // ('if' disjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15604 | void *_tmp_142_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15605 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15606 | (_tmp_142_var = _tmp_142_rule(p)) // 'if' disjunction |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15607 | ) |
| 15608 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15609 | res = _tmp_142_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15610 | if (n == children_capacity) { |
| 15611 | children_capacity *= 2; |
| 15612 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15613 | if (!children) { |
| 15614 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15615 | return NULL; |
| 15616 | } |
| 15617 | } |
| 15618 | children[n++] = res; |
| 15619 | mark = p->mark; |
| 15620 | } |
| 15621 | p->mark = mark; |
| 15622 | } |
| 15623 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15624 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15625 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105"); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15626 | PyMem_Free(children); |
| 15627 | return NULL; |
| 15628 | } |
| 15629 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15630 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15631 | _PyPegen_insert_memo(p, start_mark, _loop0_105_type, seq); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15632 | return seq; |
| 15633 | } |
| 15634 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15635 | // _loop0_106: ('if' disjunction) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15636 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15637 | _loop0_106_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15638 | { |
| 15639 | if (p->error_indicator) { |
| 15640 | return NULL; |
| 15641 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15642 | void *res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15643 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15644 | int start_mark = p->mark; |
| 15645 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15646 | if (!children) { |
| 15647 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15648 | return NULL; |
| 15649 | } |
| 15650 | ssize_t children_capacity = 1; |
| 15651 | ssize_t n = 0; |
| 15652 | { // ('if' disjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15653 | void *_tmp_143_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15654 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15655 | (_tmp_143_var = _tmp_143_rule(p)) // 'if' disjunction |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15656 | ) |
| 15657 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15658 | res = _tmp_143_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15659 | if (n == children_capacity) { |
| 15660 | children_capacity *= 2; |
| 15661 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15662 | if (!children) { |
| 15663 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15664 | return NULL; |
| 15665 | } |
| 15666 | } |
| 15667 | children[n++] = res; |
| 15668 | mark = p->mark; |
| 15669 | } |
| 15670 | p->mark = mark; |
| 15671 | } |
| 15672 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15673 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15674 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106"); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15675 | PyMem_Free(children); |
| 15676 | return NULL; |
| 15677 | } |
| 15678 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15679 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15680 | _PyPegen_insert_memo(p, start_mark, _loop0_106_type, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15681 | return seq; |
| 15682 | } |
| 15683 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15684 | // _tmp_107: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15685 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15686 | _tmp_107_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15687 | { |
| 15688 | if (p->error_indicator) { |
| 15689 | return NULL; |
| 15690 | } |
| 15691 | void * res = NULL; |
| 15692 | int mark = p->mark; |
| 15693 | { // ',' args |
| 15694 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15695 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15696 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15697 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15698 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15699 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15700 | ) |
| 15701 | { |
| 15702 | res = c; |
| 15703 | if (res == NULL && PyErr_Occurred()) { |
| 15704 | p->error_indicator = 1; |
| 15705 | return NULL; |
| 15706 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15707 | goto done; |
| 15708 | } |
| 15709 | p->mark = mark; |
| 15710 | } |
| 15711 | res = NULL; |
| 15712 | done: |
| 15713 | return res; |
| 15714 | } |
| 15715 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15716 | // _tmp_108: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15717 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15718 | _tmp_108_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15719 | { |
| 15720 | if (p->error_indicator) { |
| 15721 | return NULL; |
| 15722 | } |
| 15723 | void * res = NULL; |
| 15724 | int mark = p->mark; |
| 15725 | { // ',' args |
| 15726 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15727 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15728 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15729 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15730 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15731 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15732 | ) |
| 15733 | { |
| 15734 | res = c; |
| 15735 | if (res == NULL && PyErr_Occurred()) { |
| 15736 | p->error_indicator = 1; |
| 15737 | return NULL; |
| 15738 | } |
| 15739 | goto done; |
| 15740 | } |
| 15741 | p->mark = mark; |
| 15742 | } |
| 15743 | res = NULL; |
| 15744 | done: |
| 15745 | return res; |
| 15746 | } |
| 15747 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15748 | // _loop0_110: ',' kwarg_or_starred |
| 15749 | static asdl_seq * |
| 15750 | _loop0_110_rule(Parser *p) |
| 15751 | { |
| 15752 | if (p->error_indicator) { |
| 15753 | return NULL; |
| 15754 | } |
| 15755 | void *res = NULL; |
| 15756 | int mark = p->mark; |
| 15757 | int start_mark = p->mark; |
| 15758 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15759 | if (!children) { |
| 15760 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15761 | return NULL; |
| 15762 | } |
| 15763 | ssize_t children_capacity = 1; |
| 15764 | ssize_t n = 0; |
| 15765 | { // ',' kwarg_or_starred |
| 15766 | KeywordOrStarred* elem; |
| 15767 | Token * literal; |
| 15768 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15769 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15770 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15771 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15772 | ) |
| 15773 | { |
| 15774 | res = elem; |
| 15775 | if (res == NULL && PyErr_Occurred()) { |
| 15776 | p->error_indicator = 1; |
| 15777 | PyMem_Free(children); |
| 15778 | return NULL; |
| 15779 | } |
| 15780 | if (n == children_capacity) { |
| 15781 | children_capacity *= 2; |
| 15782 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15783 | if (!children) { |
| 15784 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15785 | return NULL; |
| 15786 | } |
| 15787 | } |
| 15788 | children[n++] = res; |
| 15789 | mark = p->mark; |
| 15790 | } |
| 15791 | p->mark = mark; |
| 15792 | } |
| 15793 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15794 | if (!seq) { |
| 15795 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110"); |
| 15796 | PyMem_Free(children); |
| 15797 | return NULL; |
| 15798 | } |
| 15799 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15800 | PyMem_Free(children); |
| 15801 | _PyPegen_insert_memo(p, start_mark, _loop0_110_type, seq); |
| 15802 | return seq; |
| 15803 | } |
| 15804 | |
| 15805 | // _gather_109: kwarg_or_starred _loop0_110 |
| 15806 | static asdl_seq * |
| 15807 | _gather_109_rule(Parser *p) |
| 15808 | { |
| 15809 | if (p->error_indicator) { |
| 15810 | return NULL; |
| 15811 | } |
| 15812 | asdl_seq * res = NULL; |
| 15813 | int mark = p->mark; |
| 15814 | { // kwarg_or_starred _loop0_110 |
| 15815 | KeywordOrStarred* elem; |
| 15816 | asdl_seq * seq; |
| 15817 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15818 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15819 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15820 | (seq = _loop0_110_rule(p)) // _loop0_110 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15821 | ) |
| 15822 | { |
| 15823 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15824 | goto done; |
| 15825 | } |
| 15826 | p->mark = mark; |
| 15827 | } |
| 15828 | res = NULL; |
| 15829 | done: |
| 15830 | return res; |
| 15831 | } |
| 15832 | |
| 15833 | // _loop0_112: ',' kwarg_or_double_starred |
| 15834 | static asdl_seq * |
| 15835 | _loop0_112_rule(Parser *p) |
| 15836 | { |
| 15837 | if (p->error_indicator) { |
| 15838 | return NULL; |
| 15839 | } |
| 15840 | void *res = NULL; |
| 15841 | int mark = p->mark; |
| 15842 | int start_mark = p->mark; |
| 15843 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15844 | if (!children) { |
| 15845 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15846 | return NULL; |
| 15847 | } |
| 15848 | ssize_t children_capacity = 1; |
| 15849 | ssize_t n = 0; |
| 15850 | { // ',' kwarg_or_double_starred |
| 15851 | KeywordOrStarred* elem; |
| 15852 | Token * literal; |
| 15853 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15854 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15855 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15856 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15857 | ) |
| 15858 | { |
| 15859 | res = elem; |
| 15860 | if (res == NULL && PyErr_Occurred()) { |
| 15861 | p->error_indicator = 1; |
| 15862 | PyMem_Free(children); |
| 15863 | return NULL; |
| 15864 | } |
| 15865 | if (n == children_capacity) { |
| 15866 | children_capacity *= 2; |
| 15867 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15868 | if (!children) { |
| 15869 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15870 | return NULL; |
| 15871 | } |
| 15872 | } |
| 15873 | children[n++] = res; |
| 15874 | mark = p->mark; |
| 15875 | } |
| 15876 | p->mark = mark; |
| 15877 | } |
| 15878 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15879 | if (!seq) { |
| 15880 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112"); |
| 15881 | PyMem_Free(children); |
| 15882 | return NULL; |
| 15883 | } |
| 15884 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15885 | PyMem_Free(children); |
| 15886 | _PyPegen_insert_memo(p, start_mark, _loop0_112_type, seq); |
| 15887 | return seq; |
| 15888 | } |
| 15889 | |
| 15890 | // _gather_111: kwarg_or_double_starred _loop0_112 |
| 15891 | static asdl_seq * |
| 15892 | _gather_111_rule(Parser *p) |
| 15893 | { |
| 15894 | if (p->error_indicator) { |
| 15895 | return NULL; |
| 15896 | } |
| 15897 | asdl_seq * res = NULL; |
| 15898 | int mark = p->mark; |
| 15899 | { // kwarg_or_double_starred _loop0_112 |
| 15900 | KeywordOrStarred* elem; |
| 15901 | asdl_seq * seq; |
| 15902 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15903 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15904 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15905 | (seq = _loop0_112_rule(p)) // _loop0_112 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15906 | ) |
| 15907 | { |
| 15908 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15909 | goto done; |
| 15910 | } |
| 15911 | p->mark = mark; |
| 15912 | } |
| 15913 | res = NULL; |
| 15914 | done: |
| 15915 | return res; |
| 15916 | } |
| 15917 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15918 | // _loop0_114: ',' kwarg_or_starred |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15919 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15920 | _loop0_114_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15921 | { |
| 15922 | if (p->error_indicator) { |
| 15923 | return NULL; |
| 15924 | } |
| 15925 | void *res = NULL; |
| 15926 | int mark = p->mark; |
| 15927 | int start_mark = p->mark; |
| 15928 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15929 | if (!children) { |
| 15930 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15931 | return NULL; |
| 15932 | } |
| 15933 | ssize_t children_capacity = 1; |
| 15934 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15935 | { // ',' kwarg_or_starred |
| 15936 | KeywordOrStarred* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15937 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15938 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15939 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15940 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15941 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15942 | ) |
| 15943 | { |
| 15944 | res = elem; |
| 15945 | if (res == NULL && PyErr_Occurred()) { |
| 15946 | p->error_indicator = 1; |
| 15947 | PyMem_Free(children); |
| 15948 | return NULL; |
| 15949 | } |
| 15950 | if (n == children_capacity) { |
| 15951 | children_capacity *= 2; |
| 15952 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15953 | if (!children) { |
| 15954 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15955 | return NULL; |
| 15956 | } |
| 15957 | } |
| 15958 | children[n++] = res; |
| 15959 | mark = p->mark; |
| 15960 | } |
| 15961 | p->mark = mark; |
| 15962 | } |
| 15963 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15964 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15965 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15966 | PyMem_Free(children); |
| 15967 | return NULL; |
| 15968 | } |
| 15969 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15970 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15971 | _PyPegen_insert_memo(p, start_mark, _loop0_114_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15972 | return seq; |
| 15973 | } |
| 15974 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15975 | // _gather_113: kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15976 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15977 | _gather_113_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15978 | { |
| 15979 | if (p->error_indicator) { |
| 15980 | return NULL; |
| 15981 | } |
| 15982 | asdl_seq * res = NULL; |
| 15983 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15984 | { // kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15985 | KeywordOrStarred* elem; |
| 15986 | asdl_seq * seq; |
| 15987 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15988 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15989 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15990 | (seq = _loop0_114_rule(p)) // _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15991 | ) |
| 15992 | { |
| 15993 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15994 | goto done; |
| 15995 | } |
| 15996 | p->mark = mark; |
| 15997 | } |
| 15998 | res = NULL; |
| 15999 | done: |
| 16000 | return res; |
| 16001 | } |
| 16002 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16003 | // _loop0_116: ',' kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16004 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16005 | _loop0_116_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16006 | { |
| 16007 | if (p->error_indicator) { |
| 16008 | return NULL; |
| 16009 | } |
| 16010 | void *res = NULL; |
| 16011 | int mark = p->mark; |
| 16012 | int start_mark = p->mark; |
| 16013 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16014 | if (!children) { |
| 16015 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16016 | return NULL; |
| 16017 | } |
| 16018 | ssize_t children_capacity = 1; |
| 16019 | ssize_t n = 0; |
| 16020 | { // ',' kwarg_or_double_starred |
| 16021 | KeywordOrStarred* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16022 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16023 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16024 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16025 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16026 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16027 | ) |
| 16028 | { |
| 16029 | res = elem; |
| 16030 | if (res == NULL && PyErr_Occurred()) { |
| 16031 | p->error_indicator = 1; |
| 16032 | PyMem_Free(children); |
| 16033 | return NULL; |
| 16034 | } |
| 16035 | if (n == children_capacity) { |
| 16036 | children_capacity *= 2; |
| 16037 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16038 | if (!children) { |
| 16039 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16040 | return NULL; |
| 16041 | } |
| 16042 | } |
| 16043 | children[n++] = res; |
| 16044 | mark = p->mark; |
| 16045 | } |
| 16046 | p->mark = mark; |
| 16047 | } |
| 16048 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16049 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16050 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16051 | PyMem_Free(children); |
| 16052 | return NULL; |
| 16053 | } |
| 16054 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16055 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16056 | _PyPegen_insert_memo(p, start_mark, _loop0_116_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16057 | return seq; |
| 16058 | } |
| 16059 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16060 | // _gather_115: kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16061 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16062 | _gather_115_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16063 | { |
| 16064 | if (p->error_indicator) { |
| 16065 | return NULL; |
| 16066 | } |
| 16067 | asdl_seq * res = NULL; |
| 16068 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16069 | { // kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16070 | KeywordOrStarred* elem; |
| 16071 | asdl_seq * seq; |
| 16072 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16073 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16074 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16075 | (seq = _loop0_116_rule(p)) // _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16076 | ) |
| 16077 | { |
| 16078 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16079 | goto done; |
| 16080 | } |
| 16081 | p->mark = mark; |
| 16082 | } |
| 16083 | res = NULL; |
| 16084 | done: |
| 16085 | return res; |
| 16086 | } |
| 16087 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16088 | // _loop0_117: (',' star_target) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16089 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16090 | _loop0_117_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16091 | { |
| 16092 | if (p->error_indicator) { |
| 16093 | return NULL; |
| 16094 | } |
| 16095 | void *res = NULL; |
| 16096 | int mark = p->mark; |
| 16097 | int start_mark = p->mark; |
| 16098 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16099 | if (!children) { |
| 16100 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16101 | return NULL; |
| 16102 | } |
| 16103 | ssize_t children_capacity = 1; |
| 16104 | ssize_t n = 0; |
| 16105 | { // (',' star_target) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16106 | void *_tmp_144_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16107 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16108 | (_tmp_144_var = _tmp_144_rule(p)) // ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16109 | ) |
| 16110 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16111 | res = _tmp_144_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16112 | if (n == children_capacity) { |
| 16113 | children_capacity *= 2; |
| 16114 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16115 | if (!children) { |
| 16116 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16117 | return NULL; |
| 16118 | } |
| 16119 | } |
| 16120 | children[n++] = res; |
| 16121 | mark = p->mark; |
| 16122 | } |
| 16123 | p->mark = mark; |
| 16124 | } |
| 16125 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16126 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16127 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117"); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16128 | PyMem_Free(children); |
| 16129 | return NULL; |
| 16130 | } |
| 16131 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16132 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16133 | _PyPegen_insert_memo(p, start_mark, _loop0_117_type, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16134 | return seq; |
| 16135 | } |
| 16136 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16137 | // _loop0_119: ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16138 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16139 | _loop0_119_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16140 | { |
| 16141 | if (p->error_indicator) { |
| 16142 | return NULL; |
| 16143 | } |
| 16144 | void *res = NULL; |
| 16145 | int mark = p->mark; |
| 16146 | int start_mark = p->mark; |
| 16147 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16148 | if (!children) { |
| 16149 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16150 | return NULL; |
| 16151 | } |
| 16152 | ssize_t children_capacity = 1; |
| 16153 | ssize_t n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16154 | { // ',' star_target |
| 16155 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16156 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16157 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16158 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16159 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16160 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16161 | ) |
| 16162 | { |
| 16163 | res = elem; |
| 16164 | if (res == NULL && PyErr_Occurred()) { |
| 16165 | p->error_indicator = 1; |
| 16166 | PyMem_Free(children); |
| 16167 | return NULL; |
| 16168 | } |
| 16169 | if (n == children_capacity) { |
| 16170 | children_capacity *= 2; |
| 16171 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16172 | if (!children) { |
| 16173 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16174 | return NULL; |
| 16175 | } |
| 16176 | } |
| 16177 | children[n++] = res; |
| 16178 | mark = p->mark; |
| 16179 | } |
| 16180 | p->mark = mark; |
| 16181 | } |
| 16182 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16183 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16184 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16185 | PyMem_Free(children); |
| 16186 | return NULL; |
| 16187 | } |
| 16188 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16189 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16190 | _PyPegen_insert_memo(p, start_mark, _loop0_119_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16191 | return seq; |
| 16192 | } |
| 16193 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16194 | // _gather_118: star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16195 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16196 | _gather_118_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16197 | { |
| 16198 | if (p->error_indicator) { |
| 16199 | return NULL; |
| 16200 | } |
| 16201 | asdl_seq * res = NULL; |
| 16202 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16203 | { // star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16204 | expr_ty elem; |
| 16205 | asdl_seq * seq; |
| 16206 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16207 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16208 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16209 | (seq = _loop0_119_rule(p)) // _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16210 | ) |
| 16211 | { |
| 16212 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16213 | goto done; |
| 16214 | } |
| 16215 | p->mark = mark; |
| 16216 | } |
| 16217 | res = NULL; |
| 16218 | done: |
| 16219 | return res; |
| 16220 | } |
| 16221 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16222 | // _tmp_120: !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16223 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16224 | _tmp_120_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16225 | { |
| 16226 | if (p->error_indicator) { |
| 16227 | return NULL; |
| 16228 | } |
| 16229 | void * res = NULL; |
| 16230 | int mark = p->mark; |
| 16231 | { // !'*' star_target |
| 16232 | expr_ty star_target_var; |
| 16233 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16234 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16235 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16236 | (star_target_var = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16237 | ) |
| 16238 | { |
| 16239 | res = star_target_var; |
| 16240 | goto done; |
| 16241 | } |
| 16242 | p->mark = mark; |
| 16243 | } |
| 16244 | res = NULL; |
| 16245 | done: |
| 16246 | return res; |
| 16247 | } |
| 16248 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16249 | // _loop0_122: ',' del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16250 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16251 | _loop0_122_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16252 | { |
| 16253 | if (p->error_indicator) { |
| 16254 | return NULL; |
| 16255 | } |
| 16256 | void *res = NULL; |
| 16257 | int mark = p->mark; |
| 16258 | int start_mark = p->mark; |
| 16259 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16260 | if (!children) { |
| 16261 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16262 | return NULL; |
| 16263 | } |
| 16264 | ssize_t children_capacity = 1; |
| 16265 | ssize_t n = 0; |
| 16266 | { // ',' del_target |
| 16267 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16268 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16269 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16270 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16271 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16272 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16273 | ) |
| 16274 | { |
| 16275 | res = elem; |
| 16276 | if (res == NULL && PyErr_Occurred()) { |
| 16277 | p->error_indicator = 1; |
| 16278 | PyMem_Free(children); |
| 16279 | return NULL; |
| 16280 | } |
| 16281 | if (n == children_capacity) { |
| 16282 | children_capacity *= 2; |
| 16283 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16284 | if (!children) { |
| 16285 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16286 | return NULL; |
| 16287 | } |
| 16288 | } |
| 16289 | children[n++] = res; |
| 16290 | mark = p->mark; |
| 16291 | } |
| 16292 | p->mark = mark; |
| 16293 | } |
| 16294 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16295 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16296 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16297 | PyMem_Free(children); |
| 16298 | return NULL; |
| 16299 | } |
| 16300 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16301 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16302 | _PyPegen_insert_memo(p, start_mark, _loop0_122_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16303 | return seq; |
| 16304 | } |
| 16305 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16306 | // _gather_121: del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16307 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16308 | _gather_121_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16309 | { |
| 16310 | if (p->error_indicator) { |
| 16311 | return NULL; |
| 16312 | } |
| 16313 | asdl_seq * res = NULL; |
| 16314 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16315 | { // del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16316 | expr_ty elem; |
| 16317 | asdl_seq * seq; |
| 16318 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16319 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16320 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16321 | (seq = _loop0_122_rule(p)) // _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16322 | ) |
| 16323 | { |
| 16324 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16325 | goto done; |
| 16326 | } |
| 16327 | p->mark = mark; |
| 16328 | } |
| 16329 | res = NULL; |
| 16330 | done: |
| 16331 | return res; |
| 16332 | } |
| 16333 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16334 | // _loop0_124: ',' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16335 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16336 | _loop0_124_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16337 | { |
| 16338 | if (p->error_indicator) { |
| 16339 | return NULL; |
| 16340 | } |
| 16341 | void *res = NULL; |
| 16342 | int mark = p->mark; |
| 16343 | int start_mark = p->mark; |
| 16344 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16345 | if (!children) { |
| 16346 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16347 | return NULL; |
| 16348 | } |
| 16349 | ssize_t children_capacity = 1; |
| 16350 | ssize_t n = 0; |
| 16351 | { // ',' target |
| 16352 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16353 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16354 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16355 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16356 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16357 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16358 | ) |
| 16359 | { |
| 16360 | res = elem; |
| 16361 | if (res == NULL && PyErr_Occurred()) { |
| 16362 | p->error_indicator = 1; |
| 16363 | PyMem_Free(children); |
| 16364 | return NULL; |
| 16365 | } |
| 16366 | if (n == children_capacity) { |
| 16367 | children_capacity *= 2; |
| 16368 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16369 | if (!children) { |
| 16370 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16371 | return NULL; |
| 16372 | } |
| 16373 | } |
| 16374 | children[n++] = res; |
| 16375 | mark = p->mark; |
| 16376 | } |
| 16377 | p->mark = mark; |
| 16378 | } |
| 16379 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16380 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16381 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16382 | PyMem_Free(children); |
| 16383 | return NULL; |
| 16384 | } |
| 16385 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16386 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16387 | _PyPegen_insert_memo(p, start_mark, _loop0_124_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16388 | return seq; |
| 16389 | } |
| 16390 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16391 | // _gather_123: target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16392 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16393 | _gather_123_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16394 | { |
| 16395 | if (p->error_indicator) { |
| 16396 | return NULL; |
| 16397 | } |
| 16398 | asdl_seq * res = NULL; |
| 16399 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16400 | { // target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16401 | expr_ty elem; |
| 16402 | asdl_seq * seq; |
| 16403 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16404 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16405 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16406 | (seq = _loop0_124_rule(p)) // _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16407 | ) |
| 16408 | { |
| 16409 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16410 | goto done; |
| 16411 | } |
| 16412 | p->mark = mark; |
| 16413 | } |
| 16414 | res = NULL; |
| 16415 | done: |
| 16416 | return res; |
| 16417 | } |
| 16418 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16419 | // _tmp_125: args | expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16420 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16421 | _tmp_125_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16422 | { |
| 16423 | if (p->error_indicator) { |
| 16424 | return NULL; |
| 16425 | } |
| 16426 | void * res = NULL; |
| 16427 | int mark = p->mark; |
| 16428 | { // args |
| 16429 | expr_ty args_var; |
| 16430 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16431 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16432 | ) |
| 16433 | { |
| 16434 | res = args_var; |
| 16435 | goto done; |
| 16436 | } |
| 16437 | p->mark = mark; |
| 16438 | } |
| 16439 | { // expression for_if_clauses |
| 16440 | expr_ty expression_var; |
| 16441 | asdl_seq* for_if_clauses_var; |
| 16442 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16443 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16444 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16445 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16446 | ) |
| 16447 | { |
| 16448 | res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); |
| 16449 | goto done; |
| 16450 | } |
| 16451 | p->mark = mark; |
| 16452 | } |
| 16453 | res = NULL; |
| 16454 | done: |
| 16455 | return res; |
| 16456 | } |
| 16457 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16458 | // _tmp_126: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16459 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16460 | _tmp_126_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16461 | { |
| 16462 | if (p->error_indicator) { |
| 16463 | return NULL; |
| 16464 | } |
| 16465 | void * res = NULL; |
| 16466 | int mark = p->mark; |
| 16467 | { // '=' annotated_rhs |
| 16468 | expr_ty annotated_rhs_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16469 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16470 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16471 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16472 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16473 | (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16474 | ) |
| 16475 | { |
| 16476 | res = _PyPegen_dummy_name(p, literal, annotated_rhs_var); |
| 16477 | goto done; |
| 16478 | } |
| 16479 | p->mark = mark; |
| 16480 | } |
| 16481 | res = NULL; |
| 16482 | done: |
| 16483 | return res; |
| 16484 | } |
| 16485 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16486 | // _tmp_127: '=' | augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16487 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16488 | _tmp_127_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16489 | { |
| 16490 | if (p->error_indicator) { |
| 16491 | return NULL; |
| 16492 | } |
| 16493 | void * res = NULL; |
| 16494 | int mark = p->mark; |
| 16495 | { // '=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16496 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16497 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16498 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16499 | ) |
| 16500 | { |
| 16501 | res = literal; |
| 16502 | goto done; |
| 16503 | } |
| 16504 | p->mark = mark; |
| 16505 | } |
| 16506 | { // augassign |
| 16507 | AugOperator* augassign_var; |
| 16508 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16509 | (augassign_var = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16510 | ) |
| 16511 | { |
| 16512 | res = augassign_var; |
| 16513 | goto done; |
| 16514 | } |
| 16515 | p->mark = mark; |
| 16516 | } |
| 16517 | res = NULL; |
| 16518 | done: |
| 16519 | return res; |
| 16520 | } |
| 16521 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16522 | // _tmp_128: yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16523 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16524 | _tmp_128_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16525 | { |
| 16526 | if (p->error_indicator) { |
| 16527 | return NULL; |
| 16528 | } |
| 16529 | void * res = NULL; |
| 16530 | int mark = p->mark; |
| 16531 | { // yield_expr |
| 16532 | expr_ty yield_expr_var; |
| 16533 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16534 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16535 | ) |
| 16536 | { |
| 16537 | res = yield_expr_var; |
| 16538 | goto done; |
| 16539 | } |
| 16540 | p->mark = mark; |
| 16541 | } |
| 16542 | { // star_expressions |
| 16543 | expr_ty star_expressions_var; |
| 16544 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16545 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16546 | ) |
| 16547 | { |
| 16548 | res = star_expressions_var; |
| 16549 | goto done; |
| 16550 | } |
| 16551 | p->mark = mark; |
| 16552 | } |
| 16553 | res = NULL; |
| 16554 | done: |
| 16555 | return res; |
| 16556 | } |
| 16557 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16558 | // _tmp_129: '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16559 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16560 | _tmp_129_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16561 | { |
| 16562 | if (p->error_indicator) { |
| 16563 | return NULL; |
| 16564 | } |
| 16565 | void * res = NULL; |
| 16566 | int mark = p->mark; |
| 16567 | { // '[' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16568 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16569 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16570 | (literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16571 | ) |
| 16572 | { |
| 16573 | res = literal; |
| 16574 | goto done; |
| 16575 | } |
| 16576 | p->mark = mark; |
| 16577 | } |
| 16578 | { // '(' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16579 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16580 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16581 | (literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16582 | ) |
| 16583 | { |
| 16584 | res = literal; |
| 16585 | goto done; |
| 16586 | } |
| 16587 | p->mark = mark; |
| 16588 | } |
| 16589 | { // '{' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16590 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16591 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16592 | (literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16593 | ) |
| 16594 | { |
| 16595 | res = literal; |
| 16596 | goto done; |
| 16597 | } |
| 16598 | p->mark = mark; |
| 16599 | } |
| 16600 | res = NULL; |
| 16601 | done: |
| 16602 | return res; |
| 16603 | } |
| 16604 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16605 | // _loop0_130: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16606 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16607 | _loop0_130_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16608 | { |
| 16609 | if (p->error_indicator) { |
| 16610 | return NULL; |
| 16611 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16612 | void *res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16613 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16614 | int start_mark = p->mark; |
| 16615 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16616 | if (!children) { |
| 16617 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16618 | return NULL; |
| 16619 | } |
| 16620 | ssize_t children_capacity = 1; |
| 16621 | ssize_t n = 0; |
| 16622 | { // param_no_default |
| 16623 | arg_ty param_no_default_var; |
| 16624 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16625 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16626 | ) |
| 16627 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16628 | res = param_no_default_var; |
| 16629 | if (n == children_capacity) { |
| 16630 | children_capacity *= 2; |
| 16631 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16632 | if (!children) { |
| 16633 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16634 | return NULL; |
| 16635 | } |
| 16636 | } |
| 16637 | children[n++] = res; |
| 16638 | mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16639 | } |
| 16640 | p->mark = mark; |
| 16641 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16642 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16643 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16644 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_130"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16645 | PyMem_Free(children); |
| 16646 | return NULL; |
| 16647 | } |
| 16648 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16649 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16650 | _PyPegen_insert_memo(p, start_mark, _loop0_130_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16651 | return seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16652 | } |
| 16653 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16654 | // _tmp_131: slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16655 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16656 | _tmp_131_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16657 | { |
| 16658 | if (p->error_indicator) { |
| 16659 | return NULL; |
| 16660 | } |
| 16661 | void * res = NULL; |
| 16662 | int mark = p->mark; |
| 16663 | { // slash_with_default |
| 16664 | SlashWithDefault* slash_with_default_var; |
| 16665 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16666 | (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16667 | ) |
| 16668 | { |
| 16669 | res = slash_with_default_var; |
| 16670 | goto done; |
| 16671 | } |
| 16672 | p->mark = mark; |
| 16673 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16674 | { // param_with_default+ |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16675 | asdl_seq * _loop1_145_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16676 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16677 | (_loop1_145_var = _loop1_145_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16678 | ) |
| 16679 | { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16680 | res = _loop1_145_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16681 | goto done; |
| 16682 | } |
| 16683 | p->mark = mark; |
| 16684 | } |
| 16685 | res = NULL; |
| 16686 | done: |
| 16687 | return res; |
| 16688 | } |
| 16689 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16690 | // _tmp_132: ')' | ',' (')' | '**') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16691 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16692 | _tmp_132_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16693 | { |
| 16694 | if (p->error_indicator) { |
| 16695 | return NULL; |
| 16696 | } |
| 16697 | void * res = NULL; |
| 16698 | int mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16699 | { // ')' |
| 16700 | Token * literal; |
| 16701 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16702 | (literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16703 | ) |
| 16704 | { |
| 16705 | res = literal; |
| 16706 | goto done; |
| 16707 | } |
| 16708 | p->mark = mark; |
| 16709 | } |
| 16710 | { // ',' (')' | '**') |
| 16711 | void *_tmp_146_var; |
| 16712 | Token * literal; |
| 16713 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16714 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16715 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16716 | (_tmp_146_var = _tmp_146_rule(p)) // ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16717 | ) |
| 16718 | { |
| 16719 | res = _PyPegen_dummy_name(p, literal, _tmp_146_var); |
| 16720 | goto done; |
| 16721 | } |
| 16722 | p->mark = mark; |
| 16723 | } |
| 16724 | res = NULL; |
| 16725 | done: |
| 16726 | return res; |
| 16727 | } |
| 16728 | |
| 16729 | // _tmp_133: ':' | ',' (':' | '**') |
| 16730 | static void * |
| 16731 | _tmp_133_rule(Parser *p) |
| 16732 | { |
| 16733 | if (p->error_indicator) { |
| 16734 | return NULL; |
| 16735 | } |
| 16736 | void * res = NULL; |
| 16737 | int mark = p->mark; |
| 16738 | { // ':' |
| 16739 | Token * literal; |
| 16740 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16741 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16742 | ) |
| 16743 | { |
| 16744 | res = literal; |
| 16745 | goto done; |
| 16746 | } |
| 16747 | p->mark = mark; |
| 16748 | } |
| 16749 | { // ',' (':' | '**') |
| 16750 | void *_tmp_147_var; |
| 16751 | Token * literal; |
| 16752 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16753 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16754 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16755 | (_tmp_147_var = _tmp_147_rule(p)) // ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16756 | ) |
| 16757 | { |
| 16758 | res = _PyPegen_dummy_name(p, literal, _tmp_147_var); |
| 16759 | goto done; |
| 16760 | } |
| 16761 | p->mark = mark; |
| 16762 | } |
| 16763 | res = NULL; |
| 16764 | done: |
| 16765 | return res; |
| 16766 | } |
| 16767 | |
| 16768 | // _tmp_134: star_targets '=' |
| 16769 | static void * |
| 16770 | _tmp_134_rule(Parser *p) |
| 16771 | { |
| 16772 | if (p->error_indicator) { |
| 16773 | return NULL; |
| 16774 | } |
| 16775 | void * res = NULL; |
| 16776 | int mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16777 | { // star_targets '=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16778 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16779 | expr_ty z; |
| 16780 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16781 | (z = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16782 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16783 | (literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16784 | ) |
| 16785 | { |
| 16786 | res = z; |
| 16787 | if (res == NULL && PyErr_Occurred()) { |
| 16788 | p->error_indicator = 1; |
| 16789 | return NULL; |
| 16790 | } |
| 16791 | goto done; |
| 16792 | } |
| 16793 | p->mark = mark; |
| 16794 | } |
| 16795 | res = NULL; |
| 16796 | done: |
| 16797 | return res; |
| 16798 | } |
| 16799 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16800 | // _tmp_135: '.' | '...' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16801 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16802 | _tmp_135_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16803 | { |
| 16804 | if (p->error_indicator) { |
| 16805 | return NULL; |
| 16806 | } |
| 16807 | void * res = NULL; |
| 16808 | int mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16809 | { // '.' |
| 16810 | Token * literal; |
| 16811 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16812 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16813 | ) |
| 16814 | { |
| 16815 | res = literal; |
| 16816 | goto done; |
| 16817 | } |
| 16818 | p->mark = mark; |
| 16819 | } |
| 16820 | { // '...' |
| 16821 | Token * literal; |
| 16822 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16823 | (literal = _PyPegen_expect_token(p, 52)) // token='...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16824 | ) |
| 16825 | { |
| 16826 | res = literal; |
| 16827 | goto done; |
| 16828 | } |
| 16829 | p->mark = mark; |
| 16830 | } |
| 16831 | res = NULL; |
| 16832 | done: |
| 16833 | return res; |
| 16834 | } |
| 16835 | |
| 16836 | // _tmp_136: '.' | '...' |
| 16837 | static void * |
| 16838 | _tmp_136_rule(Parser *p) |
| 16839 | { |
| 16840 | if (p->error_indicator) { |
| 16841 | return NULL; |
| 16842 | } |
| 16843 | void * res = NULL; |
| 16844 | int mark = p->mark; |
| 16845 | { // '.' |
| 16846 | Token * literal; |
| 16847 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16848 | (literal = _PyPegen_expect_token(p, 23)) // token='.' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16849 | ) |
| 16850 | { |
| 16851 | res = literal; |
| 16852 | goto done; |
| 16853 | } |
| 16854 | p->mark = mark; |
| 16855 | } |
| 16856 | { // '...' |
| 16857 | Token * literal; |
| 16858 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16859 | (literal = _PyPegen_expect_token(p, 52)) // token='...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16860 | ) |
| 16861 | { |
| 16862 | res = literal; |
| 16863 | goto done; |
| 16864 | } |
| 16865 | p->mark = mark; |
| 16866 | } |
| 16867 | res = NULL; |
| 16868 | done: |
| 16869 | return res; |
| 16870 | } |
| 16871 | |
| 16872 | // _tmp_137: '@' named_expression NEWLINE |
| 16873 | static void * |
| 16874 | _tmp_137_rule(Parser *p) |
| 16875 | { |
| 16876 | if (p->error_indicator) { |
| 16877 | return NULL; |
| 16878 | } |
| 16879 | void * res = NULL; |
| 16880 | int mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16881 | { // '@' named_expression NEWLINE |
| 16882 | expr_ty f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16883 | Token * literal; |
| 16884 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16885 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16886 | (literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16887 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16888 | (f = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16889 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16890 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16891 | ) |
| 16892 | { |
| 16893 | res = f; |
| 16894 | if (res == NULL && PyErr_Occurred()) { |
| 16895 | p->error_indicator = 1; |
| 16896 | return NULL; |
| 16897 | } |
| 16898 | goto done; |
| 16899 | } |
| 16900 | p->mark = mark; |
| 16901 | } |
| 16902 | res = NULL; |
| 16903 | done: |
| 16904 | return res; |
| 16905 | } |
| 16906 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16907 | // _tmp_138: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16908 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16909 | _tmp_138_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16910 | { |
| 16911 | if (p->error_indicator) { |
| 16912 | return NULL; |
| 16913 | } |
| 16914 | void * res = NULL; |
| 16915 | int mark = p->mark; |
| 16916 | { // ',' star_expression |
| 16917 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16918 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16919 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16920 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16921 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16922 | (c = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16923 | ) |
| 16924 | { |
| 16925 | res = c; |
| 16926 | if (res == NULL && PyErr_Occurred()) { |
| 16927 | p->error_indicator = 1; |
| 16928 | return NULL; |
| 16929 | } |
| 16930 | goto done; |
| 16931 | } |
| 16932 | p->mark = mark; |
| 16933 | } |
| 16934 | res = NULL; |
| 16935 | done: |
| 16936 | return res; |
| 16937 | } |
| 16938 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16939 | // _tmp_139: ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16940 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16941 | _tmp_139_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16942 | { |
| 16943 | if (p->error_indicator) { |
| 16944 | return NULL; |
| 16945 | } |
| 16946 | void * res = NULL; |
| 16947 | int mark = p->mark; |
| 16948 | { // ',' expression |
| 16949 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16950 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16951 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16952 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16953 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16954 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16955 | ) |
| 16956 | { |
| 16957 | res = c; |
| 16958 | if (res == NULL && PyErr_Occurred()) { |
| 16959 | p->error_indicator = 1; |
| 16960 | return NULL; |
| 16961 | } |
| 16962 | goto done; |
| 16963 | } |
| 16964 | p->mark = mark; |
| 16965 | } |
| 16966 | res = NULL; |
| 16967 | done: |
| 16968 | return res; |
| 16969 | } |
| 16970 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16971 | // _tmp_140: 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16972 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16973 | _tmp_140_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16974 | { |
| 16975 | if (p->error_indicator) { |
| 16976 | return NULL; |
| 16977 | } |
| 16978 | void * res = NULL; |
| 16979 | int mark = p->mark; |
| 16980 | { // 'or' conjunction |
| 16981 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16982 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16983 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16984 | (keyword = _PyPegen_expect_token(p, 532)) // token='or' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16985 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16986 | (c = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16987 | ) |
| 16988 | { |
| 16989 | res = c; |
| 16990 | if (res == NULL && PyErr_Occurred()) { |
| 16991 | p->error_indicator = 1; |
| 16992 | return NULL; |
| 16993 | } |
| 16994 | goto done; |
| 16995 | } |
| 16996 | p->mark = mark; |
| 16997 | } |
| 16998 | res = NULL; |
| 16999 | done: |
| 17000 | return res; |
| 17001 | } |
| 17002 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17003 | // _tmp_141: 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17004 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17005 | _tmp_141_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17006 | { |
| 17007 | if (p->error_indicator) { |
| 17008 | return NULL; |
| 17009 | } |
| 17010 | void * res = NULL; |
| 17011 | int mark = p->mark; |
| 17012 | { // 'and' inversion |
| 17013 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 17014 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17015 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17016 | (keyword = _PyPegen_expect_token(p, 533)) // token='and' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17017 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17018 | (c = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17019 | ) |
| 17020 | { |
| 17021 | res = c; |
| 17022 | if (res == NULL && PyErr_Occurred()) { |
| 17023 | p->error_indicator = 1; |
| 17024 | return NULL; |
| 17025 | } |
| 17026 | goto done; |
| 17027 | } |
| 17028 | p->mark = mark; |
| 17029 | } |
| 17030 | res = NULL; |
| 17031 | done: |
| 17032 | return res; |
| 17033 | } |
| 17034 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17035 | // _tmp_142: 'if' disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17036 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17037 | _tmp_142_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17038 | { |
| 17039 | if (p->error_indicator) { |
| 17040 | return NULL; |
| 17041 | } |
| 17042 | void * res = NULL; |
| 17043 | int mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17044 | { // 'if' disjunction |
| 17045 | Token * keyword; |
| 17046 | expr_ty z; |
| 17047 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17048 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17049 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17050 | (z = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17051 | ) |
| 17052 | { |
| 17053 | res = z; |
| 17054 | if (res == NULL && PyErr_Occurred()) { |
| 17055 | p->error_indicator = 1; |
| 17056 | return NULL; |
| 17057 | } |
| 17058 | goto done; |
| 17059 | } |
| 17060 | p->mark = mark; |
| 17061 | } |
| 17062 | res = NULL; |
| 17063 | done: |
| 17064 | return res; |
| 17065 | } |
| 17066 | |
| 17067 | // _tmp_143: 'if' disjunction |
| 17068 | static void * |
| 17069 | _tmp_143_rule(Parser *p) |
| 17070 | { |
| 17071 | if (p->error_indicator) { |
| 17072 | return NULL; |
| 17073 | } |
| 17074 | void * res = NULL; |
| 17075 | int mark = p->mark; |
| 17076 | { // 'if' disjunction |
| 17077 | Token * keyword; |
| 17078 | expr_ty z; |
| 17079 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17080 | (keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17081 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17082 | (z = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17083 | ) |
| 17084 | { |
| 17085 | res = z; |
| 17086 | if (res == NULL && PyErr_Occurred()) { |
| 17087 | p->error_indicator = 1; |
| 17088 | return NULL; |
| 17089 | } |
| 17090 | goto done; |
| 17091 | } |
| 17092 | p->mark = mark; |
| 17093 | } |
| 17094 | res = NULL; |
| 17095 | done: |
| 17096 | return res; |
| 17097 | } |
| 17098 | |
| 17099 | // _tmp_144: ',' star_target |
| 17100 | static void * |
| 17101 | _tmp_144_rule(Parser *p) |
| 17102 | { |
| 17103 | if (p->error_indicator) { |
| 17104 | return NULL; |
| 17105 | } |
| 17106 | void * res = NULL; |
| 17107 | int mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17108 | { // ',' star_target |
| 17109 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 17110 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17111 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17112 | (literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17113 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17114 | (c = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17115 | ) |
| 17116 | { |
| 17117 | res = c; |
| 17118 | if (res == NULL && PyErr_Occurred()) { |
| 17119 | p->error_indicator = 1; |
| 17120 | return NULL; |
| 17121 | } |
| 17122 | goto done; |
| 17123 | } |
| 17124 | p->mark = mark; |
| 17125 | } |
| 17126 | res = NULL; |
| 17127 | done: |
| 17128 | return res; |
| 17129 | } |
| 17130 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17131 | // _loop1_145: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17132 | static asdl_seq * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17133 | _loop1_145_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17134 | { |
| 17135 | if (p->error_indicator) { |
| 17136 | return NULL; |
| 17137 | } |
| 17138 | void *res = NULL; |
| 17139 | int mark = p->mark; |
| 17140 | int start_mark = p->mark; |
| 17141 | void **children = PyMem_Malloc(sizeof(void *)); |
| 17142 | if (!children) { |
| 17143 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 17144 | return NULL; |
| 17145 | } |
| 17146 | ssize_t children_capacity = 1; |
| 17147 | ssize_t n = 0; |
| 17148 | { // param_with_default |
| 17149 | NameDefaultPair* param_with_default_var; |
| 17150 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17151 | (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] | 17152 | ) |
| 17153 | { |
| 17154 | res = param_with_default_var; |
| 17155 | if (n == children_capacity) { |
| 17156 | children_capacity *= 2; |
| 17157 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 17158 | if (!children) { |
| 17159 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 17160 | return NULL; |
| 17161 | } |
| 17162 | } |
| 17163 | children[n++] = res; |
| 17164 | mark = p->mark; |
| 17165 | } |
| 17166 | p->mark = mark; |
| 17167 | } |
| 17168 | if (n == 0) { |
| 17169 | PyMem_Free(children); |
| 17170 | return NULL; |
| 17171 | } |
| 17172 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 17173 | if (!seq) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17174 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_145"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17175 | PyMem_Free(children); |
| 17176 | return NULL; |
| 17177 | } |
| 17178 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 17179 | PyMem_Free(children); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17180 | _PyPegen_insert_memo(p, start_mark, _loop1_145_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17181 | return seq; |
| 17182 | } |
| 17183 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17184 | // _tmp_146: ')' | '**' |
| 17185 | static void * |
| 17186 | _tmp_146_rule(Parser *p) |
| 17187 | { |
| 17188 | if (p->error_indicator) { |
| 17189 | return NULL; |
| 17190 | } |
| 17191 | void * res = NULL; |
| 17192 | int mark = p->mark; |
| 17193 | { // ')' |
| 17194 | Token * literal; |
| 17195 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17196 | (literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17197 | ) |
| 17198 | { |
| 17199 | res = literal; |
| 17200 | goto done; |
| 17201 | } |
| 17202 | p->mark = mark; |
| 17203 | } |
| 17204 | { // '**' |
| 17205 | Token * literal; |
| 17206 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17207 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17208 | ) |
| 17209 | { |
| 17210 | res = literal; |
| 17211 | goto done; |
| 17212 | } |
| 17213 | p->mark = mark; |
| 17214 | } |
| 17215 | res = NULL; |
| 17216 | done: |
| 17217 | return res; |
| 17218 | } |
| 17219 | |
| 17220 | // _tmp_147: ':' | '**' |
| 17221 | static void * |
| 17222 | _tmp_147_rule(Parser *p) |
| 17223 | { |
| 17224 | if (p->error_indicator) { |
| 17225 | return NULL; |
| 17226 | } |
| 17227 | void * res = NULL; |
| 17228 | int mark = p->mark; |
| 17229 | { // ':' |
| 17230 | Token * literal; |
| 17231 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17232 | (literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17233 | ) |
| 17234 | { |
| 17235 | res = literal; |
| 17236 | goto done; |
| 17237 | } |
| 17238 | p->mark = mark; |
| 17239 | } |
| 17240 | { // '**' |
| 17241 | Token * literal; |
| 17242 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17243 | (literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17244 | ) |
| 17245 | { |
| 17246 | res = literal; |
| 17247 | goto done; |
| 17248 | } |
| 17249 | p->mark = mark; |
| 17250 | } |
| 17251 | res = NULL; |
| 17252 | done: |
| 17253 | return res; |
| 17254 | } |
| 17255 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17256 | void * |
| 17257 | _PyPegen_parse(Parser *p) |
| 17258 | { |
| 17259 | // Initialize keywords |
| 17260 | p->keywords = reserved_keywords; |
| 17261 | p->n_keyword_lists = n_keyword_lists; |
| 17262 | |
| 17263 | // Run parser |
| 17264 | void *result = NULL; |
| 17265 | if (p->start_rule == Py_file_input) { |
| 17266 | result = file_rule(p); |
| 17267 | } else if (p->start_rule == Py_single_input) { |
| 17268 | result = interactive_rule(p); |
| 17269 | } else if (p->start_rule == Py_eval_input) { |
| 17270 | result = eval_rule(p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17271 | } else if (p->start_rule == Py_func_type_input) { |
| 17272 | result = func_type_rule(p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17273 | } else if (p->start_rule == Py_fstring_input) { |
| 17274 | result = fstring_rule(p); |
| 17275 | } |
| 17276 | |
| 17277 | return result; |
| 17278 | } |
| 17279 | |
| 17280 | // The end |