blob: 9c941ca1ee2eccef7407eeccda7ddd440160a9bb [file] [log] [blame]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001// @generated by pegen.py from ./Grammar/python.gram
2#include "pegen.h"
3static const int n_keyword_lists = 15;
4static 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 Rossumc001c092020-04-30 12:12:19 -070074#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
141#define lambda_slash_without_default_type 1070
142#define lambda_slash_with_default_type 1071
143#define lambda_star_etc_type 1072
144#define lambda_name_with_optional_default_type 1073
145#define lambda_names_with_default_type 1074
146#define lambda_name_with_default_type 1075
147#define lambda_plain_names_type 1076
148#define lambda_plain_name_type 1077
149#define lambda_kwds_type 1078
150#define disjunction_type 1079
151#define conjunction_type 1080
152#define inversion_type 1081
153#define comparison_type 1082
154#define compare_op_bitwise_or_pair_type 1083
155#define eq_bitwise_or_type 1084
156#define noteq_bitwise_or_type 1085
157#define lte_bitwise_or_type 1086
158#define lt_bitwise_or_type 1087
159#define gte_bitwise_or_type 1088
160#define gt_bitwise_or_type 1089
161#define notin_bitwise_or_type 1090
162#define in_bitwise_or_type 1091
163#define isnot_bitwise_or_type 1092
164#define is_bitwise_or_type 1093
165#define bitwise_or_type 1094 // Left-recursive
166#define bitwise_xor_type 1095 // Left-recursive
167#define bitwise_and_type 1096 // Left-recursive
168#define shift_expr_type 1097 // Left-recursive
169#define sum_type 1098 // Left-recursive
170#define term_type 1099 // Left-recursive
171#define factor_type 1100
172#define power_type 1101
173#define await_primary_type 1102
174#define primary_type 1103 // Left-recursive
175#define slices_type 1104
176#define slice_type 1105
177#define atom_type 1106
178#define strings_type 1107
179#define list_type 1108
180#define listcomp_type 1109
181#define tuple_type 1110
182#define group_type 1111
183#define genexp_type 1112
184#define set_type 1113
185#define setcomp_type 1114
186#define dict_type 1115
187#define dictcomp_type 1116
188#define kvpairs_type 1117
189#define kvpair_type 1118
190#define for_if_clauses_type 1119
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300191#define for_if_clause_type 1120
192#define yield_expr_type 1121
193#define arguments_type 1122
194#define args_type 1123
195#define kwargs_type 1124
196#define starred_expression_type 1125
197#define kwarg_or_starred_type 1126
198#define kwarg_or_double_starred_type 1127
199#define star_targets_type 1128
200#define star_targets_seq_type 1129
201#define star_target_type 1130
202#define star_atom_type 1131
203#define inside_paren_ann_assign_target_type 1132
204#define ann_assign_subscript_attribute_target_type 1133
205#define del_targets_type 1134
206#define del_target_type 1135
207#define del_t_atom_type 1136
208#define targets_type 1137
209#define target_type 1138
210#define t_primary_type 1139 // Left-recursive
211#define t_lookahead_type 1140
212#define t_atom_type 1141
213#define incorrect_arguments_type 1142
214#define invalid_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_double_type_comments_type 1148
220#define _loop0_1_type 1149
221#define _loop0_2_type 1150
222#define _loop0_4_type 1151
223#define _gather_3_type 1152
224#define _loop0_6_type 1153
225#define _gather_5_type 1154
226#define _loop0_8_type 1155
227#define _gather_7_type 1156
228#define _loop0_10_type 1157
229#define _gather_9_type 1158
230#define _loop1_11_type 1159
231#define _loop0_13_type 1160
232#define _gather_12_type 1161
233#define _tmp_14_type 1162
234#define _tmp_15_type 1163
235#define _tmp_16_type 1164
236#define _tmp_17_type 1165
237#define _tmp_18_type 1166
238#define _tmp_19_type 1167
239#define _tmp_20_type 1168
240#define _tmp_21_type 1169
241#define _loop1_22_type 1170
242#define _tmp_23_type 1171
243#define _tmp_24_type 1172
244#define _loop0_26_type 1173
245#define _gather_25_type 1174
246#define _loop0_28_type 1175
247#define _gather_27_type 1176
248#define _tmp_29_type 1177
249#define _loop0_30_type 1178
250#define _loop1_31_type 1179
251#define _loop0_33_type 1180
252#define _gather_32_type 1181
253#define _tmp_34_type 1182
254#define _loop0_36_type 1183
255#define _gather_35_type 1184
256#define _tmp_37_type 1185
257#define _loop0_39_type 1186
258#define _gather_38_type 1187
259#define _loop0_41_type 1188
260#define _gather_40_type 1189
261#define _loop0_43_type 1190
262#define _gather_42_type 1191
263#define _loop0_45_type 1192
264#define _gather_44_type 1193
265#define _tmp_46_type 1194
266#define _loop1_47_type 1195
267#define _tmp_48_type 1196
268#define _tmp_49_type 1197
269#define _tmp_50_type 1198
270#define _tmp_51_type 1199
271#define _tmp_52_type 1200
272#define _loop0_53_type 1201
273#define _loop0_54_type 1202
274#define _loop0_55_type 1203
275#define _loop1_56_type 1204
276#define _loop0_57_type 1205
277#define _loop1_58_type 1206
278#define _loop1_59_type 1207
279#define _loop1_60_type 1208
280#define _loop0_61_type 1209
281#define _loop1_62_type 1210
282#define _loop0_63_type 1211
283#define _loop1_64_type 1212
284#define _loop0_65_type 1213
285#define _loop1_66_type 1214
286#define _loop1_67_type 1215
287#define _tmp_68_type 1216
288#define _loop0_70_type 1217
289#define _gather_69_type 1218
290#define _loop1_71_type 1219
291#define _loop0_73_type 1220
292#define _gather_72_type 1221
293#define _loop1_74_type 1222
294#define _tmp_75_type 1223
295#define _tmp_76_type 1224
296#define _tmp_77_type 1225
297#define _tmp_78_type 1226
298#define _tmp_79_type 1227
299#define _tmp_80_type 1228
300#define _tmp_81_type 1229
301#define _tmp_82_type 1230
302#define _tmp_83_type 1231
303#define _loop0_84_type 1232
304#define _tmp_85_type 1233
305#define _loop1_86_type 1234
306#define _tmp_87_type 1235
307#define _tmp_88_type 1236
308#define _loop0_90_type 1237
309#define _gather_89_type 1238
310#define _loop0_92_type 1239
311#define _gather_91_type 1240
312#define _loop1_93_type 1241
313#define _loop1_94_type 1242
314#define _loop1_95_type 1243
315#define _tmp_96_type 1244
316#define _loop0_98_type 1245
317#define _gather_97_type 1246
318#define _tmp_99_type 1247
319#define _tmp_100_type 1248
320#define _tmp_101_type 1249
321#define _tmp_102_type 1250
322#define _loop1_103_type 1251
323#define _tmp_104_type 1252
324#define _tmp_105_type 1253
325#define _loop0_107_type 1254
326#define _gather_106_type 1255
327#define _loop1_108_type 1256
328#define _loop0_109_type 1257
329#define _loop0_110_type 1258
330#define _tmp_111_type 1259
331#define _tmp_112_type 1260
Guido van Rossumc001c092020-04-30 12:12:19 -0700332#define _loop0_114_type 1261
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300333#define _gather_113_type 1262
334#define _loop0_116_type 1263
335#define _gather_115_type 1264
336#define _loop0_118_type 1265
337#define _gather_117_type 1266
338#define _loop0_120_type 1267
339#define _gather_119_type 1268
340#define _loop0_121_type 1269
341#define _loop0_123_type 1270
342#define _gather_122_type 1271
343#define _tmp_124_type 1272
344#define _loop0_126_type 1273
345#define _gather_125_type 1274
346#define _loop0_128_type 1275
347#define _gather_127_type 1276
348#define _tmp_129_type 1277
349#define _tmp_130_type 1278
350#define _tmp_131_type 1279
351#define _tmp_132_type 1280
352#define _tmp_133_type 1281
353#define _loop0_134_type 1282
354#define _tmp_135_type 1283
355#define _tmp_136_type 1284
356#define _tmp_137_type 1285
357#define _tmp_138_type 1286
358#define _tmp_139_type 1287
359#define _tmp_140_type 1288
360#define _tmp_141_type 1289
361#define _tmp_142_type 1290
362#define _tmp_143_type 1291
363#define _tmp_144_type 1292
364#define _tmp_145_type 1293
365#define _tmp_146_type 1294
366#define _tmp_147_type 1295
367#define _loop1_148_type 1296
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100368
369static mod_ty file_rule(Parser *p);
370static mod_ty interactive_rule(Parser *p);
371static mod_ty eval_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700372static mod_ty func_type_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100373static expr_ty fstring_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700374static asdl_seq* type_expressions_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100375static asdl_seq* statements_rule(Parser *p);
376static asdl_seq* statement_rule(Parser *p);
377static asdl_seq* statement_newline_rule(Parser *p);
378static asdl_seq* simple_stmt_rule(Parser *p);
379static stmt_ty small_stmt_rule(Parser *p);
380static stmt_ty compound_stmt_rule(Parser *p);
381static void *assignment_rule(Parser *p);
382static AugOperator* augassign_rule(Parser *p);
383static stmt_ty global_stmt_rule(Parser *p);
384static stmt_ty nonlocal_stmt_rule(Parser *p);
385static stmt_ty yield_stmt_rule(Parser *p);
386static stmt_ty assert_stmt_rule(Parser *p);
387static stmt_ty del_stmt_rule(Parser *p);
388static stmt_ty import_stmt_rule(Parser *p);
389static stmt_ty import_name_rule(Parser *p);
390static stmt_ty import_from_rule(Parser *p);
391static asdl_seq* import_from_targets_rule(Parser *p);
392static asdl_seq* import_from_as_names_rule(Parser *p);
393static alias_ty import_from_as_name_rule(Parser *p);
394static asdl_seq* dotted_as_names_rule(Parser *p);
395static alias_ty dotted_as_name_rule(Parser *p);
396static expr_ty dotted_name_rule(Parser *p);
397static stmt_ty if_stmt_rule(Parser *p);
398static stmt_ty elif_stmt_rule(Parser *p);
399static asdl_seq* else_block_rule(Parser *p);
400static stmt_ty while_stmt_rule(Parser *p);
401static stmt_ty for_stmt_rule(Parser *p);
402static stmt_ty with_stmt_rule(Parser *p);
403static withitem_ty with_item_rule(Parser *p);
404static stmt_ty try_stmt_rule(Parser *p);
405static excepthandler_ty except_block_rule(Parser *p);
406static asdl_seq* finally_block_rule(Parser *p);
407static stmt_ty return_stmt_rule(Parser *p);
408static stmt_ty raise_stmt_rule(Parser *p);
409static stmt_ty function_def_rule(Parser *p);
410static stmt_ty function_def_raw_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700411static PyObject* func_type_comment_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100412static arguments_ty params_rule(Parser *p);
413static arguments_ty parameters_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700414static asdl_seq* slash_no_default_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100415static SlashWithDefault* slash_with_default_rule(Parser *p);
416static StarEtc* star_etc_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100417static arg_ty kwds_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700418static arg_ty param_no_default_rule(Parser *p);
419static NameDefaultPair* param_with_default_rule(Parser *p);
420static NameDefaultPair* param_maybe_default_rule(Parser *p);
421static arg_ty param_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100422static expr_ty annotation_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700423static expr_ty default_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100424static asdl_seq* decorators_rule(Parser *p);
425static stmt_ty class_def_rule(Parser *p);
426static stmt_ty class_def_raw_rule(Parser *p);
427static asdl_seq* block_rule(Parser *p);
428static asdl_seq* expressions_list_rule(Parser *p);
429static expr_ty star_expressions_rule(Parser *p);
430static expr_ty star_expression_rule(Parser *p);
431static asdl_seq* star_named_expressions_rule(Parser *p);
432static expr_ty star_named_expression_rule(Parser *p);
433static expr_ty named_expression_rule(Parser *p);
434static expr_ty annotated_rhs_rule(Parser *p);
435static expr_ty expressions_rule(Parser *p);
436static expr_ty expression_rule(Parser *p);
437static expr_ty lambdef_rule(Parser *p);
438static arguments_ty lambda_parameters_rule(Parser *p);
439static asdl_seq* lambda_slash_without_default_rule(Parser *p);
440static SlashWithDefault* lambda_slash_with_default_rule(Parser *p);
441static StarEtc* lambda_star_etc_rule(Parser *p);
442static NameDefaultPair* lambda_name_with_optional_default_rule(Parser *p);
443static asdl_seq* lambda_names_with_default_rule(Parser *p);
444static NameDefaultPair* lambda_name_with_default_rule(Parser *p);
445static asdl_seq* lambda_plain_names_rule(Parser *p);
446static arg_ty lambda_plain_name_rule(Parser *p);
447static arg_ty lambda_kwds_rule(Parser *p);
448static expr_ty disjunction_rule(Parser *p);
449static expr_ty conjunction_rule(Parser *p);
450static expr_ty inversion_rule(Parser *p);
451static expr_ty comparison_rule(Parser *p);
452static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p);
453static CmpopExprPair* eq_bitwise_or_rule(Parser *p);
454static CmpopExprPair* noteq_bitwise_or_rule(Parser *p);
455static CmpopExprPair* lte_bitwise_or_rule(Parser *p);
456static CmpopExprPair* lt_bitwise_or_rule(Parser *p);
457static CmpopExprPair* gte_bitwise_or_rule(Parser *p);
458static CmpopExprPair* gt_bitwise_or_rule(Parser *p);
459static CmpopExprPair* notin_bitwise_or_rule(Parser *p);
460static CmpopExprPair* in_bitwise_or_rule(Parser *p);
461static CmpopExprPair* isnot_bitwise_or_rule(Parser *p);
462static CmpopExprPair* is_bitwise_or_rule(Parser *p);
463static expr_ty bitwise_or_rule(Parser *p);
464static expr_ty bitwise_xor_rule(Parser *p);
465static expr_ty bitwise_and_rule(Parser *p);
466static expr_ty shift_expr_rule(Parser *p);
467static expr_ty sum_rule(Parser *p);
468static expr_ty term_rule(Parser *p);
469static expr_ty factor_rule(Parser *p);
470static expr_ty power_rule(Parser *p);
471static expr_ty await_primary_rule(Parser *p);
472static expr_ty primary_rule(Parser *p);
473static expr_ty slices_rule(Parser *p);
474static expr_ty slice_rule(Parser *p);
475static expr_ty atom_rule(Parser *p);
476static expr_ty strings_rule(Parser *p);
477static expr_ty list_rule(Parser *p);
478static expr_ty listcomp_rule(Parser *p);
479static expr_ty tuple_rule(Parser *p);
480static expr_ty group_rule(Parser *p);
481static expr_ty genexp_rule(Parser *p);
482static expr_ty set_rule(Parser *p);
483static expr_ty setcomp_rule(Parser *p);
484static expr_ty dict_rule(Parser *p);
485static expr_ty dictcomp_rule(Parser *p);
486static asdl_seq* kvpairs_rule(Parser *p);
487static KeyValuePair* kvpair_rule(Parser *p);
488static asdl_seq* for_if_clauses_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300489static comprehension_ty for_if_clause_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100490static expr_ty yield_expr_rule(Parser *p);
491static expr_ty arguments_rule(Parser *p);
492static expr_ty args_rule(Parser *p);
493static asdl_seq* kwargs_rule(Parser *p);
494static expr_ty starred_expression_rule(Parser *p);
495static KeywordOrStarred* kwarg_or_starred_rule(Parser *p);
496static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p);
497static expr_ty star_targets_rule(Parser *p);
498static asdl_seq* star_targets_seq_rule(Parser *p);
499static expr_ty star_target_rule(Parser *p);
500static expr_ty star_atom_rule(Parser *p);
501static expr_ty inside_paren_ann_assign_target_rule(Parser *p);
502static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p);
503static asdl_seq* del_targets_rule(Parser *p);
504static expr_ty del_target_rule(Parser *p);
505static expr_ty del_t_atom_rule(Parser *p);
506static asdl_seq* targets_rule(Parser *p);
507static expr_ty target_rule(Parser *p);
508static expr_ty t_primary_rule(Parser *p);
509static void *t_lookahead_rule(Parser *p);
510static expr_ty t_atom_rule(Parser *p);
511static void *incorrect_arguments_rule(Parser *p);
512static void *invalid_named_expression_rule(Parser *p);
513static void *invalid_assignment_rule(Parser *p);
514static void *invalid_block_rule(Parser *p);
515static void *invalid_comprehension_rule(Parser *p);
516static void *invalid_parameters_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700517static void *invalid_double_type_comments_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100518static asdl_seq *_loop0_1_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700519static asdl_seq *_loop0_2_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100520static asdl_seq *_loop0_4_rule(Parser *p);
521static asdl_seq *_gather_3_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700522static asdl_seq *_loop0_6_rule(Parser *p);
523static asdl_seq *_gather_5_rule(Parser *p);
524static asdl_seq *_loop0_8_rule(Parser *p);
525static asdl_seq *_gather_7_rule(Parser *p);
526static asdl_seq *_loop0_10_rule(Parser *p);
527static asdl_seq *_gather_9_rule(Parser *p);
528static asdl_seq *_loop1_11_rule(Parser *p);
529static asdl_seq *_loop0_13_rule(Parser *p);
530static asdl_seq *_gather_12_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100531static void *_tmp_14_rule(Parser *p);
532static void *_tmp_15_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700533static void *_tmp_16_rule(Parser *p);
534static void *_tmp_17_rule(Parser *p);
535static void *_tmp_18_rule(Parser *p);
536static void *_tmp_19_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100537static void *_tmp_20_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700538static void *_tmp_21_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100539static asdl_seq *_loop1_22_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700540static void *_tmp_23_rule(Parser *p);
541static void *_tmp_24_rule(Parser *p);
542static asdl_seq *_loop0_26_rule(Parser *p);
543static asdl_seq *_gather_25_rule(Parser *p);
544static asdl_seq *_loop0_28_rule(Parser *p);
545static asdl_seq *_gather_27_rule(Parser *p);
546static void *_tmp_29_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100547static asdl_seq *_loop0_30_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700548static asdl_seq *_loop1_31_rule(Parser *p);
549static asdl_seq *_loop0_33_rule(Parser *p);
550static asdl_seq *_gather_32_rule(Parser *p);
551static void *_tmp_34_rule(Parser *p);
552static asdl_seq *_loop0_36_rule(Parser *p);
553static asdl_seq *_gather_35_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100554static void *_tmp_37_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700555static asdl_seq *_loop0_39_rule(Parser *p);
556static asdl_seq *_gather_38_rule(Parser *p);
557static asdl_seq *_loop0_41_rule(Parser *p);
558static asdl_seq *_gather_40_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300559static asdl_seq *_loop0_43_rule(Parser *p);
560static asdl_seq *_gather_42_rule(Parser *p);
561static asdl_seq *_loop0_45_rule(Parser *p);
562static asdl_seq *_gather_44_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100563static void *_tmp_46_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300564static asdl_seq *_loop1_47_rule(Parser *p);
565static void *_tmp_48_rule(Parser *p);
566static void *_tmp_49_rule(Parser *p);
567static void *_tmp_50_rule(Parser *p);
568static void *_tmp_51_rule(Parser *p);
569static void *_tmp_52_rule(Parser *p);
570static asdl_seq *_loop0_53_rule(Parser *p);
571static asdl_seq *_loop0_54_rule(Parser *p);
572static asdl_seq *_loop0_55_rule(Parser *p);
573static asdl_seq *_loop1_56_rule(Parser *p);
574static asdl_seq *_loop0_57_rule(Parser *p);
575static asdl_seq *_loop1_58_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700576static asdl_seq *_loop1_59_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300577static asdl_seq *_loop1_60_rule(Parser *p);
578static asdl_seq *_loop0_61_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700579static asdl_seq *_loop1_62_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300580static asdl_seq *_loop0_63_rule(Parser *p);
581static asdl_seq *_loop1_64_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700582static asdl_seq *_loop0_65_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700583static asdl_seq *_loop1_66_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300584static asdl_seq *_loop1_67_rule(Parser *p);
585static void *_tmp_68_rule(Parser *p);
586static asdl_seq *_loop0_70_rule(Parser *p);
587static asdl_seq *_gather_69_rule(Parser *p);
588static asdl_seq *_loop1_71_rule(Parser *p);
589static asdl_seq *_loop0_73_rule(Parser *p);
590static asdl_seq *_gather_72_rule(Parser *p);
591static asdl_seq *_loop1_74_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100592static void *_tmp_75_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700593static void *_tmp_76_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100594static void *_tmp_77_rule(Parser *p);
595static void *_tmp_78_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300596static void *_tmp_79_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700597static void *_tmp_80_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300598static void *_tmp_81_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700599static void *_tmp_82_rule(Parser *p);
600static void *_tmp_83_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300601static asdl_seq *_loop0_84_rule(Parser *p);
602static void *_tmp_85_rule(Parser *p);
603static asdl_seq *_loop1_86_rule(Parser *p);
604static void *_tmp_87_rule(Parser *p);
605static void *_tmp_88_rule(Parser *p);
606static asdl_seq *_loop0_90_rule(Parser *p);
607static asdl_seq *_gather_89_rule(Parser *p);
608static asdl_seq *_loop0_92_rule(Parser *p);
609static asdl_seq *_gather_91_rule(Parser *p);
610static asdl_seq *_loop1_93_rule(Parser *p);
611static asdl_seq *_loop1_94_rule(Parser *p);
612static asdl_seq *_loop1_95_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700613static void *_tmp_96_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300614static asdl_seq *_loop0_98_rule(Parser *p);
615static asdl_seq *_gather_97_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100616static void *_tmp_99_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100617static void *_tmp_100_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300618static void *_tmp_101_rule(Parser *p);
619static void *_tmp_102_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700620static asdl_seq *_loop1_103_rule(Parser *p);
621static void *_tmp_104_rule(Parser *p);
622static void *_tmp_105_rule(Parser *p);
623static asdl_seq *_loop0_107_rule(Parser *p);
624static asdl_seq *_gather_106_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300625static asdl_seq *_loop1_108_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100626static asdl_seq *_loop0_109_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300627static asdl_seq *_loop0_110_rule(Parser *p);
628static void *_tmp_111_rule(Parser *p);
629static void *_tmp_112_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100630static asdl_seq *_loop0_114_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300631static asdl_seq *_gather_113_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100632static asdl_seq *_loop0_116_rule(Parser *p);
633static asdl_seq *_gather_115_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300634static asdl_seq *_loop0_118_rule(Parser *p);
635static asdl_seq *_gather_117_rule(Parser *p);
636static asdl_seq *_loop0_120_rule(Parser *p);
637static asdl_seq *_gather_119_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700638static asdl_seq *_loop0_121_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300639static asdl_seq *_loop0_123_rule(Parser *p);
640static asdl_seq *_gather_122_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100641static void *_tmp_124_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300642static asdl_seq *_loop0_126_rule(Parser *p);
643static asdl_seq *_gather_125_rule(Parser *p);
644static asdl_seq *_loop0_128_rule(Parser *p);
645static asdl_seq *_gather_127_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100646static void *_tmp_129_rule(Parser *p);
647static void *_tmp_130_rule(Parser *p);
648static void *_tmp_131_rule(Parser *p);
649static void *_tmp_132_rule(Parser *p);
650static void *_tmp_133_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300651static asdl_seq *_loop0_134_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100652static void *_tmp_135_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700653static void *_tmp_136_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100654static void *_tmp_137_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700655static void *_tmp_138_rule(Parser *p);
656static void *_tmp_139_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300657static void *_tmp_140_rule(Parser *p);
658static void *_tmp_141_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700659static void *_tmp_142_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300660static void *_tmp_143_rule(Parser *p);
661static void *_tmp_144_rule(Parser *p);
662static void *_tmp_145_rule(Parser *p);
663static void *_tmp_146_rule(Parser *p);
664static void *_tmp_147_rule(Parser *p);
665static asdl_seq *_loop1_148_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100666
667
668// file: statements? $
669static mod_ty
670file_rule(Parser *p)
671{
672 if (p->error_indicator) {
673 return NULL;
674 }
675 mod_ty res = NULL;
676 int mark = p->mark;
677 { // statements? $
678 void *a;
679 void *endmarker_var;
680 if (
681 (a = statements_rule(p), 1)
682 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +0100683 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER))
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100684 )
685 {
Guido van Rossumc001c092020-04-30 12:12:19 -0700686 res = _PyPegen_make_module ( p , a );
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100687 if (res == NULL && PyErr_Occurred()) {
688 p->error_indicator = 1;
689 return NULL;
690 }
691 goto done;
692 }
693 p->mark = mark;
694 }
695 res = NULL;
696 done:
697 return res;
698}
699
700// interactive: statement_newline
701static mod_ty
702interactive_rule(Parser *p)
703{
704 if (p->error_indicator) {
705 return NULL;
706 }
707 mod_ty res = NULL;
708 int mark = p->mark;
709 { // statement_newline
710 asdl_seq* a;
711 if (
712 (a = statement_newline_rule(p))
713 )
714 {
715 res = Interactive ( a , p -> arena );
716 if (res == NULL && PyErr_Occurred()) {
717 p->error_indicator = 1;
718 return NULL;
719 }
720 goto done;
721 }
722 p->mark = mark;
723 }
724 res = NULL;
725 done:
726 return res;
727}
728
729// eval: expressions NEWLINE* $
730static mod_ty
731eval_rule(Parser *p)
732{
733 if (p->error_indicator) {
734 return NULL;
735 }
736 mod_ty res = NULL;
737 int mark = p->mark;
738 { // expressions NEWLINE* $
739 asdl_seq * _loop0_1_var;
740 expr_ty a;
741 void *endmarker_var;
742 if (
743 (a = expressions_rule(p))
744 &&
745 (_loop0_1_var = _loop0_1_rule(p))
746 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +0100747 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER))
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100748 )
749 {
750 res = Expression ( a , p -> arena );
751 if (res == NULL && PyErr_Occurred()) {
752 p->error_indicator = 1;
753 return NULL;
754 }
755 goto done;
756 }
757 p->mark = mark;
758 }
759 res = NULL;
760 done:
761 return res;
762}
763
Guido van Rossumc001c092020-04-30 12:12:19 -0700764// func_type: '(' type_expressions? ')' '->' expression NEWLINE* $
765static mod_ty
766func_type_rule(Parser *p)
767{
768 if (p->error_indicator) {
769 return NULL;
770 }
771 mod_ty res = NULL;
772 int mark = p->mark;
773 { // '(' type_expressions? ')' '->' expression NEWLINE* $
774 asdl_seq * _loop0_2_var;
775 void *a;
776 expr_ty b;
777 void *endmarker_var;
778 void *literal;
779 void *literal_1;
780 void *literal_2;
781 if (
782 (literal = _PyPegen_expect_token(p, 7))
783 &&
784 (a = type_expressions_rule(p), 1)
785 &&
786 (literal_1 = _PyPegen_expect_token(p, 8))
787 &&
788 (literal_2 = _PyPegen_expect_token(p, 51))
789 &&
790 (b = expression_rule(p))
791 &&
792 (_loop0_2_var = _loop0_2_rule(p))
793 &&
794 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER))
795 )
796 {
797 res = FunctionType ( a , b , p -> arena );
798 if (res == NULL && PyErr_Occurred()) {
799 p->error_indicator = 1;
800 return NULL;
801 }
802 goto done;
803 }
804 p->mark = mark;
805 }
806 res = NULL;
807 done:
808 return res;
809}
810
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100811// fstring: star_expressions
812static expr_ty
813fstring_rule(Parser *p)
814{
815 if (p->error_indicator) {
816 return NULL;
817 }
818 expr_ty res = NULL;
819 int mark = p->mark;
820 { // star_expressions
821 expr_ty star_expressions_var;
822 if (
823 (star_expressions_var = star_expressions_rule(p))
824 )
825 {
826 res = star_expressions_var;
827 goto done;
828 }
829 p->mark = mark;
830 }
831 res = NULL;
832 done:
833 return res;
834}
835
Guido van Rossumc001c092020-04-30 12:12:19 -0700836// type_expressions:
837// | ','.expression+ ',' '*' expression ',' '**' expression
838// | ','.expression+ ',' '*' expression
839// | ','.expression+ ',' '**' expression
840// | ','.expression+
841static asdl_seq*
842type_expressions_rule(Parser *p)
843{
844 if (p->error_indicator) {
845 return NULL;
846 }
847 asdl_seq* res = NULL;
848 int mark = p->mark;
849 { // ','.expression+ ',' '*' expression ',' '**' expression
850 asdl_seq * a;
851 expr_ty b;
852 expr_ty c;
853 void *literal;
854 void *literal_1;
855 void *literal_2;
856 void *literal_3;
857 if (
858 (a = _gather_3_rule(p))
859 &&
860 (literal = _PyPegen_expect_token(p, 12))
861 &&
862 (literal_1 = _PyPegen_expect_token(p, 16))
863 &&
864 (b = expression_rule(p))
865 &&
866 (literal_2 = _PyPegen_expect_token(p, 12))
867 &&
868 (literal_3 = _PyPegen_expect_token(p, 35))
869 &&
870 (c = expression_rule(p))
871 )
872 {
873 res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c );
874 if (res == NULL && PyErr_Occurred()) {
875 p->error_indicator = 1;
876 return NULL;
877 }
878 goto done;
879 }
880 p->mark = mark;
881 }
882 { // ','.expression+ ',' '*' expression
883 asdl_seq * a;
884 expr_ty b;
885 void *literal;
886 void *literal_1;
887 if (
888 (a = _gather_5_rule(p))
889 &&
890 (literal = _PyPegen_expect_token(p, 12))
891 &&
892 (literal_1 = _PyPegen_expect_token(p, 16))
893 &&
894 (b = expression_rule(p))
895 )
896 {
897 res = _PyPegen_seq_append_to_end ( p , a , b );
898 if (res == NULL && PyErr_Occurred()) {
899 p->error_indicator = 1;
900 return NULL;
901 }
902 goto done;
903 }
904 p->mark = mark;
905 }
906 { // ','.expression+ ',' '**' expression
907 asdl_seq * a;
908 expr_ty b;
909 void *literal;
910 void *literal_1;
911 if (
912 (a = _gather_7_rule(p))
913 &&
914 (literal = _PyPegen_expect_token(p, 12))
915 &&
916 (literal_1 = _PyPegen_expect_token(p, 35))
917 &&
918 (b = expression_rule(p))
919 )
920 {
921 res = _PyPegen_seq_append_to_end ( p , a , b );
922 if (res == NULL && PyErr_Occurred()) {
923 p->error_indicator = 1;
924 return NULL;
925 }
926 goto done;
927 }
928 p->mark = mark;
929 }
930 { // ','.expression+
931 asdl_seq * _gather_9_var;
932 if (
933 (_gather_9_var = _gather_9_rule(p))
934 )
935 {
936 res = _gather_9_var;
937 goto done;
938 }
939 p->mark = mark;
940 }
941 res = NULL;
942 done:
943 return res;
944}
945
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100946// statements: statement+
947static asdl_seq*
948statements_rule(Parser *p)
949{
950 if (p->error_indicator) {
951 return NULL;
952 }
953 asdl_seq* res = NULL;
954 int mark = p->mark;
955 { // statement+
956 asdl_seq * a;
957 if (
Guido van Rossumc001c092020-04-30 12:12:19 -0700958 (a = _loop1_11_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100959 )
960 {
961 res = _PyPegen_seq_flatten ( p , a );
962 if (res == NULL && PyErr_Occurred()) {
963 p->error_indicator = 1;
964 return NULL;
965 }
966 goto done;
967 }
968 p->mark = mark;
969 }
970 res = NULL;
971 done:
972 return res;
973}
974
975// statement: compound_stmt | simple_stmt
976static asdl_seq*
977statement_rule(Parser *p)
978{
979 if (p->error_indicator) {
980 return NULL;
981 }
982 asdl_seq* res = NULL;
983 int mark = p->mark;
984 { // compound_stmt
985 stmt_ty a;
986 if (
987 (a = compound_stmt_rule(p))
988 )
989 {
990 res = _PyPegen_singleton_seq ( p , a );
991 if (res == NULL && PyErr_Occurred()) {
992 p->error_indicator = 1;
993 return NULL;
994 }
995 goto done;
996 }
997 p->mark = mark;
998 }
999 { // simple_stmt
1000 asdl_seq* simple_stmt_var;
1001 if (
1002 (simple_stmt_var = simple_stmt_rule(p))
1003 )
1004 {
1005 res = simple_stmt_var;
1006 goto done;
1007 }
1008 p->mark = mark;
1009 }
1010 res = NULL;
1011 done:
1012 return res;
1013}
1014
1015// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
1016static asdl_seq*
1017statement_newline_rule(Parser *p)
1018{
1019 if (p->error_indicator) {
1020 return NULL;
1021 }
1022 asdl_seq* res = NULL;
1023 int mark = p->mark;
1024 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1025 p->error_indicator = 1;
1026 return NULL;
1027 }
1028 int start_lineno = p->tokens[mark]->lineno;
1029 UNUSED(start_lineno); // Only used by EXTRA macro
1030 int start_col_offset = p->tokens[mark]->col_offset;
1031 UNUSED(start_col_offset); // Only used by EXTRA macro
1032 { // compound_stmt NEWLINE
1033 stmt_ty a;
1034 void *newline_var;
1035 if (
1036 (a = compound_stmt_rule(p))
1037 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01001038 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001039 )
1040 {
1041 res = _PyPegen_singleton_seq ( p , a );
1042 if (res == NULL && PyErr_Occurred()) {
1043 p->error_indicator = 1;
1044 return NULL;
1045 }
1046 goto done;
1047 }
1048 p->mark = mark;
1049 }
1050 { // simple_stmt
1051 asdl_seq* simple_stmt_var;
1052 if (
1053 (simple_stmt_var = simple_stmt_rule(p))
1054 )
1055 {
1056 res = simple_stmt_var;
1057 goto done;
1058 }
1059 p->mark = mark;
1060 }
1061 { // NEWLINE
1062 void *newline_var;
1063 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +01001064 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001065 )
1066 {
1067 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1068 if (token == NULL) {
1069 return NULL;
1070 }
1071 int end_lineno = token->end_lineno;
1072 UNUSED(end_lineno); // Only used by EXTRA macro
1073 int end_col_offset = token->end_col_offset;
1074 UNUSED(end_col_offset); // Only used by EXTRA macro
1075 res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) );
1076 if (res == NULL && PyErr_Occurred()) {
1077 p->error_indicator = 1;
1078 return NULL;
1079 }
1080 goto done;
1081 }
1082 p->mark = mark;
1083 }
1084 { // $
1085 void *endmarker_var;
1086 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +01001087 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001088 )
1089 {
1090 res = _PyPegen_interactive_exit ( p );
1091 if (res == NULL && PyErr_Occurred()) {
1092 p->error_indicator = 1;
1093 return NULL;
1094 }
1095 goto done;
1096 }
1097 p->mark = mark;
1098 }
1099 res = NULL;
1100 done:
1101 return res;
1102}
1103
1104// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
1105static asdl_seq*
1106simple_stmt_rule(Parser *p)
1107{
1108 if (p->error_indicator) {
1109 return NULL;
1110 }
1111 asdl_seq* res = NULL;
1112 int mark = p->mark;
1113 { // small_stmt !';' NEWLINE
1114 stmt_ty a;
1115 void *newline_var;
1116 if (
1117 (a = small_stmt_rule(p))
1118 &&
1119 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13)
1120 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01001121 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001122 )
1123 {
1124 res = _PyPegen_singleton_seq ( p , a );
1125 if (res == NULL && PyErr_Occurred()) {
1126 p->error_indicator = 1;
1127 return NULL;
1128 }
1129 goto done;
1130 }
1131 p->mark = mark;
1132 }
1133 { // ';'.small_stmt+ ';'? NEWLINE
1134 asdl_seq * a;
1135 void *newline_var;
1136 void *opt_var;
1137 UNUSED(opt_var); // Silence compiler warnings
1138 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001139 (a = _gather_12_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001140 &&
1141 (opt_var = _PyPegen_expect_token(p, 13), 1)
1142 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01001143 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001144 )
1145 {
1146 res = a;
1147 if (res == NULL && PyErr_Occurred()) {
1148 p->error_indicator = 1;
1149 return NULL;
1150 }
1151 goto done;
1152 }
1153 p->mark = mark;
1154 }
1155 res = NULL;
1156 done:
1157 return res;
1158}
1159
1160// small_stmt:
1161// | assignment
1162// | star_expressions
1163// | &'return' return_stmt
1164// | &('import' | 'from') import_stmt
1165// | &'raise' raise_stmt
1166// | 'pass'
1167// | &'del' del_stmt
1168// | &'yield' yield_stmt
1169// | &'assert' assert_stmt
1170// | 'break'
1171// | 'continue'
1172// | &'global' global_stmt
1173// | &'nonlocal' nonlocal_stmt
1174static stmt_ty
1175small_stmt_rule(Parser *p)
1176{
1177 if (p->error_indicator) {
1178 return NULL;
1179 }
1180 stmt_ty res = NULL;
1181 if (_PyPegen_is_memoized(p, small_stmt_type, &res))
1182 return res;
1183 int mark = p->mark;
1184 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1185 p->error_indicator = 1;
1186 return NULL;
1187 }
1188 int start_lineno = p->tokens[mark]->lineno;
1189 UNUSED(start_lineno); // Only used by EXTRA macro
1190 int start_col_offset = p->tokens[mark]->col_offset;
1191 UNUSED(start_col_offset); // Only used by EXTRA macro
1192 { // assignment
1193 void *assignment_var;
1194 if (
1195 (assignment_var = assignment_rule(p))
1196 )
1197 {
1198 res = assignment_var;
1199 goto done;
1200 }
1201 p->mark = mark;
1202 }
1203 { // star_expressions
1204 expr_ty e;
1205 if (
1206 (e = star_expressions_rule(p))
1207 )
1208 {
1209 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1210 if (token == NULL) {
1211 return NULL;
1212 }
1213 int end_lineno = token->end_lineno;
1214 UNUSED(end_lineno); // Only used by EXTRA macro
1215 int end_col_offset = token->end_col_offset;
1216 UNUSED(end_col_offset); // Only used by EXTRA macro
1217 res = _Py_Expr ( e , EXTRA );
1218 if (res == NULL && PyErr_Occurred()) {
1219 p->error_indicator = 1;
1220 return NULL;
1221 }
1222 goto done;
1223 }
1224 p->mark = mark;
1225 }
1226 { // &'return' return_stmt
1227 stmt_ty return_stmt_var;
1228 if (
1229 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500)
1230 &&
1231 (return_stmt_var = return_stmt_rule(p))
1232 )
1233 {
1234 res = return_stmt_var;
1235 goto done;
1236 }
1237 p->mark = mark;
1238 }
1239 { // &('import' | 'from') import_stmt
1240 stmt_ty import_stmt_var;
1241 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001242 _PyPegen_lookahead(1, _tmp_14_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001243 &&
1244 (import_stmt_var = import_stmt_rule(p))
1245 )
1246 {
1247 res = import_stmt_var;
1248 goto done;
1249 }
1250 p->mark = mark;
1251 }
1252 { // &'raise' raise_stmt
1253 stmt_ty raise_stmt_var;
1254 if (
1255 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501)
1256 &&
1257 (raise_stmt_var = raise_stmt_rule(p))
1258 )
1259 {
1260 res = raise_stmt_var;
1261 goto done;
1262 }
1263 p->mark = mark;
1264 }
1265 { // 'pass'
1266 void *keyword;
1267 if (
1268 (keyword = _PyPegen_expect_token(p, 502))
1269 )
1270 {
1271 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1272 if (token == NULL) {
1273 return NULL;
1274 }
1275 int end_lineno = token->end_lineno;
1276 UNUSED(end_lineno); // Only used by EXTRA macro
1277 int end_col_offset = token->end_col_offset;
1278 UNUSED(end_col_offset); // Only used by EXTRA macro
1279 res = _Py_Pass ( EXTRA );
1280 if (res == NULL && PyErr_Occurred()) {
1281 p->error_indicator = 1;
1282 return NULL;
1283 }
1284 goto done;
1285 }
1286 p->mark = mark;
1287 }
1288 { // &'del' del_stmt
1289 stmt_ty del_stmt_var;
1290 if (
1291 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503)
1292 &&
1293 (del_stmt_var = del_stmt_rule(p))
1294 )
1295 {
1296 res = del_stmt_var;
1297 goto done;
1298 }
1299 p->mark = mark;
1300 }
1301 { // &'yield' yield_stmt
1302 stmt_ty yield_stmt_var;
1303 if (
1304 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504)
1305 &&
1306 (yield_stmt_var = yield_stmt_rule(p))
1307 )
1308 {
1309 res = yield_stmt_var;
1310 goto done;
1311 }
1312 p->mark = mark;
1313 }
1314 { // &'assert' assert_stmt
1315 stmt_ty assert_stmt_var;
1316 if (
1317 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505)
1318 &&
1319 (assert_stmt_var = assert_stmt_rule(p))
1320 )
1321 {
1322 res = assert_stmt_var;
1323 goto done;
1324 }
1325 p->mark = mark;
1326 }
1327 { // 'break'
1328 void *keyword;
1329 if (
1330 (keyword = _PyPegen_expect_token(p, 506))
1331 )
1332 {
1333 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1334 if (token == NULL) {
1335 return NULL;
1336 }
1337 int end_lineno = token->end_lineno;
1338 UNUSED(end_lineno); // Only used by EXTRA macro
1339 int end_col_offset = token->end_col_offset;
1340 UNUSED(end_col_offset); // Only used by EXTRA macro
1341 res = _Py_Break ( EXTRA );
1342 if (res == NULL && PyErr_Occurred()) {
1343 p->error_indicator = 1;
1344 return NULL;
1345 }
1346 goto done;
1347 }
1348 p->mark = mark;
1349 }
1350 { // 'continue'
1351 void *keyword;
1352 if (
1353 (keyword = _PyPegen_expect_token(p, 507))
1354 )
1355 {
1356 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1357 if (token == NULL) {
1358 return NULL;
1359 }
1360 int end_lineno = token->end_lineno;
1361 UNUSED(end_lineno); // Only used by EXTRA macro
1362 int end_col_offset = token->end_col_offset;
1363 UNUSED(end_col_offset); // Only used by EXTRA macro
1364 res = _Py_Continue ( EXTRA );
1365 if (res == NULL && PyErr_Occurred()) {
1366 p->error_indicator = 1;
1367 return NULL;
1368 }
1369 goto done;
1370 }
1371 p->mark = mark;
1372 }
1373 { // &'global' global_stmt
1374 stmt_ty global_stmt_var;
1375 if (
1376 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508)
1377 &&
1378 (global_stmt_var = global_stmt_rule(p))
1379 )
1380 {
1381 res = global_stmt_var;
1382 goto done;
1383 }
1384 p->mark = mark;
1385 }
1386 { // &'nonlocal' nonlocal_stmt
1387 stmt_ty nonlocal_stmt_var;
1388 if (
1389 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509)
1390 &&
1391 (nonlocal_stmt_var = nonlocal_stmt_rule(p))
1392 )
1393 {
1394 res = nonlocal_stmt_var;
1395 goto done;
1396 }
1397 p->mark = mark;
1398 }
1399 res = NULL;
1400 done:
1401 _PyPegen_insert_memo(p, mark, small_stmt_type, res);
1402 return res;
1403}
1404
1405// compound_stmt:
1406// | &('def' | '@' | ASYNC) function_def
1407// | &'if' if_stmt
1408// | &('class' | '@') class_def
1409// | &('with' | ASYNC) with_stmt
1410// | &('for' | ASYNC) for_stmt
1411// | &'try' try_stmt
1412// | &'while' while_stmt
1413static stmt_ty
1414compound_stmt_rule(Parser *p)
1415{
1416 if (p->error_indicator) {
1417 return NULL;
1418 }
1419 stmt_ty res = NULL;
1420 int mark = p->mark;
1421 { // &('def' | '@' | ASYNC) function_def
1422 stmt_ty function_def_var;
1423 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001424 _PyPegen_lookahead(1, _tmp_15_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001425 &&
1426 (function_def_var = function_def_rule(p))
1427 )
1428 {
1429 res = function_def_var;
1430 goto done;
1431 }
1432 p->mark = mark;
1433 }
1434 { // &'if' if_stmt
1435 stmt_ty if_stmt_var;
1436 if (
1437 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510)
1438 &&
1439 (if_stmt_var = if_stmt_rule(p))
1440 )
1441 {
1442 res = if_stmt_var;
1443 goto done;
1444 }
1445 p->mark = mark;
1446 }
1447 { // &('class' | '@') class_def
1448 stmt_ty class_def_var;
1449 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001450 _PyPegen_lookahead(1, _tmp_16_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001451 &&
1452 (class_def_var = class_def_rule(p))
1453 )
1454 {
1455 res = class_def_var;
1456 goto done;
1457 }
1458 p->mark = mark;
1459 }
1460 { // &('with' | ASYNC) with_stmt
1461 stmt_ty with_stmt_var;
1462 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001463 _PyPegen_lookahead(1, _tmp_17_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001464 &&
1465 (with_stmt_var = with_stmt_rule(p))
1466 )
1467 {
1468 res = with_stmt_var;
1469 goto done;
1470 }
1471 p->mark = mark;
1472 }
1473 { // &('for' | ASYNC) for_stmt
1474 stmt_ty for_stmt_var;
1475 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001476 _PyPegen_lookahead(1, _tmp_18_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001477 &&
1478 (for_stmt_var = for_stmt_rule(p))
1479 )
1480 {
1481 res = for_stmt_var;
1482 goto done;
1483 }
1484 p->mark = mark;
1485 }
1486 { // &'try' try_stmt
1487 stmt_ty try_stmt_var;
1488 if (
1489 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511)
1490 &&
1491 (try_stmt_var = try_stmt_rule(p))
1492 )
1493 {
1494 res = try_stmt_var;
1495 goto done;
1496 }
1497 p->mark = mark;
1498 }
1499 { // &'while' while_stmt
1500 stmt_ty while_stmt_var;
1501 if (
1502 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512)
1503 &&
1504 (while_stmt_var = while_stmt_rule(p))
1505 )
1506 {
1507 res = while_stmt_var;
1508 goto done;
1509 }
1510 p->mark = mark;
1511 }
1512 res = NULL;
1513 done:
1514 return res;
1515}
1516
1517// assignment:
1518// | NAME ':' expression ['=' annotated_rhs]
1519// | ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs]
Guido van Rossumc001c092020-04-30 12:12:19 -07001520// | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001521// | target augassign (yield_expr | star_expressions)
1522// | invalid_assignment
1523static void *
1524assignment_rule(Parser *p)
1525{
1526 if (p->error_indicator) {
1527 return NULL;
1528 }
1529 void * res = NULL;
1530 int mark = p->mark;
1531 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1532 p->error_indicator = 1;
1533 return NULL;
1534 }
1535 int start_lineno = p->tokens[mark]->lineno;
1536 UNUSED(start_lineno); // Only used by EXTRA macro
1537 int start_col_offset = p->tokens[mark]->col_offset;
1538 UNUSED(start_col_offset); // Only used by EXTRA macro
1539 { // NAME ':' expression ['=' annotated_rhs]
1540 expr_ty a;
1541 expr_ty b;
1542 void *c;
1543 void *literal;
1544 if (
1545 (a = _PyPegen_name_token(p))
1546 &&
1547 (literal = _PyPegen_expect_token(p, 11))
1548 &&
1549 (b = expression_rule(p))
1550 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001551 (c = _tmp_19_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001552 )
1553 {
1554 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1555 if (token == NULL) {
1556 return NULL;
1557 }
1558 int end_lineno = token->end_lineno;
1559 UNUSED(end_lineno); // Only used by EXTRA macro
1560 int end_col_offset = token->end_col_offset;
1561 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001562 res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001563 if (res == NULL && PyErr_Occurred()) {
1564 p->error_indicator = 1;
1565 return NULL;
1566 }
1567 goto done;
1568 }
1569 p->mark = mark;
1570 }
1571 { // ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs]
1572 void *a;
1573 expr_ty b;
1574 void *c;
1575 void *literal;
1576 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001577 (a = _tmp_20_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001578 &&
1579 (literal = _PyPegen_expect_token(p, 11))
1580 &&
1581 (b = expression_rule(p))
1582 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001583 (c = _tmp_21_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001584 )
1585 {
1586 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1587 if (token == NULL) {
1588 return NULL;
1589 }
1590 int end_lineno = token->end_lineno;
1591 UNUSED(end_lineno); // Only used by EXTRA macro
1592 int end_col_offset = token->end_col_offset;
1593 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001594 res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001595 if (res == NULL && PyErr_Occurred()) {
1596 p->error_indicator = 1;
1597 return NULL;
1598 }
1599 goto done;
1600 }
1601 p->mark = mark;
1602 }
Guido van Rossumc001c092020-04-30 12:12:19 -07001603 { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001604 asdl_seq * a;
1605 void *b;
Guido van Rossumc001c092020-04-30 12:12:19 -07001606 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001607 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001608 (a = _loop1_22_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001609 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001610 (b = _tmp_23_rule(p))
1611 &&
1612 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001613 )
1614 {
1615 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1616 if (token == NULL) {
1617 return NULL;
1618 }
1619 int end_lineno = token->end_lineno;
1620 UNUSED(end_lineno); // Only used by EXTRA macro
1621 int end_col_offset = token->end_col_offset;
1622 UNUSED(end_col_offset); // Only used by EXTRA macro
Guido van Rossumc001c092020-04-30 12:12:19 -07001623 res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001624 if (res == NULL && PyErr_Occurred()) {
1625 p->error_indicator = 1;
1626 return NULL;
1627 }
1628 goto done;
1629 }
1630 p->mark = mark;
1631 }
1632 { // target augassign (yield_expr | star_expressions)
1633 expr_ty a;
1634 AugOperator* b;
1635 void *c;
1636 if (
1637 (a = target_rule(p))
1638 &&
1639 (b = augassign_rule(p))
1640 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001641 (c = _tmp_24_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001642 )
1643 {
1644 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1645 if (token == NULL) {
1646 return NULL;
1647 }
1648 int end_lineno = token->end_lineno;
1649 UNUSED(end_lineno); // Only used by EXTRA macro
1650 int end_col_offset = token->end_col_offset;
1651 UNUSED(end_col_offset); // Only used by EXTRA macro
1652 res = _Py_AugAssign ( a , b -> kind , c , EXTRA );
1653 if (res == NULL && PyErr_Occurred()) {
1654 p->error_indicator = 1;
1655 return NULL;
1656 }
1657 goto done;
1658 }
1659 p->mark = mark;
1660 }
1661 { // invalid_assignment
1662 void *invalid_assignment_var;
1663 if (
1664 (invalid_assignment_var = invalid_assignment_rule(p))
1665 )
1666 {
1667 res = invalid_assignment_var;
1668 goto done;
1669 }
1670 p->mark = mark;
1671 }
1672 res = NULL;
1673 done:
1674 return res;
1675}
1676
1677// augassign:
1678// | '+='
1679// | '-='
1680// | '*='
1681// | '@='
1682// | '/='
1683// | '%='
1684// | '&='
1685// | '|='
1686// | '^='
1687// | '<<='
1688// | '>>='
1689// | '**='
1690// | '//='
1691static AugOperator*
1692augassign_rule(Parser *p)
1693{
1694 if (p->error_indicator) {
1695 return NULL;
1696 }
1697 AugOperator* res = NULL;
1698 int mark = p->mark;
1699 { // '+='
1700 void *literal;
1701 if (
1702 (literal = _PyPegen_expect_token(p, 36))
1703 )
1704 {
1705 res = _PyPegen_augoperator ( p , Add );
1706 if (res == NULL && PyErr_Occurred()) {
1707 p->error_indicator = 1;
1708 return NULL;
1709 }
1710 goto done;
1711 }
1712 p->mark = mark;
1713 }
1714 { // '-='
1715 void *literal;
1716 if (
1717 (literal = _PyPegen_expect_token(p, 37))
1718 )
1719 {
1720 res = _PyPegen_augoperator ( p , Sub );
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 { // '*='
1730 void *literal;
1731 if (
1732 (literal = _PyPegen_expect_token(p, 38))
1733 )
1734 {
1735 res = _PyPegen_augoperator ( p , Mult );
1736 if (res == NULL && PyErr_Occurred()) {
1737 p->error_indicator = 1;
1738 return NULL;
1739 }
1740 goto done;
1741 }
1742 p->mark = mark;
1743 }
1744 { // '@='
1745 void *literal;
1746 if (
1747 (literal = _PyPegen_expect_token(p, 50))
1748 )
1749 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001750 res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001751 if (res == NULL && PyErr_Occurred()) {
1752 p->error_indicator = 1;
1753 return NULL;
1754 }
1755 goto done;
1756 }
1757 p->mark = mark;
1758 }
1759 { // '/='
1760 void *literal;
1761 if (
1762 (literal = _PyPegen_expect_token(p, 39))
1763 )
1764 {
1765 res = _PyPegen_augoperator ( p , Div );
1766 if (res == NULL && PyErr_Occurred()) {
1767 p->error_indicator = 1;
1768 return NULL;
1769 }
1770 goto done;
1771 }
1772 p->mark = mark;
1773 }
1774 { // '%='
1775 void *literal;
1776 if (
1777 (literal = _PyPegen_expect_token(p, 40))
1778 )
1779 {
1780 res = _PyPegen_augoperator ( p , Mod );
1781 if (res == NULL && PyErr_Occurred()) {
1782 p->error_indicator = 1;
1783 return NULL;
1784 }
1785 goto done;
1786 }
1787 p->mark = mark;
1788 }
1789 { // '&='
1790 void *literal;
1791 if (
1792 (literal = _PyPegen_expect_token(p, 41))
1793 )
1794 {
1795 res = _PyPegen_augoperator ( p , BitAnd );
1796 if (res == NULL && PyErr_Occurred()) {
1797 p->error_indicator = 1;
1798 return NULL;
1799 }
1800 goto done;
1801 }
1802 p->mark = mark;
1803 }
1804 { // '|='
1805 void *literal;
1806 if (
1807 (literal = _PyPegen_expect_token(p, 42))
1808 )
1809 {
1810 res = _PyPegen_augoperator ( p , BitOr );
1811 if (res == NULL && PyErr_Occurred()) {
1812 p->error_indicator = 1;
1813 return NULL;
1814 }
1815 goto done;
1816 }
1817 p->mark = mark;
1818 }
1819 { // '^='
1820 void *literal;
1821 if (
1822 (literal = _PyPegen_expect_token(p, 43))
1823 )
1824 {
1825 res = _PyPegen_augoperator ( p , BitXor );
1826 if (res == NULL && PyErr_Occurred()) {
1827 p->error_indicator = 1;
1828 return NULL;
1829 }
1830 goto done;
1831 }
1832 p->mark = mark;
1833 }
1834 { // '<<='
1835 void *literal;
1836 if (
1837 (literal = _PyPegen_expect_token(p, 44))
1838 )
1839 {
1840 res = _PyPegen_augoperator ( p , LShift );
1841 if (res == NULL && PyErr_Occurred()) {
1842 p->error_indicator = 1;
1843 return NULL;
1844 }
1845 goto done;
1846 }
1847 p->mark = mark;
1848 }
1849 { // '>>='
1850 void *literal;
1851 if (
1852 (literal = _PyPegen_expect_token(p, 45))
1853 )
1854 {
1855 res = _PyPegen_augoperator ( p , RShift );
1856 if (res == NULL && PyErr_Occurred()) {
1857 p->error_indicator = 1;
1858 return NULL;
1859 }
1860 goto done;
1861 }
1862 p->mark = mark;
1863 }
1864 { // '**='
1865 void *literal;
1866 if (
1867 (literal = _PyPegen_expect_token(p, 46))
1868 )
1869 {
1870 res = _PyPegen_augoperator ( p , Pow );
1871 if (res == NULL && PyErr_Occurred()) {
1872 p->error_indicator = 1;
1873 return NULL;
1874 }
1875 goto done;
1876 }
1877 p->mark = mark;
1878 }
1879 { // '//='
1880 void *literal;
1881 if (
1882 (literal = _PyPegen_expect_token(p, 48))
1883 )
1884 {
1885 res = _PyPegen_augoperator ( p , FloorDiv );
1886 if (res == NULL && PyErr_Occurred()) {
1887 p->error_indicator = 1;
1888 return NULL;
1889 }
1890 goto done;
1891 }
1892 p->mark = mark;
1893 }
1894 res = NULL;
1895 done:
1896 return res;
1897}
1898
1899// global_stmt: 'global' ','.NAME+
1900static stmt_ty
1901global_stmt_rule(Parser *p)
1902{
1903 if (p->error_indicator) {
1904 return NULL;
1905 }
1906 stmt_ty res = NULL;
1907 int mark = p->mark;
1908 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1909 p->error_indicator = 1;
1910 return NULL;
1911 }
1912 int start_lineno = p->tokens[mark]->lineno;
1913 UNUSED(start_lineno); // Only used by EXTRA macro
1914 int start_col_offset = p->tokens[mark]->col_offset;
1915 UNUSED(start_col_offset); // Only used by EXTRA macro
1916 { // 'global' ','.NAME+
1917 asdl_seq * a;
1918 void *keyword;
1919 if (
1920 (keyword = _PyPegen_expect_token(p, 508))
1921 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001922 (a = _gather_25_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001923 )
1924 {
1925 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1926 if (token == NULL) {
1927 return NULL;
1928 }
1929 int end_lineno = token->end_lineno;
1930 UNUSED(end_lineno); // Only used by EXTRA macro
1931 int end_col_offset = token->end_col_offset;
1932 UNUSED(end_col_offset); // Only used by EXTRA macro
1933 res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
1934 if (res == NULL && PyErr_Occurred()) {
1935 p->error_indicator = 1;
1936 return NULL;
1937 }
1938 goto done;
1939 }
1940 p->mark = mark;
1941 }
1942 res = NULL;
1943 done:
1944 return res;
1945}
1946
1947// nonlocal_stmt: 'nonlocal' ','.NAME+
1948static stmt_ty
1949nonlocal_stmt_rule(Parser *p)
1950{
1951 if (p->error_indicator) {
1952 return NULL;
1953 }
1954 stmt_ty res = NULL;
1955 int mark = p->mark;
1956 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1957 p->error_indicator = 1;
1958 return NULL;
1959 }
1960 int start_lineno = p->tokens[mark]->lineno;
1961 UNUSED(start_lineno); // Only used by EXTRA macro
1962 int start_col_offset = p->tokens[mark]->col_offset;
1963 UNUSED(start_col_offset); // Only used by EXTRA macro
1964 { // 'nonlocal' ','.NAME+
1965 asdl_seq * a;
1966 void *keyword;
1967 if (
1968 (keyword = _PyPegen_expect_token(p, 509))
1969 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001970 (a = _gather_27_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001971 )
1972 {
1973 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1974 if (token == NULL) {
1975 return NULL;
1976 }
1977 int end_lineno = token->end_lineno;
1978 UNUSED(end_lineno); // Only used by EXTRA macro
1979 int end_col_offset = token->end_col_offset;
1980 UNUSED(end_col_offset); // Only used by EXTRA macro
1981 res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
1982 if (res == NULL && PyErr_Occurred()) {
1983 p->error_indicator = 1;
1984 return NULL;
1985 }
1986 goto done;
1987 }
1988 p->mark = mark;
1989 }
1990 res = NULL;
1991 done:
1992 return res;
1993}
1994
1995// yield_stmt: yield_expr
1996static stmt_ty
1997yield_stmt_rule(Parser *p)
1998{
1999 if (p->error_indicator) {
2000 return NULL;
2001 }
2002 stmt_ty res = NULL;
2003 int mark = p->mark;
2004 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2005 p->error_indicator = 1;
2006 return NULL;
2007 }
2008 int start_lineno = p->tokens[mark]->lineno;
2009 UNUSED(start_lineno); // Only used by EXTRA macro
2010 int start_col_offset = p->tokens[mark]->col_offset;
2011 UNUSED(start_col_offset); // Only used by EXTRA macro
2012 { // yield_expr
2013 expr_ty y;
2014 if (
2015 (y = yield_expr_rule(p))
2016 )
2017 {
2018 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2019 if (token == NULL) {
2020 return NULL;
2021 }
2022 int end_lineno = token->end_lineno;
2023 UNUSED(end_lineno); // Only used by EXTRA macro
2024 int end_col_offset = token->end_col_offset;
2025 UNUSED(end_col_offset); // Only used by EXTRA macro
2026 res = _Py_Expr ( y , EXTRA );
2027 if (res == NULL && PyErr_Occurred()) {
2028 p->error_indicator = 1;
2029 return NULL;
2030 }
2031 goto done;
2032 }
2033 p->mark = mark;
2034 }
2035 res = NULL;
2036 done:
2037 return res;
2038}
2039
2040// assert_stmt: 'assert' expression [',' expression]
2041static stmt_ty
2042assert_stmt_rule(Parser *p)
2043{
2044 if (p->error_indicator) {
2045 return NULL;
2046 }
2047 stmt_ty res = NULL;
2048 int mark = p->mark;
2049 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2050 p->error_indicator = 1;
2051 return NULL;
2052 }
2053 int start_lineno = p->tokens[mark]->lineno;
2054 UNUSED(start_lineno); // Only used by EXTRA macro
2055 int start_col_offset = p->tokens[mark]->col_offset;
2056 UNUSED(start_col_offset); // Only used by EXTRA macro
2057 { // 'assert' expression [',' expression]
2058 expr_ty a;
2059 void *b;
2060 void *keyword;
2061 if (
2062 (keyword = _PyPegen_expect_token(p, 505))
2063 &&
2064 (a = expression_rule(p))
2065 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002066 (b = _tmp_29_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002067 )
2068 {
2069 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2070 if (token == NULL) {
2071 return NULL;
2072 }
2073 int end_lineno = token->end_lineno;
2074 UNUSED(end_lineno); // Only used by EXTRA macro
2075 int end_col_offset = token->end_col_offset;
2076 UNUSED(end_col_offset); // Only used by EXTRA macro
2077 res = _Py_Assert ( a , b , EXTRA );
2078 if (res == NULL && PyErr_Occurred()) {
2079 p->error_indicator = 1;
2080 return NULL;
2081 }
2082 goto done;
2083 }
2084 p->mark = mark;
2085 }
2086 res = NULL;
2087 done:
2088 return res;
2089}
2090
2091// del_stmt: 'del' del_targets
2092static stmt_ty
2093del_stmt_rule(Parser *p)
2094{
2095 if (p->error_indicator) {
2096 return NULL;
2097 }
2098 stmt_ty res = NULL;
2099 int mark = p->mark;
2100 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2101 p->error_indicator = 1;
2102 return NULL;
2103 }
2104 int start_lineno = p->tokens[mark]->lineno;
2105 UNUSED(start_lineno); // Only used by EXTRA macro
2106 int start_col_offset = p->tokens[mark]->col_offset;
2107 UNUSED(start_col_offset); // Only used by EXTRA macro
2108 { // 'del' del_targets
2109 asdl_seq* a;
2110 void *keyword;
2111 if (
2112 (keyword = _PyPegen_expect_token(p, 503))
2113 &&
2114 (a = del_targets_rule(p))
2115 )
2116 {
2117 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2118 if (token == NULL) {
2119 return NULL;
2120 }
2121 int end_lineno = token->end_lineno;
2122 UNUSED(end_lineno); // Only used by EXTRA macro
2123 int end_col_offset = token->end_col_offset;
2124 UNUSED(end_col_offset); // Only used by EXTRA macro
2125 res = _Py_Delete ( a , EXTRA );
2126 if (res == NULL && PyErr_Occurred()) {
2127 p->error_indicator = 1;
2128 return NULL;
2129 }
2130 goto done;
2131 }
2132 p->mark = mark;
2133 }
2134 res = NULL;
2135 done:
2136 return res;
2137}
2138
2139// import_stmt: import_name | import_from
2140static stmt_ty
2141import_stmt_rule(Parser *p)
2142{
2143 if (p->error_indicator) {
2144 return NULL;
2145 }
2146 stmt_ty res = NULL;
2147 int mark = p->mark;
2148 { // import_name
2149 stmt_ty import_name_var;
2150 if (
2151 (import_name_var = import_name_rule(p))
2152 )
2153 {
2154 res = import_name_var;
2155 goto done;
2156 }
2157 p->mark = mark;
2158 }
2159 { // import_from
2160 stmt_ty import_from_var;
2161 if (
2162 (import_from_var = import_from_rule(p))
2163 )
2164 {
2165 res = import_from_var;
2166 goto done;
2167 }
2168 p->mark = mark;
2169 }
2170 res = NULL;
2171 done:
2172 return res;
2173}
2174
2175// import_name: 'import' dotted_as_names
2176static stmt_ty
2177import_name_rule(Parser *p)
2178{
2179 if (p->error_indicator) {
2180 return NULL;
2181 }
2182 stmt_ty res = NULL;
2183 int mark = p->mark;
2184 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2185 p->error_indicator = 1;
2186 return NULL;
2187 }
2188 int start_lineno = p->tokens[mark]->lineno;
2189 UNUSED(start_lineno); // Only used by EXTRA macro
2190 int start_col_offset = p->tokens[mark]->col_offset;
2191 UNUSED(start_col_offset); // Only used by EXTRA macro
2192 { // 'import' dotted_as_names
2193 asdl_seq* a;
2194 void *keyword;
2195 if (
2196 (keyword = _PyPegen_expect_token(p, 513))
2197 &&
2198 (a = dotted_as_names_rule(p))
2199 )
2200 {
2201 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2202 if (token == NULL) {
2203 return NULL;
2204 }
2205 int end_lineno = token->end_lineno;
2206 UNUSED(end_lineno); // Only used by EXTRA macro
2207 int end_col_offset = token->end_col_offset;
2208 UNUSED(end_col_offset); // Only used by EXTRA macro
2209 res = _Py_Import ( a , EXTRA );
2210 if (res == NULL && PyErr_Occurred()) {
2211 p->error_indicator = 1;
2212 return NULL;
2213 }
2214 goto done;
2215 }
2216 p->mark = mark;
2217 }
2218 res = NULL;
2219 done:
2220 return res;
2221}
2222
2223// import_from:
2224// | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
2225// | 'from' (('.' | '...'))+ 'import' import_from_targets
2226static stmt_ty
2227import_from_rule(Parser *p)
2228{
2229 if (p->error_indicator) {
2230 return NULL;
2231 }
2232 stmt_ty res = NULL;
2233 int mark = p->mark;
2234 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2235 p->error_indicator = 1;
2236 return NULL;
2237 }
2238 int start_lineno = p->tokens[mark]->lineno;
2239 UNUSED(start_lineno); // Only used by EXTRA macro
2240 int start_col_offset = p->tokens[mark]->col_offset;
2241 UNUSED(start_col_offset); // Only used by EXTRA macro
2242 { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
2243 asdl_seq * a;
2244 expr_ty b;
2245 asdl_seq* c;
2246 void *keyword;
2247 void *keyword_1;
2248 if (
2249 (keyword = _PyPegen_expect_token(p, 514))
2250 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002251 (a = _loop0_30_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002252 &&
2253 (b = dotted_name_rule(p))
2254 &&
2255 (keyword_1 = _PyPegen_expect_token(p, 513))
2256 &&
2257 (c = import_from_targets_rule(p))
2258 )
2259 {
2260 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2261 if (token == NULL) {
2262 return NULL;
2263 }
2264 int end_lineno = token->end_lineno;
2265 UNUSED(end_lineno); // Only used by EXTRA macro
2266 int end_col_offset = token->end_col_offset;
2267 UNUSED(end_col_offset); // Only used by EXTRA macro
2268 res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA );
2269 if (res == NULL && PyErr_Occurred()) {
2270 p->error_indicator = 1;
2271 return NULL;
2272 }
2273 goto done;
2274 }
2275 p->mark = mark;
2276 }
2277 { // 'from' (('.' | '...'))+ 'import' import_from_targets
2278 asdl_seq * a;
2279 asdl_seq* b;
2280 void *keyword;
2281 void *keyword_1;
2282 if (
2283 (keyword = _PyPegen_expect_token(p, 514))
2284 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002285 (a = _loop1_31_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002286 &&
2287 (keyword_1 = _PyPegen_expect_token(p, 513))
2288 &&
2289 (b = import_from_targets_rule(p))
2290 )
2291 {
2292 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2293 if (token == NULL) {
2294 return NULL;
2295 }
2296 int end_lineno = token->end_lineno;
2297 UNUSED(end_lineno); // Only used by EXTRA macro
2298 int end_col_offset = token->end_col_offset;
2299 UNUSED(end_col_offset); // Only used by EXTRA macro
2300 res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA );
2301 if (res == NULL && PyErr_Occurred()) {
2302 p->error_indicator = 1;
2303 return NULL;
2304 }
2305 goto done;
2306 }
2307 p->mark = mark;
2308 }
2309 res = NULL;
2310 done:
2311 return res;
2312}
2313
2314// import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*'
2315static asdl_seq*
2316import_from_targets_rule(Parser *p)
2317{
2318 if (p->error_indicator) {
2319 return NULL;
2320 }
2321 asdl_seq* res = NULL;
2322 int mark = p->mark;
2323 { // '(' import_from_as_names ','? ')'
2324 asdl_seq* a;
2325 void *literal;
2326 void *literal_1;
2327 void *opt_var;
2328 UNUSED(opt_var); // Silence compiler warnings
2329 if (
2330 (literal = _PyPegen_expect_token(p, 7))
2331 &&
2332 (a = import_from_as_names_rule(p))
2333 &&
2334 (opt_var = _PyPegen_expect_token(p, 12), 1)
2335 &&
2336 (literal_1 = _PyPegen_expect_token(p, 8))
2337 )
2338 {
2339 res = a;
2340 if (res == NULL && PyErr_Occurred()) {
2341 p->error_indicator = 1;
2342 return NULL;
2343 }
2344 goto done;
2345 }
2346 p->mark = mark;
2347 }
2348 { // import_from_as_names
2349 asdl_seq* import_from_as_names_var;
2350 if (
2351 (import_from_as_names_var = import_from_as_names_rule(p))
2352 )
2353 {
2354 res = import_from_as_names_var;
2355 goto done;
2356 }
2357 p->mark = mark;
2358 }
2359 { // '*'
2360 void *literal;
2361 if (
2362 (literal = _PyPegen_expect_token(p, 16))
2363 )
2364 {
2365 res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) );
2366 if (res == NULL && PyErr_Occurred()) {
2367 p->error_indicator = 1;
2368 return NULL;
2369 }
2370 goto done;
2371 }
2372 p->mark = mark;
2373 }
2374 res = NULL;
2375 done:
2376 return res;
2377}
2378
2379// import_from_as_names: ','.import_from_as_name+
2380static asdl_seq*
2381import_from_as_names_rule(Parser *p)
2382{
2383 if (p->error_indicator) {
2384 return NULL;
2385 }
2386 asdl_seq* res = NULL;
2387 int mark = p->mark;
2388 { // ','.import_from_as_name+
2389 asdl_seq * a;
2390 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07002391 (a = _gather_32_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002392 )
2393 {
2394 res = a;
2395 if (res == NULL && PyErr_Occurred()) {
2396 p->error_indicator = 1;
2397 return NULL;
2398 }
2399 goto done;
2400 }
2401 p->mark = mark;
2402 }
2403 res = NULL;
2404 done:
2405 return res;
2406}
2407
2408// import_from_as_name: NAME ['as' NAME]
2409static alias_ty
2410import_from_as_name_rule(Parser *p)
2411{
2412 if (p->error_indicator) {
2413 return NULL;
2414 }
2415 alias_ty res = NULL;
2416 int mark = p->mark;
2417 { // NAME ['as' NAME]
2418 expr_ty a;
2419 void *b;
2420 if (
2421 (a = _PyPegen_name_token(p))
2422 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002423 (b = _tmp_34_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002424 )
2425 {
2426 res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
2427 if (res == NULL && PyErr_Occurred()) {
2428 p->error_indicator = 1;
2429 return NULL;
2430 }
2431 goto done;
2432 }
2433 p->mark = mark;
2434 }
2435 res = NULL;
2436 done:
2437 return res;
2438}
2439
2440// dotted_as_names: ','.dotted_as_name+
2441static asdl_seq*
2442dotted_as_names_rule(Parser *p)
2443{
2444 if (p->error_indicator) {
2445 return NULL;
2446 }
2447 asdl_seq* res = NULL;
2448 int mark = p->mark;
2449 { // ','.dotted_as_name+
2450 asdl_seq * a;
2451 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07002452 (a = _gather_35_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002453 )
2454 {
2455 res = a;
2456 if (res == NULL && PyErr_Occurred()) {
2457 p->error_indicator = 1;
2458 return NULL;
2459 }
2460 goto done;
2461 }
2462 p->mark = mark;
2463 }
2464 res = NULL;
2465 done:
2466 return res;
2467}
2468
2469// dotted_as_name: dotted_name ['as' NAME]
2470static alias_ty
2471dotted_as_name_rule(Parser *p)
2472{
2473 if (p->error_indicator) {
2474 return NULL;
2475 }
2476 alias_ty res = NULL;
2477 int mark = p->mark;
2478 { // dotted_name ['as' NAME]
2479 expr_ty a;
2480 void *b;
2481 if (
2482 (a = dotted_name_rule(p))
2483 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002484 (b = _tmp_37_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002485 )
2486 {
2487 res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
2488 if (res == NULL && PyErr_Occurred()) {
2489 p->error_indicator = 1;
2490 return NULL;
2491 }
2492 goto done;
2493 }
2494 p->mark = mark;
2495 }
2496 res = NULL;
2497 done:
2498 return res;
2499}
2500
2501// Left-recursive
2502// dotted_name: dotted_name '.' NAME | NAME
2503static expr_ty dotted_name_raw(Parser *);
2504static expr_ty
2505dotted_name_rule(Parser *p)
2506{
2507 expr_ty res = NULL;
2508 if (_PyPegen_is_memoized(p, dotted_name_type, &res))
2509 return res;
2510 int mark = p->mark;
2511 int resmark = p->mark;
2512 while (1) {
2513 int tmpvar_0 = _PyPegen_update_memo(p, mark, dotted_name_type, res);
2514 if (tmpvar_0) {
2515 return res;
2516 }
2517 p->mark = mark;
2518 void *raw = dotted_name_raw(p);
2519 if (raw == NULL || p->mark <= resmark)
2520 break;
2521 resmark = p->mark;
2522 res = raw;
2523 }
2524 p->mark = resmark;
2525 return res;
2526}
2527static expr_ty
2528dotted_name_raw(Parser *p)
2529{
2530 if (p->error_indicator) {
2531 return NULL;
2532 }
2533 expr_ty res = NULL;
2534 int mark = p->mark;
2535 { // dotted_name '.' NAME
2536 expr_ty a;
2537 expr_ty b;
2538 void *literal;
2539 if (
2540 (a = dotted_name_rule(p))
2541 &&
2542 (literal = _PyPegen_expect_token(p, 23))
2543 &&
2544 (b = _PyPegen_name_token(p))
2545 )
2546 {
2547 res = _PyPegen_join_names_with_dot ( p , a , b );
2548 if (res == NULL && PyErr_Occurred()) {
2549 p->error_indicator = 1;
2550 return NULL;
2551 }
2552 goto done;
2553 }
2554 p->mark = mark;
2555 }
2556 { // NAME
2557 expr_ty name_var;
2558 if (
2559 (name_var = _PyPegen_name_token(p))
2560 )
2561 {
2562 res = name_var;
2563 goto done;
2564 }
2565 p->mark = mark;
2566 }
2567 res = NULL;
2568 done:
2569 return res;
2570}
2571
2572// if_stmt:
2573// | 'if' named_expression ':' block elif_stmt
2574// | 'if' named_expression ':' block else_block?
2575static stmt_ty
2576if_stmt_rule(Parser *p)
2577{
2578 if (p->error_indicator) {
2579 return NULL;
2580 }
2581 stmt_ty res = NULL;
2582 int mark = p->mark;
2583 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2584 p->error_indicator = 1;
2585 return NULL;
2586 }
2587 int start_lineno = p->tokens[mark]->lineno;
2588 UNUSED(start_lineno); // Only used by EXTRA macro
2589 int start_col_offset = p->tokens[mark]->col_offset;
2590 UNUSED(start_col_offset); // Only used by EXTRA macro
2591 { // 'if' named_expression ':' block elif_stmt
2592 expr_ty a;
2593 asdl_seq* b;
2594 stmt_ty c;
2595 void *keyword;
2596 void *literal;
2597 if (
2598 (keyword = _PyPegen_expect_token(p, 510))
2599 &&
2600 (a = named_expression_rule(p))
2601 &&
2602 (literal = _PyPegen_expect_token(p, 11))
2603 &&
2604 (b = block_rule(p))
2605 &&
2606 (c = elif_stmt_rule(p))
2607 )
2608 {
2609 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2610 if (token == NULL) {
2611 return NULL;
2612 }
2613 int end_lineno = token->end_lineno;
2614 UNUSED(end_lineno); // Only used by EXTRA macro
2615 int end_col_offset = token->end_col_offset;
2616 UNUSED(end_col_offset); // Only used by EXTRA macro
2617 res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
2618 if (res == NULL && PyErr_Occurred()) {
2619 p->error_indicator = 1;
2620 return NULL;
2621 }
2622 goto done;
2623 }
2624 p->mark = mark;
2625 }
2626 { // 'if' named_expression ':' block else_block?
2627 expr_ty a;
2628 asdl_seq* b;
2629 void *c;
2630 void *keyword;
2631 void *literal;
2632 if (
2633 (keyword = _PyPegen_expect_token(p, 510))
2634 &&
2635 (a = named_expression_rule(p))
2636 &&
2637 (literal = _PyPegen_expect_token(p, 11))
2638 &&
2639 (b = block_rule(p))
2640 &&
2641 (c = else_block_rule(p), 1)
2642 )
2643 {
2644 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2645 if (token == NULL) {
2646 return NULL;
2647 }
2648 int end_lineno = token->end_lineno;
2649 UNUSED(end_lineno); // Only used by EXTRA macro
2650 int end_col_offset = token->end_col_offset;
2651 UNUSED(end_col_offset); // Only used by EXTRA macro
2652 res = _Py_If ( a , b , c , EXTRA );
2653 if (res == NULL && PyErr_Occurred()) {
2654 p->error_indicator = 1;
2655 return NULL;
2656 }
2657 goto done;
2658 }
2659 p->mark = mark;
2660 }
2661 res = NULL;
2662 done:
2663 return res;
2664}
2665
2666// elif_stmt:
2667// | 'elif' named_expression ':' block elif_stmt
2668// | 'elif' named_expression ':' block else_block?
2669static stmt_ty
2670elif_stmt_rule(Parser *p)
2671{
2672 if (p->error_indicator) {
2673 return NULL;
2674 }
2675 stmt_ty res = NULL;
2676 int mark = p->mark;
2677 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2678 p->error_indicator = 1;
2679 return NULL;
2680 }
2681 int start_lineno = p->tokens[mark]->lineno;
2682 UNUSED(start_lineno); // Only used by EXTRA macro
2683 int start_col_offset = p->tokens[mark]->col_offset;
2684 UNUSED(start_col_offset); // Only used by EXTRA macro
2685 { // 'elif' named_expression ':' block elif_stmt
2686 expr_ty a;
2687 asdl_seq* b;
2688 stmt_ty c;
2689 void *keyword;
2690 void *literal;
2691 if (
2692 (keyword = _PyPegen_expect_token(p, 515))
2693 &&
2694 (a = named_expression_rule(p))
2695 &&
2696 (literal = _PyPegen_expect_token(p, 11))
2697 &&
2698 (b = block_rule(p))
2699 &&
2700 (c = elif_stmt_rule(p))
2701 )
2702 {
2703 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2704 if (token == NULL) {
2705 return NULL;
2706 }
2707 int end_lineno = token->end_lineno;
2708 UNUSED(end_lineno); // Only used by EXTRA macro
2709 int end_col_offset = token->end_col_offset;
2710 UNUSED(end_col_offset); // Only used by EXTRA macro
2711 res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
2712 if (res == NULL && PyErr_Occurred()) {
2713 p->error_indicator = 1;
2714 return NULL;
2715 }
2716 goto done;
2717 }
2718 p->mark = mark;
2719 }
2720 { // 'elif' named_expression ':' block else_block?
2721 expr_ty a;
2722 asdl_seq* b;
2723 void *c;
2724 void *keyword;
2725 void *literal;
2726 if (
2727 (keyword = _PyPegen_expect_token(p, 515))
2728 &&
2729 (a = named_expression_rule(p))
2730 &&
2731 (literal = _PyPegen_expect_token(p, 11))
2732 &&
2733 (b = block_rule(p))
2734 &&
2735 (c = else_block_rule(p), 1)
2736 )
2737 {
2738 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2739 if (token == NULL) {
2740 return NULL;
2741 }
2742 int end_lineno = token->end_lineno;
2743 UNUSED(end_lineno); // Only used by EXTRA macro
2744 int end_col_offset = token->end_col_offset;
2745 UNUSED(end_col_offset); // Only used by EXTRA macro
2746 res = _Py_If ( a , b , c , EXTRA );
2747 if (res == NULL && PyErr_Occurred()) {
2748 p->error_indicator = 1;
2749 return NULL;
2750 }
2751 goto done;
2752 }
2753 p->mark = mark;
2754 }
2755 res = NULL;
2756 done:
2757 return res;
2758}
2759
2760// else_block: 'else' ':' block
2761static asdl_seq*
2762else_block_rule(Parser *p)
2763{
2764 if (p->error_indicator) {
2765 return NULL;
2766 }
2767 asdl_seq* res = NULL;
2768 int mark = p->mark;
2769 { // 'else' ':' block
2770 asdl_seq* b;
2771 void *keyword;
2772 void *literal;
2773 if (
2774 (keyword = _PyPegen_expect_token(p, 516))
2775 &&
2776 (literal = _PyPegen_expect_token(p, 11))
2777 &&
2778 (b = block_rule(p))
2779 )
2780 {
2781 res = b;
2782 if (res == NULL && PyErr_Occurred()) {
2783 p->error_indicator = 1;
2784 return NULL;
2785 }
2786 goto done;
2787 }
2788 p->mark = mark;
2789 }
2790 res = NULL;
2791 done:
2792 return res;
2793}
2794
2795// while_stmt: 'while' named_expression ':' block else_block?
2796static stmt_ty
2797while_stmt_rule(Parser *p)
2798{
2799 if (p->error_indicator) {
2800 return NULL;
2801 }
2802 stmt_ty res = NULL;
2803 int mark = p->mark;
2804 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2805 p->error_indicator = 1;
2806 return NULL;
2807 }
2808 int start_lineno = p->tokens[mark]->lineno;
2809 UNUSED(start_lineno); // Only used by EXTRA macro
2810 int start_col_offset = p->tokens[mark]->col_offset;
2811 UNUSED(start_col_offset); // Only used by EXTRA macro
2812 { // 'while' named_expression ':' block else_block?
2813 expr_ty a;
2814 asdl_seq* b;
2815 void *c;
2816 void *keyword;
2817 void *literal;
2818 if (
2819 (keyword = _PyPegen_expect_token(p, 512))
2820 &&
2821 (a = named_expression_rule(p))
2822 &&
2823 (literal = _PyPegen_expect_token(p, 11))
2824 &&
2825 (b = block_rule(p))
2826 &&
2827 (c = else_block_rule(p), 1)
2828 )
2829 {
2830 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2831 if (token == NULL) {
2832 return NULL;
2833 }
2834 int end_lineno = token->end_lineno;
2835 UNUSED(end_lineno); // Only used by EXTRA macro
2836 int end_col_offset = token->end_col_offset;
2837 UNUSED(end_col_offset); // Only used by EXTRA macro
2838 res = _Py_While ( a , b , c , EXTRA );
2839 if (res == NULL && PyErr_Occurred()) {
2840 p->error_indicator = 1;
2841 return NULL;
2842 }
2843 goto done;
2844 }
2845 p->mark = mark;
2846 }
2847 res = NULL;
2848 done:
2849 return res;
2850}
2851
Guido van Rossumc001c092020-04-30 12:12:19 -07002852// for_stmt:
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002853// | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
2854// | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002855static stmt_ty
2856for_stmt_rule(Parser *p)
2857{
2858 if (p->error_indicator) {
2859 return NULL;
2860 }
2861 stmt_ty res = NULL;
2862 int mark = p->mark;
2863 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2864 p->error_indicator = 1;
2865 return NULL;
2866 }
2867 int start_lineno = p->tokens[mark]->lineno;
2868 UNUSED(start_lineno); // Only used by EXTRA macro
2869 int start_col_offset = p->tokens[mark]->col_offset;
2870 UNUSED(start_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002871 { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002872 asdl_seq* b;
2873 void *el;
2874 expr_ty ex;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002875 void *keyword;
2876 void *keyword_1;
2877 void *literal;
2878 expr_ty t;
Guido van Rossumc001c092020-04-30 12:12:19 -07002879 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002880 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002881 (keyword = _PyPegen_expect_token(p, 517))
2882 &&
2883 (t = star_targets_rule(p))
2884 &&
2885 (keyword_1 = _PyPegen_expect_token(p, 518))
2886 &&
2887 (ex = star_expressions_rule(p))
2888 &&
2889 (literal = _PyPegen_expect_token(p, 11))
2890 &&
2891 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
2892 &&
2893 (b = block_rule(p))
2894 &&
2895 (el = else_block_rule(p), 1)
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_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , 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 { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
2916 void *async_var;
2917 asdl_seq* b;
2918 void *el;
2919 expr_ty ex;
2920 void *keyword;
2921 void *keyword_1;
2922 void *literal;
2923 expr_ty t;
2924 void *tc;
2925 if (
2926 (async_var = _PyPegen_expect_token(p, ASYNC))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002927 &&
2928 (keyword = _PyPegen_expect_token(p, 517))
2929 &&
2930 (t = star_targets_rule(p))
2931 &&
2932 (keyword_1 = _PyPegen_expect_token(p, 518))
2933 &&
2934 (ex = star_expressions_rule(p))
2935 &&
2936 (literal = _PyPegen_expect_token(p, 11))
2937 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002938 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
2939 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002940 (b = block_rule(p))
2941 &&
2942 (el = else_block_rule(p), 1)
2943 )
2944 {
2945 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2946 if (token == NULL) {
2947 return NULL;
2948 }
2949 int end_lineno = token->end_lineno;
2950 UNUSED(end_lineno); // Only used by EXTRA macro
2951 int end_col_offset = token->end_col_offset;
2952 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002953 res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002954 if (res == NULL && PyErr_Occurred()) {
2955 p->error_indicator = 1;
2956 return NULL;
2957 }
2958 goto done;
2959 }
2960 p->mark = mark;
2961 }
2962 res = NULL;
2963 done:
2964 return res;
2965}
2966
2967// with_stmt:
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002968// | 'with' '(' ','.with_item+ ')' ':' block
2969// | 'with' ','.with_item+ ':' TYPE_COMMENT? block
2970// | ASYNC 'with' '(' ','.with_item+ ')' ':' block
2971// | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002972static stmt_ty
2973with_stmt_rule(Parser *p)
2974{
2975 if (p->error_indicator) {
2976 return NULL;
2977 }
2978 stmt_ty res = NULL;
2979 int mark = p->mark;
2980 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2981 p->error_indicator = 1;
2982 return NULL;
2983 }
2984 int start_lineno = p->tokens[mark]->lineno;
2985 UNUSED(start_lineno); // Only used by EXTRA macro
2986 int start_col_offset = p->tokens[mark]->col_offset;
2987 UNUSED(start_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002988 { // 'with' '(' ','.with_item+ ')' ':' block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002989 asdl_seq * a;
2990 asdl_seq* b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002991 void *keyword;
2992 void *literal;
2993 void *literal_1;
2994 void *literal_2;
2995 if (
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002996 (keyword = _PyPegen_expect_token(p, 519))
2997 &&
2998 (literal = _PyPegen_expect_token(p, 7))
2999 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003000 (a = _gather_38_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003001 &&
3002 (literal_1 = _PyPegen_expect_token(p, 8))
3003 &&
3004 (literal_2 = _PyPegen_expect_token(p, 11))
3005 &&
3006 (b = block_rule(p))
3007 )
3008 {
3009 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3010 if (token == NULL) {
3011 return NULL;
3012 }
3013 int end_lineno = token->end_lineno;
3014 UNUSED(end_lineno); // Only used by EXTRA macro
3015 int end_col_offset = token->end_col_offset;
3016 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003017 res = _Py_With ( a , b , NULL , EXTRA );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003018 if (res == NULL && PyErr_Occurred()) {
3019 p->error_indicator = 1;
3020 return NULL;
3021 }
3022 goto done;
3023 }
3024 p->mark = mark;
3025 }
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003026 { // 'with' ','.with_item+ ':' TYPE_COMMENT? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003027 asdl_seq * a;
3028 asdl_seq* b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003029 void *keyword;
3030 void *literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07003031 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003032 if (
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003033 (keyword = _PyPegen_expect_token(p, 519))
3034 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003035 (a = _gather_40_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003036 &&
3037 (literal = _PyPegen_expect_token(p, 11))
3038 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003039 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
3040 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003041 (b = block_rule(p))
3042 )
3043 {
3044 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3045 if (token == NULL) {
3046 return NULL;
3047 }
3048 int end_lineno = token->end_lineno;
3049 UNUSED(end_lineno); // Only used by EXTRA macro
3050 int end_col_offset = token->end_col_offset;
3051 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003052 res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
3053 if (res == NULL && PyErr_Occurred()) {
3054 p->error_indicator = 1;
3055 return NULL;
3056 }
3057 goto done;
3058 }
3059 p->mark = mark;
3060 }
3061 { // ASYNC 'with' '(' ','.with_item+ ')' ':' block
3062 asdl_seq * a;
3063 void *async_var;
3064 asdl_seq* b;
3065 void *keyword;
3066 void *literal;
3067 void *literal_1;
3068 void *literal_2;
3069 if (
3070 (async_var = _PyPegen_expect_token(p, ASYNC))
3071 &&
3072 (keyword = _PyPegen_expect_token(p, 519))
3073 &&
3074 (literal = _PyPegen_expect_token(p, 7))
3075 &&
3076 (a = _gather_42_rule(p))
3077 &&
3078 (literal_1 = _PyPegen_expect_token(p, 8))
3079 &&
3080 (literal_2 = _PyPegen_expect_token(p, 11))
3081 &&
3082 (b = block_rule(p))
3083 )
3084 {
3085 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3086 if (token == NULL) {
3087 return NULL;
3088 }
3089 int end_lineno = token->end_lineno;
3090 UNUSED(end_lineno); // Only used by EXTRA macro
3091 int end_col_offset = token->end_col_offset;
3092 UNUSED(end_col_offset); // Only used by EXTRA macro
3093 res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) );
3094 if (res == NULL && PyErr_Occurred()) {
3095 p->error_indicator = 1;
3096 return NULL;
3097 }
3098 goto done;
3099 }
3100 p->mark = mark;
3101 }
3102 { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
3103 asdl_seq * a;
3104 void *async_var;
3105 asdl_seq* b;
3106 void *keyword;
3107 void *literal;
3108 void *tc;
3109 if (
3110 (async_var = _PyPegen_expect_token(p, ASYNC))
3111 &&
3112 (keyword = _PyPegen_expect_token(p, 519))
3113 &&
3114 (a = _gather_44_rule(p))
3115 &&
3116 (literal = _PyPegen_expect_token(p, 11))
3117 &&
3118 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
3119 &&
3120 (b = block_rule(p))
3121 )
3122 {
3123 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3124 if (token == NULL) {
3125 return NULL;
3126 }
3127 int end_lineno = token->end_lineno;
3128 UNUSED(end_lineno); // Only used by EXTRA macro
3129 int end_col_offset = token->end_col_offset;
3130 UNUSED(end_col_offset); // Only used by EXTRA macro
3131 res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003132 if (res == NULL && PyErr_Occurred()) {
3133 p->error_indicator = 1;
3134 return NULL;
3135 }
3136 goto done;
3137 }
3138 p->mark = mark;
3139 }
3140 res = NULL;
3141 done:
3142 return res;
3143}
3144
3145// with_item: expression ['as' target]
3146static withitem_ty
3147with_item_rule(Parser *p)
3148{
3149 if (p->error_indicator) {
3150 return NULL;
3151 }
3152 withitem_ty res = NULL;
3153 int mark = p->mark;
3154 { // expression ['as' target]
3155 expr_ty e;
3156 void *o;
3157 if (
3158 (e = expression_rule(p))
3159 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003160 (o = _tmp_46_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003161 )
3162 {
3163 res = _Py_withitem ( e , o , p -> arena );
3164 if (res == NULL && PyErr_Occurred()) {
3165 p->error_indicator = 1;
3166 return NULL;
3167 }
3168 goto done;
3169 }
3170 p->mark = mark;
3171 }
3172 res = NULL;
3173 done:
3174 return res;
3175}
3176
3177// try_stmt:
3178// | 'try' ':' block finally_block
3179// | 'try' ':' block except_block+ else_block? finally_block?
3180static stmt_ty
3181try_stmt_rule(Parser *p)
3182{
3183 if (p->error_indicator) {
3184 return NULL;
3185 }
3186 stmt_ty res = NULL;
3187 int mark = p->mark;
3188 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3189 p->error_indicator = 1;
3190 return NULL;
3191 }
3192 int start_lineno = p->tokens[mark]->lineno;
3193 UNUSED(start_lineno); // Only used by EXTRA macro
3194 int start_col_offset = p->tokens[mark]->col_offset;
3195 UNUSED(start_col_offset); // Only used by EXTRA macro
3196 { // 'try' ':' block finally_block
3197 asdl_seq* b;
3198 asdl_seq* f;
3199 void *keyword;
3200 void *literal;
3201 if (
3202 (keyword = _PyPegen_expect_token(p, 511))
3203 &&
3204 (literal = _PyPegen_expect_token(p, 11))
3205 &&
3206 (b = block_rule(p))
3207 &&
3208 (f = finally_block_rule(p))
3209 )
3210 {
3211 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3212 if (token == NULL) {
3213 return NULL;
3214 }
3215 int end_lineno = token->end_lineno;
3216 UNUSED(end_lineno); // Only used by EXTRA macro
3217 int end_col_offset = token->end_col_offset;
3218 UNUSED(end_col_offset); // Only used by EXTRA macro
3219 res = _Py_Try ( b , NULL , NULL , f , EXTRA );
3220 if (res == NULL && PyErr_Occurred()) {
3221 p->error_indicator = 1;
3222 return NULL;
3223 }
3224 goto done;
3225 }
3226 p->mark = mark;
3227 }
3228 { // 'try' ':' block except_block+ else_block? finally_block?
3229 asdl_seq* b;
3230 void *el;
3231 asdl_seq * ex;
3232 void *f;
3233 void *keyword;
3234 void *literal;
3235 if (
3236 (keyword = _PyPegen_expect_token(p, 511))
3237 &&
3238 (literal = _PyPegen_expect_token(p, 11))
3239 &&
3240 (b = block_rule(p))
3241 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003242 (ex = _loop1_47_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003243 &&
3244 (el = else_block_rule(p), 1)
3245 &&
3246 (f = finally_block_rule(p), 1)
3247 )
3248 {
3249 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3250 if (token == NULL) {
3251 return NULL;
3252 }
3253 int end_lineno = token->end_lineno;
3254 UNUSED(end_lineno); // Only used by EXTRA macro
3255 int end_col_offset = token->end_col_offset;
3256 UNUSED(end_col_offset); // Only used by EXTRA macro
3257 res = _Py_Try ( b , ex , el , f , EXTRA );
3258 if (res == NULL && PyErr_Occurred()) {
3259 p->error_indicator = 1;
3260 return NULL;
3261 }
3262 goto done;
3263 }
3264 p->mark = mark;
3265 }
3266 res = NULL;
3267 done:
3268 return res;
3269}
3270
3271// except_block: 'except' expression ['as' target] ':' block | 'except' ':' block
3272static excepthandler_ty
3273except_block_rule(Parser *p)
3274{
3275 if (p->error_indicator) {
3276 return NULL;
3277 }
3278 excepthandler_ty res = NULL;
3279 int mark = p->mark;
3280 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3281 p->error_indicator = 1;
3282 return NULL;
3283 }
3284 int start_lineno = p->tokens[mark]->lineno;
3285 UNUSED(start_lineno); // Only used by EXTRA macro
3286 int start_col_offset = p->tokens[mark]->col_offset;
3287 UNUSED(start_col_offset); // Only used by EXTRA macro
3288 { // 'except' expression ['as' target] ':' block
3289 asdl_seq* b;
3290 expr_ty e;
3291 void *keyword;
3292 void *literal;
3293 void *t;
3294 if (
3295 (keyword = _PyPegen_expect_token(p, 520))
3296 &&
3297 (e = expression_rule(p))
3298 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003299 (t = _tmp_48_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003300 &&
3301 (literal = _PyPegen_expect_token(p, 11))
3302 &&
3303 (b = block_rule(p))
3304 )
3305 {
3306 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3307 if (token == NULL) {
3308 return NULL;
3309 }
3310 int end_lineno = token->end_lineno;
3311 UNUSED(end_lineno); // Only used by EXTRA macro
3312 int end_col_offset = token->end_col_offset;
3313 UNUSED(end_col_offset); // Only used by EXTRA macro
3314 res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA );
3315 if (res == NULL && PyErr_Occurred()) {
3316 p->error_indicator = 1;
3317 return NULL;
3318 }
3319 goto done;
3320 }
3321 p->mark = mark;
3322 }
3323 { // 'except' ':' block
3324 asdl_seq* b;
3325 void *keyword;
3326 void *literal;
3327 if (
3328 (keyword = _PyPegen_expect_token(p, 520))
3329 &&
3330 (literal = _PyPegen_expect_token(p, 11))
3331 &&
3332 (b = block_rule(p))
3333 )
3334 {
3335 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3336 if (token == NULL) {
3337 return NULL;
3338 }
3339 int end_lineno = token->end_lineno;
3340 UNUSED(end_lineno); // Only used by EXTRA macro
3341 int end_col_offset = token->end_col_offset;
3342 UNUSED(end_col_offset); // Only used by EXTRA macro
3343 res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA );
3344 if (res == NULL && PyErr_Occurred()) {
3345 p->error_indicator = 1;
3346 return NULL;
3347 }
3348 goto done;
3349 }
3350 p->mark = mark;
3351 }
3352 res = NULL;
3353 done:
3354 return res;
3355}
3356
3357// finally_block: 'finally' ':' block
3358static asdl_seq*
3359finally_block_rule(Parser *p)
3360{
3361 if (p->error_indicator) {
3362 return NULL;
3363 }
3364 asdl_seq* res = NULL;
3365 int mark = p->mark;
3366 { // 'finally' ':' block
3367 asdl_seq* a;
3368 void *keyword;
3369 void *literal;
3370 if (
3371 (keyword = _PyPegen_expect_token(p, 521))
3372 &&
3373 (literal = _PyPegen_expect_token(p, 11))
3374 &&
3375 (a = block_rule(p))
3376 )
3377 {
3378 res = a;
3379 if (res == NULL && PyErr_Occurred()) {
3380 p->error_indicator = 1;
3381 return NULL;
3382 }
3383 goto done;
3384 }
3385 p->mark = mark;
3386 }
3387 res = NULL;
3388 done:
3389 return res;
3390}
3391
3392// return_stmt: 'return' star_expressions?
3393static stmt_ty
3394return_stmt_rule(Parser *p)
3395{
3396 if (p->error_indicator) {
3397 return NULL;
3398 }
3399 stmt_ty res = NULL;
3400 int mark = p->mark;
3401 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3402 p->error_indicator = 1;
3403 return NULL;
3404 }
3405 int start_lineno = p->tokens[mark]->lineno;
3406 UNUSED(start_lineno); // Only used by EXTRA macro
3407 int start_col_offset = p->tokens[mark]->col_offset;
3408 UNUSED(start_col_offset); // Only used by EXTRA macro
3409 { // 'return' star_expressions?
3410 void *a;
3411 void *keyword;
3412 if (
3413 (keyword = _PyPegen_expect_token(p, 500))
3414 &&
3415 (a = star_expressions_rule(p), 1)
3416 )
3417 {
3418 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3419 if (token == NULL) {
3420 return NULL;
3421 }
3422 int end_lineno = token->end_lineno;
3423 UNUSED(end_lineno); // Only used by EXTRA macro
3424 int end_col_offset = token->end_col_offset;
3425 UNUSED(end_col_offset); // Only used by EXTRA macro
3426 res = _Py_Return ( a , EXTRA );
3427 if (res == NULL && PyErr_Occurred()) {
3428 p->error_indicator = 1;
3429 return NULL;
3430 }
3431 goto done;
3432 }
3433 p->mark = mark;
3434 }
3435 res = NULL;
3436 done:
3437 return res;
3438}
3439
3440// raise_stmt: 'raise' expression ['from' expression] | 'raise'
3441static stmt_ty
3442raise_stmt_rule(Parser *p)
3443{
3444 if (p->error_indicator) {
3445 return NULL;
3446 }
3447 stmt_ty res = NULL;
3448 int mark = p->mark;
3449 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3450 p->error_indicator = 1;
3451 return NULL;
3452 }
3453 int start_lineno = p->tokens[mark]->lineno;
3454 UNUSED(start_lineno); // Only used by EXTRA macro
3455 int start_col_offset = p->tokens[mark]->col_offset;
3456 UNUSED(start_col_offset); // Only used by EXTRA macro
3457 { // 'raise' expression ['from' expression]
3458 expr_ty a;
3459 void *b;
3460 void *keyword;
3461 if (
3462 (keyword = _PyPegen_expect_token(p, 501))
3463 &&
3464 (a = expression_rule(p))
3465 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003466 (b = _tmp_49_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003467 )
3468 {
3469 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3470 if (token == NULL) {
3471 return NULL;
3472 }
3473 int end_lineno = token->end_lineno;
3474 UNUSED(end_lineno); // Only used by EXTRA macro
3475 int end_col_offset = token->end_col_offset;
3476 UNUSED(end_col_offset); // Only used by EXTRA macro
3477 res = _Py_Raise ( a , b , EXTRA );
3478 if (res == NULL && PyErr_Occurred()) {
3479 p->error_indicator = 1;
3480 return NULL;
3481 }
3482 goto done;
3483 }
3484 p->mark = mark;
3485 }
3486 { // 'raise'
3487 void *keyword;
3488 if (
3489 (keyword = _PyPegen_expect_token(p, 501))
3490 )
3491 {
3492 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3493 if (token == NULL) {
3494 return NULL;
3495 }
3496 int end_lineno = token->end_lineno;
3497 UNUSED(end_lineno); // Only used by EXTRA macro
3498 int end_col_offset = token->end_col_offset;
3499 UNUSED(end_col_offset); // Only used by EXTRA macro
3500 res = _Py_Raise ( NULL , NULL , EXTRA );
3501 if (res == NULL && PyErr_Occurred()) {
3502 p->error_indicator = 1;
3503 return NULL;
3504 }
3505 goto done;
3506 }
3507 p->mark = mark;
3508 }
3509 res = NULL;
3510 done:
3511 return res;
3512}
3513
3514// function_def: decorators function_def_raw | function_def_raw
3515static stmt_ty
3516function_def_rule(Parser *p)
3517{
3518 if (p->error_indicator) {
3519 return NULL;
3520 }
3521 stmt_ty res = NULL;
3522 int mark = p->mark;
3523 { // decorators function_def_raw
3524 asdl_seq* d;
3525 stmt_ty f;
3526 if (
3527 (d = decorators_rule(p))
3528 &&
3529 (f = function_def_raw_rule(p))
3530 )
3531 {
3532 res = _PyPegen_function_def_decorators ( p , d , f );
3533 if (res == NULL && PyErr_Occurred()) {
3534 p->error_indicator = 1;
3535 return NULL;
3536 }
3537 goto done;
3538 }
3539 p->mark = mark;
3540 }
3541 { // function_def_raw
3542 stmt_ty function_def_raw_var;
3543 if (
3544 (function_def_raw_var = function_def_raw_rule(p))
3545 )
3546 {
3547 res = function_def_raw_var;
3548 goto done;
3549 }
3550 p->mark = mark;
3551 }
3552 res = NULL;
3553 done:
3554 return res;
3555}
3556
Guido van Rossumc001c092020-04-30 12:12:19 -07003557// function_def_raw:
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003558// | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
3559// | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003560static stmt_ty
3561function_def_raw_rule(Parser *p)
3562{
3563 if (p->error_indicator) {
3564 return NULL;
3565 }
3566 stmt_ty res = NULL;
3567 int mark = p->mark;
3568 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3569 p->error_indicator = 1;
3570 return NULL;
3571 }
3572 int start_lineno = p->tokens[mark]->lineno;
3573 UNUSED(start_lineno); // Only used by EXTRA macro
3574 int start_col_offset = p->tokens[mark]->col_offset;
3575 UNUSED(start_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003576 { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003577 void *a;
3578 asdl_seq* b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003579 void *keyword;
3580 void *literal;
3581 void *literal_1;
3582 void *literal_2;
3583 expr_ty n;
3584 void *params;
Guido van Rossumc001c092020-04-30 12:12:19 -07003585 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003586 if (
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003587 (keyword = _PyPegen_expect_token(p, 522))
3588 &&
3589 (n = _PyPegen_name_token(p))
3590 &&
3591 (literal = _PyPegen_expect_token(p, 7))
3592 &&
3593 (params = params_rule(p), 1)
3594 &&
3595 (literal_1 = _PyPegen_expect_token(p, 8))
3596 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003597 (a = _tmp_50_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003598 &&
3599 (literal_2 = _PyPegen_expect_token(p, 11))
3600 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003601 (tc = func_type_comment_rule(p), 1)
3602 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003603 (b = block_rule(p))
3604 )
3605 {
3606 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3607 if (token == NULL) {
3608 return NULL;
3609 }
3610 int end_lineno = token->end_lineno;
3611 UNUSED(end_lineno); // Only used by EXTRA macro
3612 int end_col_offset = token->end_col_offset;
3613 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003614 res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
3615 if (res == NULL && PyErr_Occurred()) {
3616 p->error_indicator = 1;
3617 return NULL;
3618 }
3619 goto done;
3620 }
3621 p->mark = mark;
3622 }
3623 { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
3624 void *a;
3625 void *async_var;
3626 asdl_seq* b;
3627 void *keyword;
3628 void *literal;
3629 void *literal_1;
3630 void *literal_2;
3631 expr_ty n;
3632 void *params;
3633 void *tc;
3634 if (
3635 (async_var = _PyPegen_expect_token(p, ASYNC))
3636 &&
3637 (keyword = _PyPegen_expect_token(p, 522))
3638 &&
3639 (n = _PyPegen_name_token(p))
3640 &&
3641 (literal = _PyPegen_expect_token(p, 7))
3642 &&
3643 (params = params_rule(p), 1)
3644 &&
3645 (literal_1 = _PyPegen_expect_token(p, 8))
3646 &&
3647 (a = _tmp_51_rule(p), 1)
3648 &&
3649 (literal_2 = _PyPegen_expect_token(p, 11))
3650 &&
3651 (tc = func_type_comment_rule(p), 1)
3652 &&
3653 (b = block_rule(p))
3654 )
3655 {
3656 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3657 if (token == NULL) {
3658 return NULL;
3659 }
3660 int end_lineno = token->end_lineno;
3661 UNUSED(end_lineno); // Only used by EXTRA macro
3662 int end_col_offset = token->end_col_offset;
3663 UNUSED(end_col_offset); // Only used by EXTRA macro
3664 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 Galindoc5fc1562020-04-22 23:29:27 +01003665 if (res == NULL && PyErr_Occurred()) {
3666 p->error_indicator = 1;
3667 return NULL;
3668 }
3669 goto done;
3670 }
3671 p->mark = mark;
3672 }
3673 res = NULL;
3674 done:
3675 return res;
3676}
3677
Guido van Rossumc001c092020-04-30 12:12:19 -07003678// func_type_comment:
3679// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
3680// | invalid_double_type_comments
3681// | TYPE_COMMENT
3682static PyObject*
3683func_type_comment_rule(Parser *p)
3684{
3685 if (p->error_indicator) {
3686 return NULL;
3687 }
3688 PyObject* res = NULL;
3689 int mark = p->mark;
3690 { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
3691 void *newline_var;
3692 void *t;
3693 if (
3694 (newline_var = _PyPegen_expect_token(p, NEWLINE))
3695 &&
3696 (t = _PyPegen_expect_token(p, TYPE_COMMENT))
3697 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003698 _PyPegen_lookahead(1, _tmp_52_rule, p)
Guido van Rossumc001c092020-04-30 12:12:19 -07003699 )
3700 {
3701 res = t;
3702 if (res == NULL && PyErr_Occurred()) {
3703 p->error_indicator = 1;
3704 return NULL;
3705 }
3706 goto done;
3707 }
3708 p->mark = mark;
3709 }
3710 { // invalid_double_type_comments
3711 void *invalid_double_type_comments_var;
3712 if (
3713 (invalid_double_type_comments_var = invalid_double_type_comments_rule(p))
3714 )
3715 {
3716 res = invalid_double_type_comments_var;
3717 goto done;
3718 }
3719 p->mark = mark;
3720 }
3721 { // TYPE_COMMENT
3722 void *type_comment_var;
3723 if (
3724 (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT))
3725 )
3726 {
3727 res = type_comment_var;
3728 goto done;
3729 }
3730 p->mark = mark;
3731 }
3732 res = NULL;
3733 done:
3734 return res;
3735}
3736
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003737// params: invalid_parameters | parameters
3738static arguments_ty
3739params_rule(Parser *p)
3740{
3741 if (p->error_indicator) {
3742 return NULL;
3743 }
3744 arguments_ty res = NULL;
3745 int mark = p->mark;
3746 { // invalid_parameters
3747 void *invalid_parameters_var;
3748 if (
3749 (invalid_parameters_var = invalid_parameters_rule(p))
3750 )
3751 {
3752 res = invalid_parameters_var;
3753 goto done;
3754 }
3755 p->mark = mark;
3756 }
3757 { // parameters
3758 arguments_ty parameters_var;
3759 if (
3760 (parameters_var = parameters_rule(p))
3761 )
3762 {
3763 res = parameters_var;
3764 goto done;
3765 }
3766 p->mark = mark;
3767 }
3768 res = NULL;
3769 done:
3770 return res;
3771}
3772
3773// parameters:
Guido van Rossumc001c092020-04-30 12:12:19 -07003774// | slash_no_default param_no_default* param_with_default* star_etc?
3775// | slash_with_default param_with_default* star_etc?
3776// | param_no_default+ param_with_default* star_etc?
3777// | param_with_default+ star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003778// | star_etc
3779static arguments_ty
3780parameters_rule(Parser *p)
3781{
3782 if (p->error_indicator) {
3783 return NULL;
3784 }
3785 arguments_ty res = NULL;
3786 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07003787 { // slash_no_default param_no_default* param_with_default* star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003788 asdl_seq* a;
Guido van Rossumc001c092020-04-30 12:12:19 -07003789 asdl_seq * b;
3790 asdl_seq * c;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003791 void *d;
3792 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07003793 (a = slash_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003794 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003795 (b = _loop0_53_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003796 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003797 (c = _loop0_54_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003798 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003799 (d = star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003800 )
3801 {
3802 res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
3803 if (res == NULL && PyErr_Occurred()) {
3804 p->error_indicator = 1;
3805 return NULL;
3806 }
3807 goto done;
3808 }
3809 p->mark = mark;
3810 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003811 { // slash_with_default param_with_default* star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003812 SlashWithDefault* a;
Guido van Rossumc001c092020-04-30 12:12:19 -07003813 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003814 void *c;
3815 if (
3816 (a = slash_with_default_rule(p))
3817 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003818 (b = _loop0_55_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003819 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003820 (c = star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003821 )
3822 {
3823 res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
3824 if (res == NULL && PyErr_Occurred()) {
3825 p->error_indicator = 1;
3826 return NULL;
3827 }
3828 goto done;
3829 }
3830 p->mark = mark;
3831 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003832 { // param_no_default+ param_with_default* star_etc?
3833 asdl_seq * a;
3834 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003835 void *c;
3836 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003837 (a = _loop1_56_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003838 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003839 (b = _loop0_57_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003840 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003841 (c = star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003842 )
3843 {
3844 res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
3845 if (res == NULL && PyErr_Occurred()) {
3846 p->error_indicator = 1;
3847 return NULL;
3848 }
3849 goto done;
3850 }
3851 p->mark = mark;
3852 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003853 { // param_with_default+ star_etc?
3854 asdl_seq * a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003855 void *b;
3856 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003857 (a = _loop1_58_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003858 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003859 (b = star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003860 )
3861 {
3862 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
3863 if (res == NULL && PyErr_Occurred()) {
3864 p->error_indicator = 1;
3865 return NULL;
3866 }
3867 goto done;
3868 }
3869 p->mark = mark;
3870 }
3871 { // star_etc
3872 StarEtc* a;
3873 if (
3874 (a = star_etc_rule(p))
3875 )
3876 {
3877 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
3878 if (res == NULL && PyErr_Occurred()) {
3879 p->error_indicator = 1;
3880 return NULL;
3881 }
3882 goto done;
3883 }
3884 p->mark = mark;
3885 }
3886 res = NULL;
3887 done:
3888 return res;
3889}
3890
Guido van Rossumc001c092020-04-30 12:12:19 -07003891// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003892static asdl_seq*
Guido van Rossumc001c092020-04-30 12:12:19 -07003893slash_no_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003894{
3895 if (p->error_indicator) {
3896 return NULL;
3897 }
3898 asdl_seq* res = NULL;
3899 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07003900 { // param_no_default+ '/' ','
3901 asdl_seq * a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003902 void *literal;
3903 void *literal_1;
3904 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003905 (a = _loop1_59_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003906 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003907 (literal = _PyPegen_expect_token(p, 17))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003908 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003909 (literal_1 = _PyPegen_expect_token(p, 12))
3910 )
3911 {
3912 res = a;
3913 if (res == NULL && PyErr_Occurred()) {
3914 p->error_indicator = 1;
3915 return NULL;
3916 }
3917 goto done;
3918 }
3919 p->mark = mark;
3920 }
3921 { // param_no_default+ '/' &')'
3922 asdl_seq * a;
3923 void *literal;
3924 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003925 (a = _loop1_60_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -07003926 &&
3927 (literal = _PyPegen_expect_token(p, 17))
3928 &&
3929 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003930 )
3931 {
3932 res = a;
3933 if (res == NULL && PyErr_Occurred()) {
3934 p->error_indicator = 1;
3935 return NULL;
3936 }
3937 goto done;
3938 }
3939 p->mark = mark;
3940 }
3941 res = NULL;
3942 done:
3943 return res;
3944}
3945
Guido van Rossumc001c092020-04-30 12:12:19 -07003946// slash_with_default:
3947// | param_no_default* param_with_default+ '/' ','
3948// | param_no_default* param_with_default+ '/' &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003949static SlashWithDefault*
3950slash_with_default_rule(Parser *p)
3951{
3952 if (p->error_indicator) {
3953 return NULL;
3954 }
3955 SlashWithDefault* res = NULL;
3956 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07003957 { // param_no_default* param_with_default+ '/' ','
3958 asdl_seq * a;
3959 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003960 void *literal;
3961 void *literal_1;
3962 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003963 (a = _loop0_61_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003964 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003965 (b = _loop1_62_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003966 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003967 (literal = _PyPegen_expect_token(p, 17))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003968 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003969 (literal_1 = _PyPegen_expect_token(p, 12))
3970 )
3971 {
3972 res = _PyPegen_slash_with_default ( p , a , b );
3973 if (res == NULL && PyErr_Occurred()) {
3974 p->error_indicator = 1;
3975 return NULL;
3976 }
3977 goto done;
3978 }
3979 p->mark = mark;
3980 }
3981 { // param_no_default* param_with_default+ '/' &')'
3982 asdl_seq * a;
3983 asdl_seq * b;
3984 void *literal;
3985 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003986 (a = _loop0_63_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -07003987 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003988 (b = _loop1_64_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -07003989 &&
3990 (literal = _PyPegen_expect_token(p, 17))
3991 &&
3992 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003993 )
3994 {
3995 res = _PyPegen_slash_with_default ( p , a , b );
3996 if (res == NULL && PyErr_Occurred()) {
3997 p->error_indicator = 1;
3998 return NULL;
3999 }
4000 goto done;
4001 }
4002 p->mark = mark;
4003 }
4004 res = NULL;
4005 done:
4006 return res;
4007}
4008
4009// star_etc:
Guido van Rossumc001c092020-04-30 12:12:19 -07004010// | '*' param_no_default param_maybe_default* kwds?
4011// | '*' ',' param_maybe_default+ kwds?
4012// | kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004013static StarEtc*
4014star_etc_rule(Parser *p)
4015{
4016 if (p->error_indicator) {
4017 return NULL;
4018 }
4019 StarEtc* res = NULL;
4020 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004021 { // '*' param_no_default param_maybe_default* kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004022 arg_ty a;
4023 asdl_seq * b;
4024 void *c;
4025 void *literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004026 if (
4027 (literal = _PyPegen_expect_token(p, 16))
4028 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004029 (a = param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004030 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004031 (b = _loop0_65_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004032 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004033 (c = kwds_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004034 )
4035 {
4036 res = _PyPegen_star_etc ( p , a , b , c );
4037 if (res == NULL && PyErr_Occurred()) {
4038 p->error_indicator = 1;
4039 return NULL;
4040 }
4041 goto done;
4042 }
4043 p->mark = mark;
4044 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004045 { // '*' ',' param_maybe_default+ kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004046 asdl_seq * b;
4047 void *c;
4048 void *literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004049 void *literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004050 if (
4051 (literal = _PyPegen_expect_token(p, 16))
4052 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004053 (literal_1 = _PyPegen_expect_token(p, 12))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004054 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004055 (b = _loop1_66_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004056 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004057 (c = kwds_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004058 )
4059 {
4060 res = _PyPegen_star_etc ( p , NULL , b , c );
4061 if (res == NULL && PyErr_Occurred()) {
4062 p->error_indicator = 1;
4063 return NULL;
4064 }
4065 goto done;
4066 }
4067 p->mark = mark;
4068 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004069 { // kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004070 arg_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004071 if (
4072 (a = kwds_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004073 )
4074 {
4075 res = _PyPegen_star_etc ( p , NULL , NULL , a );
4076 if (res == NULL && PyErr_Occurred()) {
4077 p->error_indicator = 1;
4078 return NULL;
4079 }
4080 goto done;
4081 }
4082 p->mark = mark;
4083 }
4084 res = NULL;
4085 done:
4086 return res;
4087}
4088
Guido van Rossumc001c092020-04-30 12:12:19 -07004089// kwds: '**' param_no_default
4090static arg_ty
4091kwds_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004092{
4093 if (p->error_indicator) {
4094 return NULL;
4095 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004096 arg_ty res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004097 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004098 { // '**' param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004099 arg_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004100 void *literal;
4101 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004102 (literal = _PyPegen_expect_token(p, 35))
4103 &&
4104 (a = param_no_default_rule(p))
4105 )
4106 {
4107 res = a;
4108 if (res == NULL && PyErr_Occurred()) {
4109 p->error_indicator = 1;
4110 return NULL;
4111 }
4112 goto done;
4113 }
4114 p->mark = mark;
4115 }
4116 res = NULL;
4117 done:
4118 return res;
4119}
4120
4121// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')'
4122static arg_ty
4123param_no_default_rule(Parser *p)
4124{
4125 if (p->error_indicator) {
4126 return NULL;
4127 }
4128 arg_ty res = NULL;
4129 int mark = p->mark;
4130 { // param ',' TYPE_COMMENT?
4131 arg_ty a;
4132 void *literal;
4133 void *tc;
4134 if (
4135 (a = param_rule(p))
4136 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004137 (literal = _PyPegen_expect_token(p, 12))
4138 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004139 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004140 )
4141 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004142 res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004143 if (res == NULL && PyErr_Occurred()) {
4144 p->error_indicator = 1;
4145 return NULL;
4146 }
4147 goto done;
4148 }
4149 p->mark = mark;
4150 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004151 { // param TYPE_COMMENT? &')'
4152 arg_ty a;
4153 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004154 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004155 (a = param_rule(p))
4156 &&
4157 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
4158 &&
4159 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004160 )
4161 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004162 res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004163 if (res == NULL && PyErr_Occurred()) {
4164 p->error_indicator = 1;
4165 return NULL;
4166 }
4167 goto done;
4168 }
4169 p->mark = mark;
4170 }
4171 res = NULL;
4172 done:
4173 return res;
4174}
4175
Guido van Rossumc001c092020-04-30 12:12:19 -07004176// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004177static NameDefaultPair*
Guido van Rossumc001c092020-04-30 12:12:19 -07004178param_with_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004179{
4180 if (p->error_indicator) {
4181 return NULL;
4182 }
4183 NameDefaultPair* res = NULL;
4184 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004185 { // param default ',' TYPE_COMMENT?
4186 arg_ty a;
4187 expr_ty c;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004188 void *literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004189 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004190 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004191 (a = param_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004192 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004193 (c = default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004194 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004195 (literal = _PyPegen_expect_token(p, 12))
4196 &&
4197 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004198 )
4199 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004200 res = _PyPegen_name_default_pair ( p , a , c , tc );
4201 if (res == NULL && PyErr_Occurred()) {
4202 p->error_indicator = 1;
4203 return NULL;
4204 }
4205 goto done;
4206 }
4207 p->mark = mark;
4208 }
4209 { // param default TYPE_COMMENT? &')'
4210 arg_ty a;
4211 expr_ty c;
4212 void *tc;
4213 if (
4214 (a = param_rule(p))
4215 &&
4216 (c = default_rule(p))
4217 &&
4218 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
4219 &&
4220 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
4221 )
4222 {
4223 res = _PyPegen_name_default_pair ( p , a , c , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004224 if (res == NULL && PyErr_Occurred()) {
4225 p->error_indicator = 1;
4226 return NULL;
4227 }
4228 goto done;
4229 }
4230 p->mark = mark;
4231 }
4232 res = NULL;
4233 done:
4234 return res;
4235}
4236
Guido van Rossumc001c092020-04-30 12:12:19 -07004237// param_maybe_default:
4238// | param default? ',' TYPE_COMMENT?
4239// | param default? TYPE_COMMENT? &')'
4240static NameDefaultPair*
4241param_maybe_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004242{
4243 if (p->error_indicator) {
4244 return NULL;
4245 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004246 NameDefaultPair* res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004247 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004248 { // param default? ',' TYPE_COMMENT?
4249 arg_ty a;
4250 void *c;
4251 void *literal;
4252 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004253 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004254 (a = param_rule(p))
4255 &&
4256 (c = default_rule(p), 1)
4257 &&
4258 (literal = _PyPegen_expect_token(p, 12))
4259 &&
4260 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004261 )
4262 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004263 res = _PyPegen_name_default_pair ( p , a , c , tc );
4264 if (res == NULL && PyErr_Occurred()) {
4265 p->error_indicator = 1;
4266 return NULL;
4267 }
4268 goto done;
4269 }
4270 p->mark = mark;
4271 }
4272 { // param default? TYPE_COMMENT? &')'
4273 arg_ty a;
4274 void *c;
4275 void *tc;
4276 if (
4277 (a = param_rule(p))
4278 &&
4279 (c = default_rule(p), 1)
4280 &&
4281 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
4282 &&
4283 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
4284 )
4285 {
4286 res = _PyPegen_name_default_pair ( p , a , c , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004287 if (res == NULL && PyErr_Occurred()) {
4288 p->error_indicator = 1;
4289 return NULL;
4290 }
4291 goto done;
4292 }
4293 p->mark = mark;
4294 }
4295 res = NULL;
4296 done:
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004297 return res;
4298}
4299
Guido van Rossumc001c092020-04-30 12:12:19 -07004300// param: NAME annotation?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004301static arg_ty
Guido van Rossumc001c092020-04-30 12:12:19 -07004302param_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004303{
4304 if (p->error_indicator) {
4305 return NULL;
4306 }
4307 arg_ty res = NULL;
4308 int mark = p->mark;
4309 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4310 p->error_indicator = 1;
4311 return NULL;
4312 }
4313 int start_lineno = p->tokens[mark]->lineno;
4314 UNUSED(start_lineno); // Only used by EXTRA macro
4315 int start_col_offset = p->tokens[mark]->col_offset;
4316 UNUSED(start_col_offset); // Only used by EXTRA macro
Guido van Rossumc001c092020-04-30 12:12:19 -07004317 { // NAME annotation?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004318 expr_ty a;
4319 void *b;
4320 if (
4321 (a = _PyPegen_name_token(p))
4322 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004323 (b = annotation_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004324 )
4325 {
4326 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4327 if (token == NULL) {
4328 return NULL;
4329 }
4330 int end_lineno = token->end_lineno;
4331 UNUSED(end_lineno); // Only used by EXTRA macro
4332 int end_col_offset = token->end_col_offset;
4333 UNUSED(end_col_offset); // Only used by EXTRA macro
4334 res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA );
4335 if (res == NULL && PyErr_Occurred()) {
4336 p->error_indicator = 1;
4337 return NULL;
4338 }
4339 goto done;
4340 }
4341 p->mark = mark;
4342 }
4343 res = NULL;
4344 done:
4345 return res;
4346}
4347
Guido van Rossumc001c092020-04-30 12:12:19 -07004348// annotation: ':' expression
4349static expr_ty
4350annotation_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004351{
4352 if (p->error_indicator) {
4353 return NULL;
4354 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004355 expr_ty res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004356 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004357 { // ':' expression
4358 expr_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004359 void *literal;
4360 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004361 (literal = _PyPegen_expect_token(p, 11))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004362 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004363 (a = expression_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004364 )
4365 {
4366 res = a;
4367 if (res == NULL && PyErr_Occurred()) {
4368 p->error_indicator = 1;
4369 return NULL;
4370 }
4371 goto done;
4372 }
4373 p->mark = mark;
4374 }
4375 res = NULL;
4376 done:
4377 return res;
4378}
4379
Guido van Rossumc001c092020-04-30 12:12:19 -07004380// default: '=' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004381static expr_ty
Guido van Rossumc001c092020-04-30 12:12:19 -07004382default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004383{
4384 if (p->error_indicator) {
4385 return NULL;
4386 }
4387 expr_ty res = NULL;
4388 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004389 { // '=' expression
4390 expr_ty a;
4391 void *literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004392 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004393 (literal = _PyPegen_expect_token(p, 22))
4394 &&
4395 (a = expression_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004396 )
4397 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004398 res = a;
4399 if (res == NULL && PyErr_Occurred()) {
4400 p->error_indicator = 1;
4401 return NULL;
4402 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004403 goto done;
4404 }
4405 p->mark = mark;
4406 }
4407 res = NULL;
4408 done:
4409 return res;
4410}
4411
4412// decorators: (('@' named_expression NEWLINE))+
4413static asdl_seq*
4414decorators_rule(Parser *p)
4415{
4416 if (p->error_indicator) {
4417 return NULL;
4418 }
4419 asdl_seq* res = NULL;
4420 int mark = p->mark;
4421 { // (('@' named_expression NEWLINE))+
4422 asdl_seq * a;
4423 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004424 (a = _loop1_67_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004425 )
4426 {
4427 res = a;
4428 if (res == NULL && PyErr_Occurred()) {
4429 p->error_indicator = 1;
4430 return NULL;
4431 }
4432 goto done;
4433 }
4434 p->mark = mark;
4435 }
4436 res = NULL;
4437 done:
4438 return res;
4439}
4440
4441// class_def: decorators class_def_raw | class_def_raw
4442static stmt_ty
4443class_def_rule(Parser *p)
4444{
4445 if (p->error_indicator) {
4446 return NULL;
4447 }
4448 stmt_ty res = NULL;
4449 int mark = p->mark;
4450 { // decorators class_def_raw
4451 asdl_seq* a;
4452 stmt_ty b;
4453 if (
4454 (a = decorators_rule(p))
4455 &&
4456 (b = class_def_raw_rule(p))
4457 )
4458 {
4459 res = _PyPegen_class_def_decorators ( p , a , b );
4460 if (res == NULL && PyErr_Occurred()) {
4461 p->error_indicator = 1;
4462 return NULL;
4463 }
4464 goto done;
4465 }
4466 p->mark = mark;
4467 }
4468 { // class_def_raw
4469 stmt_ty class_def_raw_var;
4470 if (
4471 (class_def_raw_var = class_def_raw_rule(p))
4472 )
4473 {
4474 res = class_def_raw_var;
4475 goto done;
4476 }
4477 p->mark = mark;
4478 }
4479 res = NULL;
4480 done:
4481 return res;
4482}
4483
4484// class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block
4485static stmt_ty
4486class_def_raw_rule(Parser *p)
4487{
4488 if (p->error_indicator) {
4489 return NULL;
4490 }
4491 stmt_ty res = NULL;
4492 int mark = p->mark;
4493 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4494 p->error_indicator = 1;
4495 return NULL;
4496 }
4497 int start_lineno = p->tokens[mark]->lineno;
4498 UNUSED(start_lineno); // Only used by EXTRA macro
4499 int start_col_offset = p->tokens[mark]->col_offset;
4500 UNUSED(start_col_offset); // Only used by EXTRA macro
4501 { // 'class' NAME ['(' arguments? ')'] ':' block
4502 expr_ty a;
4503 void *b;
4504 asdl_seq* c;
4505 void *keyword;
4506 void *literal;
4507 if (
4508 (keyword = _PyPegen_expect_token(p, 523))
4509 &&
4510 (a = _PyPegen_name_token(p))
4511 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004512 (b = _tmp_68_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004513 &&
4514 (literal = _PyPegen_expect_token(p, 11))
4515 &&
4516 (c = block_rule(p))
4517 )
4518 {
4519 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4520 if (token == NULL) {
4521 return NULL;
4522 }
4523 int end_lineno = token->end_lineno;
4524 UNUSED(end_lineno); // Only used by EXTRA macro
4525 int end_col_offset = token->end_col_offset;
4526 UNUSED(end_col_offset); // Only used by EXTRA macro
4527 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 );
4528 if (res == NULL && PyErr_Occurred()) {
4529 p->error_indicator = 1;
4530 return NULL;
4531 }
4532 goto done;
4533 }
4534 p->mark = mark;
4535 }
4536 res = NULL;
4537 done:
4538 return res;
4539}
4540
4541// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
4542static asdl_seq*
4543block_rule(Parser *p)
4544{
4545 if (p->error_indicator) {
4546 return NULL;
4547 }
4548 asdl_seq* res = NULL;
4549 if (_PyPegen_is_memoized(p, block_type, &res))
4550 return res;
4551 int mark = p->mark;
4552 { // NEWLINE INDENT statements DEDENT
4553 asdl_seq* a;
4554 void *dedent_var;
4555 void *indent_var;
4556 void *newline_var;
4557 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +01004558 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004559 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01004560 (indent_var = _PyPegen_expect_token(p, INDENT))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004561 &&
4562 (a = statements_rule(p))
4563 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01004564 (dedent_var = _PyPegen_expect_token(p, DEDENT))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004565 )
4566 {
4567 res = a;
4568 if (res == NULL && PyErr_Occurred()) {
4569 p->error_indicator = 1;
4570 return NULL;
4571 }
4572 goto done;
4573 }
4574 p->mark = mark;
4575 }
4576 { // simple_stmt
4577 asdl_seq* simple_stmt_var;
4578 if (
4579 (simple_stmt_var = simple_stmt_rule(p))
4580 )
4581 {
4582 res = simple_stmt_var;
4583 goto done;
4584 }
4585 p->mark = mark;
4586 }
4587 { // invalid_block
4588 void *invalid_block_var;
4589 if (
4590 (invalid_block_var = invalid_block_rule(p))
4591 )
4592 {
4593 res = invalid_block_var;
4594 goto done;
4595 }
4596 p->mark = mark;
4597 }
4598 res = NULL;
4599 done:
4600 _PyPegen_insert_memo(p, mark, block_type, res);
4601 return res;
4602}
4603
4604// expressions_list: ','.star_expression+ ','?
4605static asdl_seq*
4606expressions_list_rule(Parser *p)
4607{
4608 if (p->error_indicator) {
4609 return NULL;
4610 }
4611 asdl_seq* res = NULL;
4612 int mark = p->mark;
4613 { // ','.star_expression+ ','?
4614 asdl_seq * a;
4615 void *opt_var;
4616 UNUSED(opt_var); // Silence compiler warnings
4617 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004618 (a = _gather_69_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004619 &&
4620 (opt_var = _PyPegen_expect_token(p, 12), 1)
4621 )
4622 {
4623 res = a;
4624 if (res == NULL && PyErr_Occurred()) {
4625 p->error_indicator = 1;
4626 return NULL;
4627 }
4628 goto done;
4629 }
4630 p->mark = mark;
4631 }
4632 res = NULL;
4633 done:
4634 return res;
4635}
4636
4637// star_expressions:
4638// | star_expression ((',' star_expression))+ ','?
4639// | star_expression ','
4640// | star_expression
4641static expr_ty
4642star_expressions_rule(Parser *p)
4643{
4644 if (p->error_indicator) {
4645 return NULL;
4646 }
4647 expr_ty res = NULL;
4648 int mark = p->mark;
4649 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4650 p->error_indicator = 1;
4651 return NULL;
4652 }
4653 int start_lineno = p->tokens[mark]->lineno;
4654 UNUSED(start_lineno); // Only used by EXTRA macro
4655 int start_col_offset = p->tokens[mark]->col_offset;
4656 UNUSED(start_col_offset); // Only used by EXTRA macro
4657 { // star_expression ((',' star_expression))+ ','?
4658 expr_ty a;
4659 asdl_seq * b;
4660 void *opt_var;
4661 UNUSED(opt_var); // Silence compiler warnings
4662 if (
4663 (a = star_expression_rule(p))
4664 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004665 (b = _loop1_71_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004666 &&
4667 (opt_var = _PyPegen_expect_token(p, 12), 1)
4668 )
4669 {
4670 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4671 if (token == NULL) {
4672 return NULL;
4673 }
4674 int end_lineno = token->end_lineno;
4675 UNUSED(end_lineno); // Only used by EXTRA macro
4676 int end_col_offset = token->end_col_offset;
4677 UNUSED(end_col_offset); // Only used by EXTRA macro
4678 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
4679 if (res == NULL && PyErr_Occurred()) {
4680 p->error_indicator = 1;
4681 return NULL;
4682 }
4683 goto done;
4684 }
4685 p->mark = mark;
4686 }
4687 { // star_expression ','
4688 expr_ty a;
4689 void *literal;
4690 if (
4691 (a = star_expression_rule(p))
4692 &&
4693 (literal = _PyPegen_expect_token(p, 12))
4694 )
4695 {
4696 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4697 if (token == NULL) {
4698 return NULL;
4699 }
4700 int end_lineno = token->end_lineno;
4701 UNUSED(end_lineno); // Only used by EXTRA macro
4702 int end_col_offset = token->end_col_offset;
4703 UNUSED(end_col_offset); // Only used by EXTRA macro
4704 res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
4705 if (res == NULL && PyErr_Occurred()) {
4706 p->error_indicator = 1;
4707 return NULL;
4708 }
4709 goto done;
4710 }
4711 p->mark = mark;
4712 }
4713 { // star_expression
4714 expr_ty star_expression_var;
4715 if (
4716 (star_expression_var = star_expression_rule(p))
4717 )
4718 {
4719 res = star_expression_var;
4720 goto done;
4721 }
4722 p->mark = mark;
4723 }
4724 res = NULL;
4725 done:
4726 return res;
4727}
4728
4729// star_expression: '*' bitwise_or | expression
4730static expr_ty
4731star_expression_rule(Parser *p)
4732{
4733 if (p->error_indicator) {
4734 return NULL;
4735 }
4736 expr_ty res = NULL;
4737 if (_PyPegen_is_memoized(p, star_expression_type, &res))
4738 return res;
4739 int mark = p->mark;
4740 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4741 p->error_indicator = 1;
4742 return NULL;
4743 }
4744 int start_lineno = p->tokens[mark]->lineno;
4745 UNUSED(start_lineno); // Only used by EXTRA macro
4746 int start_col_offset = p->tokens[mark]->col_offset;
4747 UNUSED(start_col_offset); // Only used by EXTRA macro
4748 { // '*' bitwise_or
4749 expr_ty a;
4750 void *literal;
4751 if (
4752 (literal = _PyPegen_expect_token(p, 16))
4753 &&
4754 (a = bitwise_or_rule(p))
4755 )
4756 {
4757 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4758 if (token == NULL) {
4759 return NULL;
4760 }
4761 int end_lineno = token->end_lineno;
4762 UNUSED(end_lineno); // Only used by EXTRA macro
4763 int end_col_offset = token->end_col_offset;
4764 UNUSED(end_col_offset); // Only used by EXTRA macro
4765 res = _Py_Starred ( a , Load , EXTRA );
4766 if (res == NULL && PyErr_Occurred()) {
4767 p->error_indicator = 1;
4768 return NULL;
4769 }
4770 goto done;
4771 }
4772 p->mark = mark;
4773 }
4774 { // expression
4775 expr_ty expression_var;
4776 if (
4777 (expression_var = expression_rule(p))
4778 )
4779 {
4780 res = expression_var;
4781 goto done;
4782 }
4783 p->mark = mark;
4784 }
4785 res = NULL;
4786 done:
4787 _PyPegen_insert_memo(p, mark, star_expression_type, res);
4788 return res;
4789}
4790
4791// star_named_expressions: ','.star_named_expression+ ','?
4792static asdl_seq*
4793star_named_expressions_rule(Parser *p)
4794{
4795 if (p->error_indicator) {
4796 return NULL;
4797 }
4798 asdl_seq* res = NULL;
4799 int mark = p->mark;
4800 { // ','.star_named_expression+ ','?
4801 asdl_seq * a;
4802 void *opt_var;
4803 UNUSED(opt_var); // Silence compiler warnings
4804 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004805 (a = _gather_72_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004806 &&
4807 (opt_var = _PyPegen_expect_token(p, 12), 1)
4808 )
4809 {
4810 res = a;
4811 if (res == NULL && PyErr_Occurred()) {
4812 p->error_indicator = 1;
4813 return NULL;
4814 }
4815 goto done;
4816 }
4817 p->mark = mark;
4818 }
4819 res = NULL;
4820 done:
4821 return res;
4822}
4823
4824// star_named_expression: '*' bitwise_or | named_expression
4825static expr_ty
4826star_named_expression_rule(Parser *p)
4827{
4828 if (p->error_indicator) {
4829 return NULL;
4830 }
4831 expr_ty res = NULL;
4832 int mark = p->mark;
4833 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4834 p->error_indicator = 1;
4835 return NULL;
4836 }
4837 int start_lineno = p->tokens[mark]->lineno;
4838 UNUSED(start_lineno); // Only used by EXTRA macro
4839 int start_col_offset = p->tokens[mark]->col_offset;
4840 UNUSED(start_col_offset); // Only used by EXTRA macro
4841 { // '*' bitwise_or
4842 expr_ty a;
4843 void *literal;
4844 if (
4845 (literal = _PyPegen_expect_token(p, 16))
4846 &&
4847 (a = bitwise_or_rule(p))
4848 )
4849 {
4850 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4851 if (token == NULL) {
4852 return NULL;
4853 }
4854 int end_lineno = token->end_lineno;
4855 UNUSED(end_lineno); // Only used by EXTRA macro
4856 int end_col_offset = token->end_col_offset;
4857 UNUSED(end_col_offset); // Only used by EXTRA macro
4858 res = _Py_Starred ( a , Load , EXTRA );
4859 if (res == NULL && PyErr_Occurred()) {
4860 p->error_indicator = 1;
4861 return NULL;
4862 }
4863 goto done;
4864 }
4865 p->mark = mark;
4866 }
4867 { // named_expression
4868 expr_ty named_expression_var;
4869 if (
4870 (named_expression_var = named_expression_rule(p))
4871 )
4872 {
4873 res = named_expression_var;
4874 goto done;
4875 }
4876 p->mark = mark;
4877 }
4878 res = NULL;
4879 done:
4880 return res;
4881}
4882
4883// named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression
4884static expr_ty
4885named_expression_rule(Parser *p)
4886{
4887 if (p->error_indicator) {
4888 return NULL;
4889 }
4890 expr_ty res = NULL;
4891 int mark = p->mark;
4892 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4893 p->error_indicator = 1;
4894 return NULL;
4895 }
4896 int start_lineno = p->tokens[mark]->lineno;
4897 UNUSED(start_lineno); // Only used by EXTRA macro
4898 int start_col_offset = p->tokens[mark]->col_offset;
4899 UNUSED(start_col_offset); // Only used by EXTRA macro
4900 { // NAME ':=' expression
4901 expr_ty a;
4902 expr_ty b;
4903 void *literal;
4904 if (
4905 (a = _PyPegen_name_token(p))
4906 &&
4907 (literal = _PyPegen_expect_token(p, 53))
4908 &&
4909 (b = expression_rule(p))
4910 )
4911 {
4912 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4913 if (token == NULL) {
4914 return NULL;
4915 }
4916 int end_lineno = token->end_lineno;
4917 UNUSED(end_lineno); // Only used by EXTRA macro
4918 int end_col_offset = token->end_col_offset;
4919 UNUSED(end_col_offset); // Only used by EXTRA macro
4920 res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA );
4921 if (res == NULL && PyErr_Occurred()) {
4922 p->error_indicator = 1;
4923 return NULL;
4924 }
4925 goto done;
4926 }
4927 p->mark = mark;
4928 }
4929 { // expression !':='
4930 expr_ty expression_var;
4931 if (
4932 (expression_var = expression_rule(p))
4933 &&
4934 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53)
4935 )
4936 {
4937 res = expression_var;
4938 goto done;
4939 }
4940 p->mark = mark;
4941 }
4942 { // invalid_named_expression
4943 void *invalid_named_expression_var;
4944 if (
4945 (invalid_named_expression_var = invalid_named_expression_rule(p))
4946 )
4947 {
4948 res = invalid_named_expression_var;
4949 goto done;
4950 }
4951 p->mark = mark;
4952 }
4953 res = NULL;
4954 done:
4955 return res;
4956}
4957
4958// annotated_rhs: yield_expr | star_expressions
4959static expr_ty
4960annotated_rhs_rule(Parser *p)
4961{
4962 if (p->error_indicator) {
4963 return NULL;
4964 }
4965 expr_ty res = NULL;
4966 int mark = p->mark;
4967 { // yield_expr
4968 expr_ty yield_expr_var;
4969 if (
4970 (yield_expr_var = yield_expr_rule(p))
4971 )
4972 {
4973 res = yield_expr_var;
4974 goto done;
4975 }
4976 p->mark = mark;
4977 }
4978 { // star_expressions
4979 expr_ty star_expressions_var;
4980 if (
4981 (star_expressions_var = star_expressions_rule(p))
4982 )
4983 {
4984 res = star_expressions_var;
4985 goto done;
4986 }
4987 p->mark = mark;
4988 }
4989 res = NULL;
4990 done:
4991 return res;
4992}
4993
4994// expressions: expression ((',' expression))+ ','? | expression ',' | expression
4995static expr_ty
4996expressions_rule(Parser *p)
4997{
4998 if (p->error_indicator) {
4999 return NULL;
5000 }
5001 expr_ty res = NULL;
5002 int mark = p->mark;
5003 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5004 p->error_indicator = 1;
5005 return NULL;
5006 }
5007 int start_lineno = p->tokens[mark]->lineno;
5008 UNUSED(start_lineno); // Only used by EXTRA macro
5009 int start_col_offset = p->tokens[mark]->col_offset;
5010 UNUSED(start_col_offset); // Only used by EXTRA macro
5011 { // expression ((',' expression))+ ','?
5012 expr_ty a;
5013 asdl_seq * b;
5014 void *opt_var;
5015 UNUSED(opt_var); // Silence compiler warnings
5016 if (
5017 (a = expression_rule(p))
5018 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005019 (b = _loop1_74_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005020 &&
5021 (opt_var = _PyPegen_expect_token(p, 12), 1)
5022 )
5023 {
5024 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5025 if (token == NULL) {
5026 return NULL;
5027 }
5028 int end_lineno = token->end_lineno;
5029 UNUSED(end_lineno); // Only used by EXTRA macro
5030 int end_col_offset = token->end_col_offset;
5031 UNUSED(end_col_offset); // Only used by EXTRA macro
5032 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
5033 if (res == NULL && PyErr_Occurred()) {
5034 p->error_indicator = 1;
5035 return NULL;
5036 }
5037 goto done;
5038 }
5039 p->mark = mark;
5040 }
5041 { // expression ','
5042 expr_ty a;
5043 void *literal;
5044 if (
5045 (a = expression_rule(p))
5046 &&
5047 (literal = _PyPegen_expect_token(p, 12))
5048 )
5049 {
5050 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5051 if (token == NULL) {
5052 return NULL;
5053 }
5054 int end_lineno = token->end_lineno;
5055 UNUSED(end_lineno); // Only used by EXTRA macro
5056 int end_col_offset = token->end_col_offset;
5057 UNUSED(end_col_offset); // Only used by EXTRA macro
5058 res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
5059 if (res == NULL && PyErr_Occurred()) {
5060 p->error_indicator = 1;
5061 return NULL;
5062 }
5063 goto done;
5064 }
5065 p->mark = mark;
5066 }
5067 { // expression
5068 expr_ty expression_var;
5069 if (
5070 (expression_var = expression_rule(p))
5071 )
5072 {
5073 res = expression_var;
5074 goto done;
5075 }
5076 p->mark = mark;
5077 }
5078 res = NULL;
5079 done:
5080 return res;
5081}
5082
5083// expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef
5084static expr_ty
5085expression_rule(Parser *p)
5086{
5087 if (p->error_indicator) {
5088 return NULL;
5089 }
5090 expr_ty res = NULL;
5091 if (_PyPegen_is_memoized(p, expression_type, &res))
5092 return res;
5093 int mark = p->mark;
5094 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5095 p->error_indicator = 1;
5096 return NULL;
5097 }
5098 int start_lineno = p->tokens[mark]->lineno;
5099 UNUSED(start_lineno); // Only used by EXTRA macro
5100 int start_col_offset = p->tokens[mark]->col_offset;
5101 UNUSED(start_col_offset); // Only used by EXTRA macro
5102 { // disjunction 'if' disjunction 'else' expression
5103 expr_ty a;
5104 expr_ty b;
5105 expr_ty c;
5106 void *keyword;
5107 void *keyword_1;
5108 if (
5109 (a = disjunction_rule(p))
5110 &&
5111 (keyword = _PyPegen_expect_token(p, 510))
5112 &&
5113 (b = disjunction_rule(p))
5114 &&
5115 (keyword_1 = _PyPegen_expect_token(p, 516))
5116 &&
5117 (c = expression_rule(p))
5118 )
5119 {
5120 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5121 if (token == NULL) {
5122 return NULL;
5123 }
5124 int end_lineno = token->end_lineno;
5125 UNUSED(end_lineno); // Only used by EXTRA macro
5126 int end_col_offset = token->end_col_offset;
5127 UNUSED(end_col_offset); // Only used by EXTRA macro
5128 res = _Py_IfExp ( b , a , c , EXTRA );
5129 if (res == NULL && PyErr_Occurred()) {
5130 p->error_indicator = 1;
5131 return NULL;
5132 }
5133 goto done;
5134 }
5135 p->mark = mark;
5136 }
5137 { // disjunction
5138 expr_ty disjunction_var;
5139 if (
5140 (disjunction_var = disjunction_rule(p))
5141 )
5142 {
5143 res = disjunction_var;
5144 goto done;
5145 }
5146 p->mark = mark;
5147 }
5148 { // lambdef
5149 expr_ty lambdef_var;
5150 if (
5151 (lambdef_var = lambdef_rule(p))
5152 )
5153 {
5154 res = lambdef_var;
5155 goto done;
5156 }
5157 p->mark = mark;
5158 }
5159 res = NULL;
5160 done:
5161 _PyPegen_insert_memo(p, mark, expression_type, res);
5162 return res;
5163}
5164
5165// lambdef: 'lambda' lambda_parameters? ':' expression
5166static expr_ty
5167lambdef_rule(Parser *p)
5168{
5169 if (p->error_indicator) {
5170 return NULL;
5171 }
5172 expr_ty res = NULL;
5173 int mark = p->mark;
5174 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5175 p->error_indicator = 1;
5176 return NULL;
5177 }
5178 int start_lineno = p->tokens[mark]->lineno;
5179 UNUSED(start_lineno); // Only used by EXTRA macro
5180 int start_col_offset = p->tokens[mark]->col_offset;
5181 UNUSED(start_col_offset); // Only used by EXTRA macro
5182 { // 'lambda' lambda_parameters? ':' expression
5183 void *a;
5184 expr_ty b;
5185 void *keyword;
5186 void *literal;
5187 if (
5188 (keyword = _PyPegen_expect_token(p, 524))
5189 &&
5190 (a = lambda_parameters_rule(p), 1)
5191 &&
5192 (literal = _PyPegen_expect_token(p, 11))
5193 &&
5194 (b = expression_rule(p))
5195 )
5196 {
5197 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5198 if (token == NULL) {
5199 return NULL;
5200 }
5201 int end_lineno = token->end_lineno;
5202 UNUSED(end_lineno); // Only used by EXTRA macro
5203 int end_col_offset = token->end_col_offset;
5204 UNUSED(end_col_offset); // Only used by EXTRA macro
5205 res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA );
5206 if (res == NULL && PyErr_Occurred()) {
5207 p->error_indicator = 1;
5208 return NULL;
5209 }
5210 goto done;
5211 }
5212 p->mark = mark;
5213 }
5214 res = NULL;
5215 done:
5216 return res;
5217}
5218
5219// lambda_parameters:
5220// | lambda_slash_without_default [',' lambda_plain_names] [',' lambda_names_with_default] [',' lambda_star_etc?]
5221// | lambda_slash_with_default [',' lambda_names_with_default] [',' lambda_star_etc?]
5222// | lambda_plain_names [',' lambda_names_with_default] [',' lambda_star_etc?]
5223// | lambda_names_with_default [',' lambda_star_etc?]
5224// | lambda_star_etc
5225static arguments_ty
5226lambda_parameters_rule(Parser *p)
5227{
5228 if (p->error_indicator) {
5229 return NULL;
5230 }
5231 arguments_ty res = NULL;
5232 int mark = p->mark;
5233 { // lambda_slash_without_default [',' lambda_plain_names] [',' lambda_names_with_default] [',' lambda_star_etc?]
5234 asdl_seq* a;
5235 void *b;
5236 void *c;
5237 void *d;
5238 if (
5239 (a = lambda_slash_without_default_rule(p))
5240 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005241 (b = _tmp_75_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005242 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005243 (c = _tmp_76_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005244 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005245 (d = _tmp_77_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005246 )
5247 {
5248 res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
5249 if (res == NULL && PyErr_Occurred()) {
5250 p->error_indicator = 1;
5251 return NULL;
5252 }
5253 goto done;
5254 }
5255 p->mark = mark;
5256 }
5257 { // lambda_slash_with_default [',' lambda_names_with_default] [',' lambda_star_etc?]
5258 SlashWithDefault* a;
5259 void *b;
5260 void *c;
5261 if (
5262 (a = lambda_slash_with_default_rule(p))
5263 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005264 (b = _tmp_78_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005265 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005266 (c = _tmp_79_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005267 )
5268 {
5269 res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
5270 if (res == NULL && PyErr_Occurred()) {
5271 p->error_indicator = 1;
5272 return NULL;
5273 }
5274 goto done;
5275 }
5276 p->mark = mark;
5277 }
5278 { // lambda_plain_names [',' lambda_names_with_default] [',' lambda_star_etc?]
5279 asdl_seq* a;
5280 void *b;
5281 void *c;
5282 if (
5283 (a = lambda_plain_names_rule(p))
5284 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005285 (b = _tmp_80_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005286 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005287 (c = _tmp_81_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005288 )
5289 {
5290 res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
5291 if (res == NULL && PyErr_Occurred()) {
5292 p->error_indicator = 1;
5293 return NULL;
5294 }
5295 goto done;
5296 }
5297 p->mark = mark;
5298 }
5299 { // lambda_names_with_default [',' lambda_star_etc?]
5300 asdl_seq* a;
5301 void *b;
5302 if (
5303 (a = lambda_names_with_default_rule(p))
5304 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005305 (b = _tmp_82_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005306 )
5307 {
5308 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
5309 if (res == NULL && PyErr_Occurred()) {
5310 p->error_indicator = 1;
5311 return NULL;
5312 }
5313 goto done;
5314 }
5315 p->mark = mark;
5316 }
5317 { // lambda_star_etc
5318 StarEtc* a;
5319 if (
5320 (a = lambda_star_etc_rule(p))
5321 )
5322 {
5323 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
5324 if (res == NULL && PyErr_Occurred()) {
5325 p->error_indicator = 1;
5326 return NULL;
5327 }
5328 goto done;
5329 }
5330 p->mark = mark;
5331 }
5332 res = NULL;
5333 done:
5334 return res;
5335}
5336
5337// lambda_slash_without_default: lambda_plain_names ',' '/'
5338static asdl_seq*
5339lambda_slash_without_default_rule(Parser *p)
5340{
5341 if (p->error_indicator) {
5342 return NULL;
5343 }
5344 asdl_seq* res = NULL;
5345 int mark = p->mark;
5346 { // lambda_plain_names ',' '/'
5347 asdl_seq* a;
5348 void *literal;
5349 void *literal_1;
5350 if (
5351 (a = lambda_plain_names_rule(p))
5352 &&
5353 (literal = _PyPegen_expect_token(p, 12))
5354 &&
5355 (literal_1 = _PyPegen_expect_token(p, 17))
5356 )
5357 {
5358 res = a;
5359 if (res == NULL && PyErr_Occurred()) {
5360 p->error_indicator = 1;
5361 return NULL;
5362 }
5363 goto done;
5364 }
5365 p->mark = mark;
5366 }
5367 res = NULL;
5368 done:
5369 return res;
5370}
5371
5372// lambda_slash_with_default: [lambda_plain_names ','] lambda_names_with_default ',' '/'
5373static SlashWithDefault*
5374lambda_slash_with_default_rule(Parser *p)
5375{
5376 if (p->error_indicator) {
5377 return NULL;
5378 }
5379 SlashWithDefault* res = NULL;
5380 int mark = p->mark;
5381 { // [lambda_plain_names ','] lambda_names_with_default ',' '/'
5382 void *a;
5383 asdl_seq* b;
5384 void *literal;
5385 void *literal_1;
5386 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005387 (a = _tmp_83_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005388 &&
5389 (b = lambda_names_with_default_rule(p))
5390 &&
5391 (literal = _PyPegen_expect_token(p, 12))
5392 &&
5393 (literal_1 = _PyPegen_expect_token(p, 17))
5394 )
5395 {
5396 res = _PyPegen_slash_with_default ( p , 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 res = NULL;
5406 done:
5407 return res;
5408}
5409
5410// lambda_star_etc:
5411// | '*' lambda_plain_name lambda_name_with_optional_default* [',' lambda_kwds] ','?
5412// | '*' lambda_name_with_optional_default+ [',' lambda_kwds] ','?
5413// | lambda_kwds ','?
5414static StarEtc*
5415lambda_star_etc_rule(Parser *p)
5416{
5417 if (p->error_indicator) {
5418 return NULL;
5419 }
5420 StarEtc* res = NULL;
5421 int mark = p->mark;
5422 { // '*' lambda_plain_name lambda_name_with_optional_default* [',' lambda_kwds] ','?
5423 arg_ty a;
5424 asdl_seq * b;
5425 void *c;
5426 void *literal;
5427 void *opt_var;
5428 UNUSED(opt_var); // Silence compiler warnings
5429 if (
5430 (literal = _PyPegen_expect_token(p, 16))
5431 &&
5432 (a = lambda_plain_name_rule(p))
5433 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005434 (b = _loop0_84_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005435 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005436 (c = _tmp_85_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005437 &&
5438 (opt_var = _PyPegen_expect_token(p, 12), 1)
5439 )
5440 {
5441 res = _PyPegen_star_etc ( p , a , b , c );
5442 if (res == NULL && PyErr_Occurred()) {
5443 p->error_indicator = 1;
5444 return NULL;
5445 }
5446 goto done;
5447 }
5448 p->mark = mark;
5449 }
5450 { // '*' lambda_name_with_optional_default+ [',' lambda_kwds] ','?
5451 asdl_seq * b;
5452 void *c;
5453 void *literal;
5454 void *opt_var;
5455 UNUSED(opt_var); // Silence compiler warnings
5456 if (
5457 (literal = _PyPegen_expect_token(p, 16))
5458 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005459 (b = _loop1_86_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005460 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005461 (c = _tmp_87_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005462 &&
5463 (opt_var = _PyPegen_expect_token(p, 12), 1)
5464 )
5465 {
5466 res = _PyPegen_star_etc ( p , NULL , b , c );
5467 if (res == NULL && PyErr_Occurred()) {
5468 p->error_indicator = 1;
5469 return NULL;
5470 }
5471 goto done;
5472 }
5473 p->mark = mark;
5474 }
5475 { // lambda_kwds ','?
5476 arg_ty a;
5477 void *opt_var;
5478 UNUSED(opt_var); // Silence compiler warnings
5479 if (
5480 (a = lambda_kwds_rule(p))
5481 &&
5482 (opt_var = _PyPegen_expect_token(p, 12), 1)
5483 )
5484 {
5485 res = _PyPegen_star_etc ( p , NULL , NULL , a );
5486 if (res == NULL && PyErr_Occurred()) {
5487 p->error_indicator = 1;
5488 return NULL;
5489 }
5490 goto done;
5491 }
5492 p->mark = mark;
5493 }
5494 res = NULL;
5495 done:
5496 return res;
5497}
5498
5499// lambda_name_with_optional_default: ',' lambda_plain_name ['=' expression]
5500static NameDefaultPair*
5501lambda_name_with_optional_default_rule(Parser *p)
5502{
5503 if (p->error_indicator) {
5504 return NULL;
5505 }
5506 NameDefaultPair* res = NULL;
5507 int mark = p->mark;
5508 { // ',' lambda_plain_name ['=' expression]
5509 arg_ty a;
5510 void *b;
5511 void *literal;
5512 if (
5513 (literal = _PyPegen_expect_token(p, 12))
5514 &&
5515 (a = lambda_plain_name_rule(p))
5516 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005517 (b = _tmp_88_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005518 )
5519 {
Guido van Rossumc001c092020-04-30 12:12:19 -07005520 res = _PyPegen_name_default_pair ( p , a , b , NULL );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005521 if (res == NULL && PyErr_Occurred()) {
5522 p->error_indicator = 1;
5523 return NULL;
5524 }
5525 goto done;
5526 }
5527 p->mark = mark;
5528 }
5529 res = NULL;
5530 done:
5531 return res;
5532}
5533
5534// lambda_names_with_default: ','.lambda_name_with_default+
5535static asdl_seq*
5536lambda_names_with_default_rule(Parser *p)
5537{
5538 if (p->error_indicator) {
5539 return NULL;
5540 }
5541 asdl_seq* res = NULL;
5542 int mark = p->mark;
5543 { // ','.lambda_name_with_default+
5544 asdl_seq * a;
5545 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005546 (a = _gather_89_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005547 )
5548 {
5549 res = a;
5550 if (res == NULL && PyErr_Occurred()) {
5551 p->error_indicator = 1;
5552 return NULL;
5553 }
5554 goto done;
5555 }
5556 p->mark = mark;
5557 }
5558 res = NULL;
5559 done:
5560 return res;
5561}
5562
5563// lambda_name_with_default: lambda_plain_name '=' expression
5564static NameDefaultPair*
5565lambda_name_with_default_rule(Parser *p)
5566{
5567 if (p->error_indicator) {
5568 return NULL;
5569 }
5570 NameDefaultPair* res = NULL;
5571 int mark = p->mark;
5572 { // lambda_plain_name '=' expression
5573 expr_ty e;
5574 void *literal;
5575 arg_ty n;
5576 if (
5577 (n = lambda_plain_name_rule(p))
5578 &&
5579 (literal = _PyPegen_expect_token(p, 22))
5580 &&
5581 (e = expression_rule(p))
5582 )
5583 {
Guido van Rossumc001c092020-04-30 12:12:19 -07005584 res = _PyPegen_name_default_pair ( p , n , e , NULL );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005585 if (res == NULL && PyErr_Occurred()) {
5586 p->error_indicator = 1;
5587 return NULL;
5588 }
5589 goto done;
5590 }
5591 p->mark = mark;
5592 }
5593 res = NULL;
5594 done:
5595 return res;
5596}
5597
5598// lambda_plain_names: ','.(lambda_plain_name !'=')+
5599static asdl_seq*
5600lambda_plain_names_rule(Parser *p)
5601{
5602 if (p->error_indicator) {
5603 return NULL;
5604 }
5605 asdl_seq* res = NULL;
5606 int mark = p->mark;
5607 { // ','.(lambda_plain_name !'=')+
5608 asdl_seq * a;
5609 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005610 (a = _gather_91_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005611 )
5612 {
5613 res = a;
5614 if (res == NULL && PyErr_Occurred()) {
5615 p->error_indicator = 1;
5616 return NULL;
5617 }
5618 goto done;
5619 }
5620 p->mark = mark;
5621 }
5622 res = NULL;
5623 done:
5624 return res;
5625}
5626
5627// lambda_plain_name: NAME
5628static arg_ty
5629lambda_plain_name_rule(Parser *p)
5630{
5631 if (p->error_indicator) {
5632 return NULL;
5633 }
5634 arg_ty res = NULL;
5635 int mark = p->mark;
5636 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5637 p->error_indicator = 1;
5638 return NULL;
5639 }
5640 int start_lineno = p->tokens[mark]->lineno;
5641 UNUSED(start_lineno); // Only used by EXTRA macro
5642 int start_col_offset = p->tokens[mark]->col_offset;
5643 UNUSED(start_col_offset); // Only used by EXTRA macro
5644 { // NAME
5645 expr_ty a;
5646 if (
5647 (a = _PyPegen_name_token(p))
5648 )
5649 {
5650 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5651 if (token == NULL) {
5652 return NULL;
5653 }
5654 int end_lineno = token->end_lineno;
5655 UNUSED(end_lineno); // Only used by EXTRA macro
5656 int end_col_offset = token->end_col_offset;
5657 UNUSED(end_col_offset); // Only used by EXTRA macro
5658 res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA );
5659 if (res == NULL && PyErr_Occurred()) {
5660 p->error_indicator = 1;
5661 return NULL;
5662 }
5663 goto done;
5664 }
5665 p->mark = mark;
5666 }
5667 res = NULL;
5668 done:
5669 return res;
5670}
5671
5672// lambda_kwds: '**' lambda_plain_name
5673static arg_ty
5674lambda_kwds_rule(Parser *p)
5675{
5676 if (p->error_indicator) {
5677 return NULL;
5678 }
5679 arg_ty res = NULL;
5680 int mark = p->mark;
5681 { // '**' lambda_plain_name
5682 arg_ty a;
5683 void *literal;
5684 if (
5685 (literal = _PyPegen_expect_token(p, 35))
5686 &&
5687 (a = lambda_plain_name_rule(p))
5688 )
5689 {
5690 res = a;
5691 if (res == NULL && PyErr_Occurred()) {
5692 p->error_indicator = 1;
5693 return NULL;
5694 }
5695 goto done;
5696 }
5697 p->mark = mark;
5698 }
5699 res = NULL;
5700 done:
5701 return res;
5702}
5703
5704// disjunction: conjunction (('or' conjunction))+ | conjunction
5705static expr_ty
5706disjunction_rule(Parser *p)
5707{
5708 if (p->error_indicator) {
5709 return NULL;
5710 }
5711 expr_ty res = NULL;
5712 if (_PyPegen_is_memoized(p, disjunction_type, &res))
5713 return res;
5714 int mark = p->mark;
5715 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5716 p->error_indicator = 1;
5717 return NULL;
5718 }
5719 int start_lineno = p->tokens[mark]->lineno;
5720 UNUSED(start_lineno); // Only used by EXTRA macro
5721 int start_col_offset = p->tokens[mark]->col_offset;
5722 UNUSED(start_col_offset); // Only used by EXTRA macro
5723 { // conjunction (('or' conjunction))+
5724 expr_ty a;
5725 asdl_seq * b;
5726 if (
5727 (a = conjunction_rule(p))
5728 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005729 (b = _loop1_93_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005730 )
5731 {
5732 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5733 if (token == NULL) {
5734 return NULL;
5735 }
5736 int end_lineno = token->end_lineno;
5737 UNUSED(end_lineno); // Only used by EXTRA macro
5738 int end_col_offset = token->end_col_offset;
5739 UNUSED(end_col_offset); // Only used by EXTRA macro
5740 res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
5741 if (res == NULL && PyErr_Occurred()) {
5742 p->error_indicator = 1;
5743 return NULL;
5744 }
5745 goto done;
5746 }
5747 p->mark = mark;
5748 }
5749 { // conjunction
5750 expr_ty conjunction_var;
5751 if (
5752 (conjunction_var = conjunction_rule(p))
5753 )
5754 {
5755 res = conjunction_var;
5756 goto done;
5757 }
5758 p->mark = mark;
5759 }
5760 res = NULL;
5761 done:
5762 _PyPegen_insert_memo(p, mark, disjunction_type, res);
5763 return res;
5764}
5765
5766// conjunction: inversion (('and' inversion))+ | inversion
5767static expr_ty
5768conjunction_rule(Parser *p)
5769{
5770 if (p->error_indicator) {
5771 return NULL;
5772 }
5773 expr_ty res = NULL;
5774 if (_PyPegen_is_memoized(p, conjunction_type, &res))
5775 return res;
5776 int mark = p->mark;
5777 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5778 p->error_indicator = 1;
5779 return NULL;
5780 }
5781 int start_lineno = p->tokens[mark]->lineno;
5782 UNUSED(start_lineno); // Only used by EXTRA macro
5783 int start_col_offset = p->tokens[mark]->col_offset;
5784 UNUSED(start_col_offset); // Only used by EXTRA macro
5785 { // inversion (('and' inversion))+
5786 expr_ty a;
5787 asdl_seq * b;
5788 if (
5789 (a = inversion_rule(p))
5790 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005791 (b = _loop1_94_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005792 )
5793 {
5794 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5795 if (token == NULL) {
5796 return NULL;
5797 }
5798 int end_lineno = token->end_lineno;
5799 UNUSED(end_lineno); // Only used by EXTRA macro
5800 int end_col_offset = token->end_col_offset;
5801 UNUSED(end_col_offset); // Only used by EXTRA macro
5802 res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
5803 if (res == NULL && PyErr_Occurred()) {
5804 p->error_indicator = 1;
5805 return NULL;
5806 }
5807 goto done;
5808 }
5809 p->mark = mark;
5810 }
5811 { // inversion
5812 expr_ty inversion_var;
5813 if (
5814 (inversion_var = inversion_rule(p))
5815 )
5816 {
5817 res = inversion_var;
5818 goto done;
5819 }
5820 p->mark = mark;
5821 }
5822 res = NULL;
5823 done:
5824 _PyPegen_insert_memo(p, mark, conjunction_type, res);
5825 return res;
5826}
5827
5828// inversion: 'not' inversion | comparison
5829static expr_ty
5830inversion_rule(Parser *p)
5831{
5832 if (p->error_indicator) {
5833 return NULL;
5834 }
5835 expr_ty res = NULL;
5836 if (_PyPegen_is_memoized(p, inversion_type, &res))
5837 return res;
5838 int mark = p->mark;
5839 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5840 p->error_indicator = 1;
5841 return NULL;
5842 }
5843 int start_lineno = p->tokens[mark]->lineno;
5844 UNUSED(start_lineno); // Only used by EXTRA macro
5845 int start_col_offset = p->tokens[mark]->col_offset;
5846 UNUSED(start_col_offset); // Only used by EXTRA macro
5847 { // 'not' inversion
5848 expr_ty a;
5849 void *keyword;
5850 if (
5851 (keyword = _PyPegen_expect_token(p, 525))
5852 &&
5853 (a = inversion_rule(p))
5854 )
5855 {
5856 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5857 if (token == NULL) {
5858 return NULL;
5859 }
5860 int end_lineno = token->end_lineno;
5861 UNUSED(end_lineno); // Only used by EXTRA macro
5862 int end_col_offset = token->end_col_offset;
5863 UNUSED(end_col_offset); // Only used by EXTRA macro
5864 res = _Py_UnaryOp ( Not , a , EXTRA );
5865 if (res == NULL && PyErr_Occurred()) {
5866 p->error_indicator = 1;
5867 return NULL;
5868 }
5869 goto done;
5870 }
5871 p->mark = mark;
5872 }
5873 { // comparison
5874 expr_ty comparison_var;
5875 if (
5876 (comparison_var = comparison_rule(p))
5877 )
5878 {
5879 res = comparison_var;
5880 goto done;
5881 }
5882 p->mark = mark;
5883 }
5884 res = NULL;
5885 done:
5886 _PyPegen_insert_memo(p, mark, inversion_type, res);
5887 return res;
5888}
5889
5890// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or
5891static expr_ty
5892comparison_rule(Parser *p)
5893{
5894 if (p->error_indicator) {
5895 return NULL;
5896 }
5897 expr_ty res = NULL;
5898 int mark = p->mark;
5899 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5900 p->error_indicator = 1;
5901 return NULL;
5902 }
5903 int start_lineno = p->tokens[mark]->lineno;
5904 UNUSED(start_lineno); // Only used by EXTRA macro
5905 int start_col_offset = p->tokens[mark]->col_offset;
5906 UNUSED(start_col_offset); // Only used by EXTRA macro
5907 { // bitwise_or compare_op_bitwise_or_pair+
5908 expr_ty a;
5909 asdl_seq * b;
5910 if (
5911 (a = bitwise_or_rule(p))
5912 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005913 (b = _loop1_95_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005914 )
5915 {
5916 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5917 if (token == NULL) {
5918 return NULL;
5919 }
5920 int end_lineno = token->end_lineno;
5921 UNUSED(end_lineno); // Only used by EXTRA macro
5922 int end_col_offset = token->end_col_offset;
5923 UNUSED(end_col_offset); // Only used by EXTRA macro
5924 res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA );
5925 if (res == NULL && PyErr_Occurred()) {
5926 p->error_indicator = 1;
5927 return NULL;
5928 }
5929 goto done;
5930 }
5931 p->mark = mark;
5932 }
5933 { // bitwise_or
5934 expr_ty bitwise_or_var;
5935 if (
5936 (bitwise_or_var = bitwise_or_rule(p))
5937 )
5938 {
5939 res = bitwise_or_var;
5940 goto done;
5941 }
5942 p->mark = mark;
5943 }
5944 res = NULL;
5945 done:
5946 return res;
5947}
5948
5949// compare_op_bitwise_or_pair:
5950// | eq_bitwise_or
5951// | noteq_bitwise_or
5952// | lte_bitwise_or
5953// | lt_bitwise_or
5954// | gte_bitwise_or
5955// | gt_bitwise_or
5956// | notin_bitwise_or
5957// | in_bitwise_or
5958// | isnot_bitwise_or
5959// | is_bitwise_or
5960static CmpopExprPair*
5961compare_op_bitwise_or_pair_rule(Parser *p)
5962{
5963 if (p->error_indicator) {
5964 return NULL;
5965 }
5966 CmpopExprPair* res = NULL;
5967 int mark = p->mark;
5968 { // eq_bitwise_or
5969 CmpopExprPair* eq_bitwise_or_var;
5970 if (
5971 (eq_bitwise_or_var = eq_bitwise_or_rule(p))
5972 )
5973 {
5974 res = eq_bitwise_or_var;
5975 goto done;
5976 }
5977 p->mark = mark;
5978 }
5979 { // noteq_bitwise_or
5980 CmpopExprPair* noteq_bitwise_or_var;
5981 if (
5982 (noteq_bitwise_or_var = noteq_bitwise_or_rule(p))
5983 )
5984 {
5985 res = noteq_bitwise_or_var;
5986 goto done;
5987 }
5988 p->mark = mark;
5989 }
5990 { // lte_bitwise_or
5991 CmpopExprPair* lte_bitwise_or_var;
5992 if (
5993 (lte_bitwise_or_var = lte_bitwise_or_rule(p))
5994 )
5995 {
5996 res = lte_bitwise_or_var;
5997 goto done;
5998 }
5999 p->mark = mark;
6000 }
6001 { // lt_bitwise_or
6002 CmpopExprPair* lt_bitwise_or_var;
6003 if (
6004 (lt_bitwise_or_var = lt_bitwise_or_rule(p))
6005 )
6006 {
6007 res = lt_bitwise_or_var;
6008 goto done;
6009 }
6010 p->mark = mark;
6011 }
6012 { // gte_bitwise_or
6013 CmpopExprPair* gte_bitwise_or_var;
6014 if (
6015 (gte_bitwise_or_var = gte_bitwise_or_rule(p))
6016 )
6017 {
6018 res = gte_bitwise_or_var;
6019 goto done;
6020 }
6021 p->mark = mark;
6022 }
6023 { // gt_bitwise_or
6024 CmpopExprPair* gt_bitwise_or_var;
6025 if (
6026 (gt_bitwise_or_var = gt_bitwise_or_rule(p))
6027 )
6028 {
6029 res = gt_bitwise_or_var;
6030 goto done;
6031 }
6032 p->mark = mark;
6033 }
6034 { // notin_bitwise_or
6035 CmpopExprPair* notin_bitwise_or_var;
6036 if (
6037 (notin_bitwise_or_var = notin_bitwise_or_rule(p))
6038 )
6039 {
6040 res = notin_bitwise_or_var;
6041 goto done;
6042 }
6043 p->mark = mark;
6044 }
6045 { // in_bitwise_or
6046 CmpopExprPair* in_bitwise_or_var;
6047 if (
6048 (in_bitwise_or_var = in_bitwise_or_rule(p))
6049 )
6050 {
6051 res = in_bitwise_or_var;
6052 goto done;
6053 }
6054 p->mark = mark;
6055 }
6056 { // isnot_bitwise_or
6057 CmpopExprPair* isnot_bitwise_or_var;
6058 if (
6059 (isnot_bitwise_or_var = isnot_bitwise_or_rule(p))
6060 )
6061 {
6062 res = isnot_bitwise_or_var;
6063 goto done;
6064 }
6065 p->mark = mark;
6066 }
6067 { // is_bitwise_or
6068 CmpopExprPair* is_bitwise_or_var;
6069 if (
6070 (is_bitwise_or_var = is_bitwise_or_rule(p))
6071 )
6072 {
6073 res = is_bitwise_or_var;
6074 goto done;
6075 }
6076 p->mark = mark;
6077 }
6078 res = NULL;
6079 done:
6080 return res;
6081}
6082
6083// eq_bitwise_or: '==' bitwise_or
6084static CmpopExprPair*
6085eq_bitwise_or_rule(Parser *p)
6086{
6087 if (p->error_indicator) {
6088 return NULL;
6089 }
6090 CmpopExprPair* res = NULL;
6091 int mark = p->mark;
6092 { // '==' bitwise_or
6093 expr_ty a;
6094 void *literal;
6095 if (
6096 (literal = _PyPegen_expect_token(p, 27))
6097 &&
6098 (a = bitwise_or_rule(p))
6099 )
6100 {
6101 res = _PyPegen_cmpop_expr_pair ( p , Eq , a );
6102 if (res == NULL && PyErr_Occurred()) {
6103 p->error_indicator = 1;
6104 return NULL;
6105 }
6106 goto done;
6107 }
6108 p->mark = mark;
6109 }
6110 res = NULL;
6111 done:
6112 return res;
6113}
6114
Pablo Galindo2b74c832020-04-27 18:02:07 +01006115// noteq_bitwise_or: ('!=') bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006116static CmpopExprPair*
6117noteq_bitwise_or_rule(Parser *p)
6118{
6119 if (p->error_indicator) {
6120 return NULL;
6121 }
6122 CmpopExprPair* res = NULL;
6123 int mark = p->mark;
Pablo Galindo2b74c832020-04-27 18:02:07 +01006124 { // ('!=') bitwise_or
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03006125 void *_tmp_96_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006126 expr_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006127 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03006128 (_tmp_96_var = _tmp_96_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006129 &&
6130 (a = bitwise_or_rule(p))
6131 )
6132 {
6133 res = _PyPegen_cmpop_expr_pair ( p , NotEq , a );
6134 if (res == NULL && PyErr_Occurred()) {
6135 p->error_indicator = 1;
6136 return NULL;
6137 }
6138 goto done;
6139 }
6140 p->mark = mark;
6141 }
6142 res = NULL;
6143 done:
6144 return res;
6145}
6146
6147// lte_bitwise_or: '<=' bitwise_or
6148static CmpopExprPair*
6149lte_bitwise_or_rule(Parser *p)
6150{
6151 if (p->error_indicator) {
6152 return NULL;
6153 }
6154 CmpopExprPair* res = NULL;
6155 int mark = p->mark;
6156 { // '<=' bitwise_or
6157 expr_ty a;
6158 void *literal;
6159 if (
6160 (literal = _PyPegen_expect_token(p, 29))
6161 &&
6162 (a = bitwise_or_rule(p))
6163 )
6164 {
6165 res = _PyPegen_cmpop_expr_pair ( p , LtE , a );
6166 if (res == NULL && PyErr_Occurred()) {
6167 p->error_indicator = 1;
6168 return NULL;
6169 }
6170 goto done;
6171 }
6172 p->mark = mark;
6173 }
6174 res = NULL;
6175 done:
6176 return res;
6177}
6178
6179// lt_bitwise_or: '<' bitwise_or
6180static CmpopExprPair*
6181lt_bitwise_or_rule(Parser *p)
6182{
6183 if (p->error_indicator) {
6184 return NULL;
6185 }
6186 CmpopExprPair* res = NULL;
6187 int mark = p->mark;
6188 { // '<' bitwise_or
6189 expr_ty a;
6190 void *literal;
6191 if (
6192 (literal = _PyPegen_expect_token(p, 20))
6193 &&
6194 (a = bitwise_or_rule(p))
6195 )
6196 {
6197 res = _PyPegen_cmpop_expr_pair ( p , Lt , a );
6198 if (res == NULL && PyErr_Occurred()) {
6199 p->error_indicator = 1;
6200 return NULL;
6201 }
6202 goto done;
6203 }
6204 p->mark = mark;
6205 }
6206 res = NULL;
6207 done:
6208 return res;
6209}
6210
6211// gte_bitwise_or: '>=' bitwise_or
6212static CmpopExprPair*
6213gte_bitwise_or_rule(Parser *p)
6214{
6215 if (p->error_indicator) {
6216 return NULL;
6217 }
6218 CmpopExprPair* res = NULL;
6219 int mark = p->mark;
6220 { // '>=' bitwise_or
6221 expr_ty a;
6222 void *literal;
6223 if (
6224 (literal = _PyPegen_expect_token(p, 30))
6225 &&
6226 (a = bitwise_or_rule(p))
6227 )
6228 {
6229 res = _PyPegen_cmpop_expr_pair ( p , GtE , a );
6230 if (res == NULL && PyErr_Occurred()) {
6231 p->error_indicator = 1;
6232 return NULL;
6233 }
6234 goto done;
6235 }
6236 p->mark = mark;
6237 }
6238 res = NULL;
6239 done:
6240 return res;
6241}
6242
6243// gt_bitwise_or: '>' bitwise_or
6244static CmpopExprPair*
6245gt_bitwise_or_rule(Parser *p)
6246{
6247 if (p->error_indicator) {
6248 return NULL;
6249 }
6250 CmpopExprPair* res = NULL;
6251 int mark = p->mark;
6252 { // '>' bitwise_or
6253 expr_ty a;
6254 void *literal;
6255 if (
6256 (literal = _PyPegen_expect_token(p, 21))
6257 &&
6258 (a = bitwise_or_rule(p))
6259 )
6260 {
6261 res = _PyPegen_cmpop_expr_pair ( p , Gt , a );
6262 if (res == NULL && PyErr_Occurred()) {
6263 p->error_indicator = 1;
6264 return NULL;
6265 }
6266 goto done;
6267 }
6268 p->mark = mark;
6269 }
6270 res = NULL;
6271 done:
6272 return res;
6273}
6274
6275// notin_bitwise_or: 'not' 'in' bitwise_or
6276static CmpopExprPair*
6277notin_bitwise_or_rule(Parser *p)
6278{
6279 if (p->error_indicator) {
6280 return NULL;
6281 }
6282 CmpopExprPair* res = NULL;
6283 int mark = p->mark;
6284 { // 'not' 'in' bitwise_or
6285 expr_ty a;
6286 void *keyword;
6287 void *keyword_1;
6288 if (
6289 (keyword = _PyPegen_expect_token(p, 525))
6290 &&
6291 (keyword_1 = _PyPegen_expect_token(p, 518))
6292 &&
6293 (a = bitwise_or_rule(p))
6294 )
6295 {
6296 res = _PyPegen_cmpop_expr_pair ( p , NotIn , a );
6297 if (res == NULL && PyErr_Occurred()) {
6298 p->error_indicator = 1;
6299 return NULL;
6300 }
6301 goto done;
6302 }
6303 p->mark = mark;
6304 }
6305 res = NULL;
6306 done:
6307 return res;
6308}
6309
6310// in_bitwise_or: 'in' bitwise_or
6311static CmpopExprPair*
6312in_bitwise_or_rule(Parser *p)
6313{
6314 if (p->error_indicator) {
6315 return NULL;
6316 }
6317 CmpopExprPair* res = NULL;
6318 int mark = p->mark;
6319 { // 'in' bitwise_or
6320 expr_ty a;
6321 void *keyword;
6322 if (
6323 (keyword = _PyPegen_expect_token(p, 518))
6324 &&
6325 (a = bitwise_or_rule(p))
6326 )
6327 {
6328 res = _PyPegen_cmpop_expr_pair ( p , In , a );
6329 if (res == NULL && PyErr_Occurred()) {
6330 p->error_indicator = 1;
6331 return NULL;
6332 }
6333 goto done;
6334 }
6335 p->mark = mark;
6336 }
6337 res = NULL;
6338 done:
6339 return res;
6340}
6341
6342// isnot_bitwise_or: 'is' 'not' bitwise_or
6343static CmpopExprPair*
6344isnot_bitwise_or_rule(Parser *p)
6345{
6346 if (p->error_indicator) {
6347 return NULL;
6348 }
6349 CmpopExprPair* res = NULL;
6350 int mark = p->mark;
6351 { // 'is' 'not' bitwise_or
6352 expr_ty a;
6353 void *keyword;
6354 void *keyword_1;
6355 if (
6356 (keyword = _PyPegen_expect_token(p, 526))
6357 &&
6358 (keyword_1 = _PyPegen_expect_token(p, 525))
6359 &&
6360 (a = bitwise_or_rule(p))
6361 )
6362 {
6363 res = _PyPegen_cmpop_expr_pair ( p , IsNot , a );
6364 if (res == NULL && PyErr_Occurred()) {
6365 p->error_indicator = 1;
6366 return NULL;
6367 }
6368 goto done;
6369 }
6370 p->mark = mark;
6371 }
6372 res = NULL;
6373 done:
6374 return res;
6375}
6376
6377// is_bitwise_or: 'is' bitwise_or
6378static CmpopExprPair*
6379is_bitwise_or_rule(Parser *p)
6380{
6381 if (p->error_indicator) {
6382 return NULL;
6383 }
6384 CmpopExprPair* res = NULL;
6385 int mark = p->mark;
6386 { // 'is' bitwise_or
6387 expr_ty a;
6388 void *keyword;
6389 if (
6390 (keyword = _PyPegen_expect_token(p, 526))
6391 &&
6392 (a = bitwise_or_rule(p))
6393 )
6394 {
6395 res = _PyPegen_cmpop_expr_pair ( p , Is , a );
6396 if (res == NULL && PyErr_Occurred()) {
6397 p->error_indicator = 1;
6398 return NULL;
6399 }
6400 goto done;
6401 }
6402 p->mark = mark;
6403 }
6404 res = NULL;
6405 done:
6406 return res;
6407}
6408
6409// Left-recursive
6410// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor
6411static expr_ty bitwise_or_raw(Parser *);
6412static expr_ty
6413bitwise_or_rule(Parser *p)
6414{
6415 expr_ty res = NULL;
6416 if (_PyPegen_is_memoized(p, bitwise_or_type, &res))
6417 return res;
6418 int mark = p->mark;
6419 int resmark = p->mark;
6420 while (1) {
6421 int tmpvar_1 = _PyPegen_update_memo(p, mark, bitwise_or_type, res);
6422 if (tmpvar_1) {
6423 return res;
6424 }
6425 p->mark = mark;
6426 void *raw = bitwise_or_raw(p);
6427 if (raw == NULL || p->mark <= resmark)
6428 break;
6429 resmark = p->mark;
6430 res = raw;
6431 }
6432 p->mark = resmark;
6433 return res;
6434}
6435static expr_ty
6436bitwise_or_raw(Parser *p)
6437{
6438 if (p->error_indicator) {
6439 return NULL;
6440 }
6441 expr_ty res = NULL;
6442 int mark = p->mark;
6443 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6444 p->error_indicator = 1;
6445 return NULL;
6446 }
6447 int start_lineno = p->tokens[mark]->lineno;
6448 UNUSED(start_lineno); // Only used by EXTRA macro
6449 int start_col_offset = p->tokens[mark]->col_offset;
6450 UNUSED(start_col_offset); // Only used by EXTRA macro
6451 { // bitwise_or '|' bitwise_xor
6452 expr_ty a;
6453 expr_ty b;
6454 void *literal;
6455 if (
6456 (a = bitwise_or_rule(p))
6457 &&
6458 (literal = _PyPegen_expect_token(p, 18))
6459 &&
6460 (b = bitwise_xor_rule(p))
6461 )
6462 {
6463 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6464 if (token == NULL) {
6465 return NULL;
6466 }
6467 int end_lineno = token->end_lineno;
6468 UNUSED(end_lineno); // Only used by EXTRA macro
6469 int end_col_offset = token->end_col_offset;
6470 UNUSED(end_col_offset); // Only used by EXTRA macro
6471 res = _Py_BinOp ( a , BitOr , b , EXTRA );
6472 if (res == NULL && PyErr_Occurred()) {
6473 p->error_indicator = 1;
6474 return NULL;
6475 }
6476 goto done;
6477 }
6478 p->mark = mark;
6479 }
6480 { // bitwise_xor
6481 expr_ty bitwise_xor_var;
6482 if (
6483 (bitwise_xor_var = bitwise_xor_rule(p))
6484 )
6485 {
6486 res = bitwise_xor_var;
6487 goto done;
6488 }
6489 p->mark = mark;
6490 }
6491 res = NULL;
6492 done:
6493 return res;
6494}
6495
6496// Left-recursive
6497// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and
6498static expr_ty bitwise_xor_raw(Parser *);
6499static expr_ty
6500bitwise_xor_rule(Parser *p)
6501{
6502 expr_ty res = NULL;
6503 if (_PyPegen_is_memoized(p, bitwise_xor_type, &res))
6504 return res;
6505 int mark = p->mark;
6506 int resmark = p->mark;
6507 while (1) {
6508 int tmpvar_2 = _PyPegen_update_memo(p, mark, bitwise_xor_type, res);
6509 if (tmpvar_2) {
6510 return res;
6511 }
6512 p->mark = mark;
6513 void *raw = bitwise_xor_raw(p);
6514 if (raw == NULL || p->mark <= resmark)
6515 break;
6516 resmark = p->mark;
6517 res = raw;
6518 }
6519 p->mark = resmark;
6520 return res;
6521}
6522static expr_ty
6523bitwise_xor_raw(Parser *p)
6524{
6525 if (p->error_indicator) {
6526 return NULL;
6527 }
6528 expr_ty res = NULL;
6529 int mark = p->mark;
6530 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6531 p->error_indicator = 1;
6532 return NULL;
6533 }
6534 int start_lineno = p->tokens[mark]->lineno;
6535 UNUSED(start_lineno); // Only used by EXTRA macro
6536 int start_col_offset = p->tokens[mark]->col_offset;
6537 UNUSED(start_col_offset); // Only used by EXTRA macro
6538 { // bitwise_xor '^' bitwise_and
6539 expr_ty a;
6540 expr_ty b;
6541 void *literal;
6542 if (
6543 (a = bitwise_xor_rule(p))
6544 &&
6545 (literal = _PyPegen_expect_token(p, 32))
6546 &&
6547 (b = bitwise_and_rule(p))
6548 )
6549 {
6550 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6551 if (token == NULL) {
6552 return NULL;
6553 }
6554 int end_lineno = token->end_lineno;
6555 UNUSED(end_lineno); // Only used by EXTRA macro
6556 int end_col_offset = token->end_col_offset;
6557 UNUSED(end_col_offset); // Only used by EXTRA macro
6558 res = _Py_BinOp ( a , BitXor , b , EXTRA );
6559 if (res == NULL && PyErr_Occurred()) {
6560 p->error_indicator = 1;
6561 return NULL;
6562 }
6563 goto done;
6564 }
6565 p->mark = mark;
6566 }
6567 { // bitwise_and
6568 expr_ty bitwise_and_var;
6569 if (
6570 (bitwise_and_var = bitwise_and_rule(p))
6571 )
6572 {
6573 res = bitwise_and_var;
6574 goto done;
6575 }
6576 p->mark = mark;
6577 }
6578 res = NULL;
6579 done:
6580 return res;
6581}
6582
6583// Left-recursive
6584// bitwise_and: bitwise_and '&' shift_expr | shift_expr
6585static expr_ty bitwise_and_raw(Parser *);
6586static expr_ty
6587bitwise_and_rule(Parser *p)
6588{
6589 expr_ty res = NULL;
6590 if (_PyPegen_is_memoized(p, bitwise_and_type, &res))
6591 return res;
6592 int mark = p->mark;
6593 int resmark = p->mark;
6594 while (1) {
6595 int tmpvar_3 = _PyPegen_update_memo(p, mark, bitwise_and_type, res);
6596 if (tmpvar_3) {
6597 return res;
6598 }
6599 p->mark = mark;
6600 void *raw = bitwise_and_raw(p);
6601 if (raw == NULL || p->mark <= resmark)
6602 break;
6603 resmark = p->mark;
6604 res = raw;
6605 }
6606 p->mark = resmark;
6607 return res;
6608}
6609static expr_ty
6610bitwise_and_raw(Parser *p)
6611{
6612 if (p->error_indicator) {
6613 return NULL;
6614 }
6615 expr_ty res = NULL;
6616 int mark = p->mark;
6617 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6618 p->error_indicator = 1;
6619 return NULL;
6620 }
6621 int start_lineno = p->tokens[mark]->lineno;
6622 UNUSED(start_lineno); // Only used by EXTRA macro
6623 int start_col_offset = p->tokens[mark]->col_offset;
6624 UNUSED(start_col_offset); // Only used by EXTRA macro
6625 { // bitwise_and '&' shift_expr
6626 expr_ty a;
6627 expr_ty b;
6628 void *literal;
6629 if (
6630 (a = bitwise_and_rule(p))
6631 &&
6632 (literal = _PyPegen_expect_token(p, 19))
6633 &&
6634 (b = shift_expr_rule(p))
6635 )
6636 {
6637 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6638 if (token == NULL) {
6639 return NULL;
6640 }
6641 int end_lineno = token->end_lineno;
6642 UNUSED(end_lineno); // Only used by EXTRA macro
6643 int end_col_offset = token->end_col_offset;
6644 UNUSED(end_col_offset); // Only used by EXTRA macro
6645 res = _Py_BinOp ( a , BitAnd , b , EXTRA );
6646 if (res == NULL && PyErr_Occurred()) {
6647 p->error_indicator = 1;
6648 return NULL;
6649 }
6650 goto done;
6651 }
6652 p->mark = mark;
6653 }
6654 { // shift_expr
6655 expr_ty shift_expr_var;
6656 if (
6657 (shift_expr_var = shift_expr_rule(p))
6658 )
6659 {
6660 res = shift_expr_var;
6661 goto done;
6662 }
6663 p->mark = mark;
6664 }
6665 res = NULL;
6666 done:
6667 return res;
6668}
6669
6670// Left-recursive
6671// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum
6672static expr_ty shift_expr_raw(Parser *);
6673static expr_ty
6674shift_expr_rule(Parser *p)
6675{
6676 expr_ty res = NULL;
6677 if (_PyPegen_is_memoized(p, shift_expr_type, &res))
6678 return res;
6679 int mark = p->mark;
6680 int resmark = p->mark;
6681 while (1) {
6682 int tmpvar_4 = _PyPegen_update_memo(p, mark, shift_expr_type, res);
6683 if (tmpvar_4) {
6684 return res;
6685 }
6686 p->mark = mark;
6687 void *raw = shift_expr_raw(p);
6688 if (raw == NULL || p->mark <= resmark)
6689 break;
6690 resmark = p->mark;
6691 res = raw;
6692 }
6693 p->mark = resmark;
6694 return res;
6695}
6696static expr_ty
6697shift_expr_raw(Parser *p)
6698{
6699 if (p->error_indicator) {
6700 return NULL;
6701 }
6702 expr_ty res = NULL;
6703 int mark = p->mark;
6704 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6705 p->error_indicator = 1;
6706 return NULL;
6707 }
6708 int start_lineno = p->tokens[mark]->lineno;
6709 UNUSED(start_lineno); // Only used by EXTRA macro
6710 int start_col_offset = p->tokens[mark]->col_offset;
6711 UNUSED(start_col_offset); // Only used by EXTRA macro
6712 { // shift_expr '<<' sum
6713 expr_ty a;
6714 expr_ty b;
6715 void *literal;
6716 if (
6717 (a = shift_expr_rule(p))
6718 &&
6719 (literal = _PyPegen_expect_token(p, 33))
6720 &&
6721 (b = sum_rule(p))
6722 )
6723 {
6724 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6725 if (token == NULL) {
6726 return NULL;
6727 }
6728 int end_lineno = token->end_lineno;
6729 UNUSED(end_lineno); // Only used by EXTRA macro
6730 int end_col_offset = token->end_col_offset;
6731 UNUSED(end_col_offset); // Only used by EXTRA macro
6732 res = _Py_BinOp ( a , LShift , b , EXTRA );
6733 if (res == NULL && PyErr_Occurred()) {
6734 p->error_indicator = 1;
6735 return NULL;
6736 }
6737 goto done;
6738 }
6739 p->mark = mark;
6740 }
6741 { // shift_expr '>>' sum
6742 expr_ty a;
6743 expr_ty b;
6744 void *literal;
6745 if (
6746 (a = shift_expr_rule(p))
6747 &&
6748 (literal = _PyPegen_expect_token(p, 34))
6749 &&
6750 (b = sum_rule(p))
6751 )
6752 {
6753 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6754 if (token == NULL) {
6755 return NULL;
6756 }
6757 int end_lineno = token->end_lineno;
6758 UNUSED(end_lineno); // Only used by EXTRA macro
6759 int end_col_offset = token->end_col_offset;
6760 UNUSED(end_col_offset); // Only used by EXTRA macro
6761 res = _Py_BinOp ( a , RShift , b , EXTRA );
6762 if (res == NULL && PyErr_Occurred()) {
6763 p->error_indicator = 1;
6764 return NULL;
6765 }
6766 goto done;
6767 }
6768 p->mark = mark;
6769 }
6770 { // sum
6771 expr_ty sum_var;
6772 if (
6773 (sum_var = sum_rule(p))
6774 )
6775 {
6776 res = sum_var;
6777 goto done;
6778 }
6779 p->mark = mark;
6780 }
6781 res = NULL;
6782 done:
6783 return res;
6784}
6785
6786// Left-recursive
6787// sum: sum '+' term | sum '-' term | term
6788static expr_ty sum_raw(Parser *);
6789static expr_ty
6790sum_rule(Parser *p)
6791{
6792 expr_ty res = NULL;
6793 if (_PyPegen_is_memoized(p, sum_type, &res))
6794 return res;
6795 int mark = p->mark;
6796 int resmark = p->mark;
6797 while (1) {
6798 int tmpvar_5 = _PyPegen_update_memo(p, mark, sum_type, res);
6799 if (tmpvar_5) {
6800 return res;
6801 }
6802 p->mark = mark;
6803 void *raw = sum_raw(p);
6804 if (raw == NULL || p->mark <= resmark)
6805 break;
6806 resmark = p->mark;
6807 res = raw;
6808 }
6809 p->mark = resmark;
6810 return res;
6811}
6812static expr_ty
6813sum_raw(Parser *p)
6814{
6815 if (p->error_indicator) {
6816 return NULL;
6817 }
6818 expr_ty res = NULL;
6819 int mark = p->mark;
6820 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6821 p->error_indicator = 1;
6822 return NULL;
6823 }
6824 int start_lineno = p->tokens[mark]->lineno;
6825 UNUSED(start_lineno); // Only used by EXTRA macro
6826 int start_col_offset = p->tokens[mark]->col_offset;
6827 UNUSED(start_col_offset); // Only used by EXTRA macro
6828 { // sum '+' term
6829 expr_ty a;
6830 expr_ty b;
6831 void *literal;
6832 if (
6833 (a = sum_rule(p))
6834 &&
6835 (literal = _PyPegen_expect_token(p, 14))
6836 &&
6837 (b = term_rule(p))
6838 )
6839 {
6840 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6841 if (token == NULL) {
6842 return NULL;
6843 }
6844 int end_lineno = token->end_lineno;
6845 UNUSED(end_lineno); // Only used by EXTRA macro
6846 int end_col_offset = token->end_col_offset;
6847 UNUSED(end_col_offset); // Only used by EXTRA macro
6848 res = _Py_BinOp ( a , Add , b , EXTRA );
6849 if (res == NULL && PyErr_Occurred()) {
6850 p->error_indicator = 1;
6851 return NULL;
6852 }
6853 goto done;
6854 }
6855 p->mark = mark;
6856 }
6857 { // sum '-' term
6858 expr_ty a;
6859 expr_ty b;
6860 void *literal;
6861 if (
6862 (a = sum_rule(p))
6863 &&
6864 (literal = _PyPegen_expect_token(p, 15))
6865 &&
6866 (b = term_rule(p))
6867 )
6868 {
6869 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6870 if (token == NULL) {
6871 return NULL;
6872 }
6873 int end_lineno = token->end_lineno;
6874 UNUSED(end_lineno); // Only used by EXTRA macro
6875 int end_col_offset = token->end_col_offset;
6876 UNUSED(end_col_offset); // Only used by EXTRA macro
6877 res = _Py_BinOp ( a , Sub , b , EXTRA );
6878 if (res == NULL && PyErr_Occurred()) {
6879 p->error_indicator = 1;
6880 return NULL;
6881 }
6882 goto done;
6883 }
6884 p->mark = mark;
6885 }
6886 { // term
6887 expr_ty term_var;
6888 if (
6889 (term_var = term_rule(p))
6890 )
6891 {
6892 res = term_var;
6893 goto done;
6894 }
6895 p->mark = mark;
6896 }
6897 res = NULL;
6898 done:
6899 return res;
6900}
6901
6902// Left-recursive
6903// term:
6904// | term '*' factor
6905// | term '/' factor
6906// | term '//' factor
6907// | term '%' factor
6908// | term '@' factor
6909// | factor
6910static expr_ty term_raw(Parser *);
6911static expr_ty
6912term_rule(Parser *p)
6913{
6914 expr_ty res = NULL;
6915 if (_PyPegen_is_memoized(p, term_type, &res))
6916 return res;
6917 int mark = p->mark;
6918 int resmark = p->mark;
6919 while (1) {
6920 int tmpvar_6 = _PyPegen_update_memo(p, mark, term_type, res);
6921 if (tmpvar_6) {
6922 return res;
6923 }
6924 p->mark = mark;
6925 void *raw = term_raw(p);
6926 if (raw == NULL || p->mark <= resmark)
6927 break;
6928 resmark = p->mark;
6929 res = raw;
6930 }
6931 p->mark = resmark;
6932 return res;
6933}
6934static expr_ty
6935term_raw(Parser *p)
6936{
6937 if (p->error_indicator) {
6938 return NULL;
6939 }
6940 expr_ty res = NULL;
6941 int mark = p->mark;
6942 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6943 p->error_indicator = 1;
6944 return NULL;
6945 }
6946 int start_lineno = p->tokens[mark]->lineno;
6947 UNUSED(start_lineno); // Only used by EXTRA macro
6948 int start_col_offset = p->tokens[mark]->col_offset;
6949 UNUSED(start_col_offset); // Only used by EXTRA macro
6950 { // term '*' factor
6951 expr_ty a;
6952 expr_ty b;
6953 void *literal;
6954 if (
6955 (a = term_rule(p))
6956 &&
6957 (literal = _PyPegen_expect_token(p, 16))
6958 &&
6959 (b = factor_rule(p))
6960 )
6961 {
6962 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6963 if (token == NULL) {
6964 return NULL;
6965 }
6966 int end_lineno = token->end_lineno;
6967 UNUSED(end_lineno); // Only used by EXTRA macro
6968 int end_col_offset = token->end_col_offset;
6969 UNUSED(end_col_offset); // Only used by EXTRA macro
6970 res = _Py_BinOp ( a , Mult , b , EXTRA );
6971 if (res == NULL && PyErr_Occurred()) {
6972 p->error_indicator = 1;
6973 return NULL;
6974 }
6975 goto done;
6976 }
6977 p->mark = mark;
6978 }
6979 { // term '/' factor
6980 expr_ty a;
6981 expr_ty b;
6982 void *literal;
6983 if (
6984 (a = term_rule(p))
6985 &&
6986 (literal = _PyPegen_expect_token(p, 17))
6987 &&
6988 (b = factor_rule(p))
6989 )
6990 {
6991 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6992 if (token == NULL) {
6993 return NULL;
6994 }
6995 int end_lineno = token->end_lineno;
6996 UNUSED(end_lineno); // Only used by EXTRA macro
6997 int end_col_offset = token->end_col_offset;
6998 UNUSED(end_col_offset); // Only used by EXTRA macro
6999 res = _Py_BinOp ( a , Div , b , EXTRA );
7000 if (res == NULL && PyErr_Occurred()) {
7001 p->error_indicator = 1;
7002 return NULL;
7003 }
7004 goto done;
7005 }
7006 p->mark = mark;
7007 }
7008 { // term '//' factor
7009 expr_ty a;
7010 expr_ty b;
7011 void *literal;
7012 if (
7013 (a = term_rule(p))
7014 &&
7015 (literal = _PyPegen_expect_token(p, 47))
7016 &&
7017 (b = factor_rule(p))
7018 )
7019 {
7020 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7021 if (token == NULL) {
7022 return NULL;
7023 }
7024 int end_lineno = token->end_lineno;
7025 UNUSED(end_lineno); // Only used by EXTRA macro
7026 int end_col_offset = token->end_col_offset;
7027 UNUSED(end_col_offset); // Only used by EXTRA macro
7028 res = _Py_BinOp ( a , FloorDiv , b , EXTRA );
7029 if (res == NULL && PyErr_Occurred()) {
7030 p->error_indicator = 1;
7031 return NULL;
7032 }
7033 goto done;
7034 }
7035 p->mark = mark;
7036 }
7037 { // term '%' factor
7038 expr_ty a;
7039 expr_ty b;
7040 void *literal;
7041 if (
7042 (a = term_rule(p))
7043 &&
7044 (literal = _PyPegen_expect_token(p, 24))
7045 &&
7046 (b = factor_rule(p))
7047 )
7048 {
7049 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7050 if (token == NULL) {
7051 return NULL;
7052 }
7053 int end_lineno = token->end_lineno;
7054 UNUSED(end_lineno); // Only used by EXTRA macro
7055 int end_col_offset = token->end_col_offset;
7056 UNUSED(end_col_offset); // Only used by EXTRA macro
7057 res = _Py_BinOp ( a , Mod , b , EXTRA );
7058 if (res == NULL && PyErr_Occurred()) {
7059 p->error_indicator = 1;
7060 return NULL;
7061 }
7062 goto done;
7063 }
7064 p->mark = mark;
7065 }
7066 { // term '@' factor
7067 expr_ty a;
7068 expr_ty b;
7069 void *literal;
7070 if (
7071 (a = term_rule(p))
7072 &&
7073 (literal = _PyPegen_expect_token(p, 49))
7074 &&
7075 (b = factor_rule(p))
7076 )
7077 {
7078 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7079 if (token == NULL) {
7080 return NULL;
7081 }
7082 int end_lineno = token->end_lineno;
7083 UNUSED(end_lineno); // Only used by EXTRA macro
7084 int end_col_offset = token->end_col_offset;
7085 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007086 res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007087 if (res == NULL && PyErr_Occurred()) {
7088 p->error_indicator = 1;
7089 return NULL;
7090 }
7091 goto done;
7092 }
7093 p->mark = mark;
7094 }
7095 { // factor
7096 expr_ty factor_var;
7097 if (
7098 (factor_var = factor_rule(p))
7099 )
7100 {
7101 res = factor_var;
7102 goto done;
7103 }
7104 p->mark = mark;
7105 }
7106 res = NULL;
7107 done:
7108 return res;
7109}
7110
7111// factor: '+' factor | '-' factor | '~' factor | power
7112static expr_ty
7113factor_rule(Parser *p)
7114{
7115 if (p->error_indicator) {
7116 return NULL;
7117 }
7118 expr_ty res = NULL;
7119 if (_PyPegen_is_memoized(p, factor_type, &res))
7120 return res;
7121 int mark = p->mark;
7122 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7123 p->error_indicator = 1;
7124 return NULL;
7125 }
7126 int start_lineno = p->tokens[mark]->lineno;
7127 UNUSED(start_lineno); // Only used by EXTRA macro
7128 int start_col_offset = p->tokens[mark]->col_offset;
7129 UNUSED(start_col_offset); // Only used by EXTRA macro
7130 { // '+' factor
7131 expr_ty a;
7132 void *literal;
7133 if (
7134 (literal = _PyPegen_expect_token(p, 14))
7135 &&
7136 (a = factor_rule(p))
7137 )
7138 {
7139 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7140 if (token == NULL) {
7141 return NULL;
7142 }
7143 int end_lineno = token->end_lineno;
7144 UNUSED(end_lineno); // Only used by EXTRA macro
7145 int end_col_offset = token->end_col_offset;
7146 UNUSED(end_col_offset); // Only used by EXTRA macro
7147 res = _Py_UnaryOp ( UAdd , a , EXTRA );
7148 if (res == NULL && PyErr_Occurred()) {
7149 p->error_indicator = 1;
7150 return NULL;
7151 }
7152 goto done;
7153 }
7154 p->mark = mark;
7155 }
7156 { // '-' factor
7157 expr_ty a;
7158 void *literal;
7159 if (
7160 (literal = _PyPegen_expect_token(p, 15))
7161 &&
7162 (a = factor_rule(p))
7163 )
7164 {
7165 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7166 if (token == NULL) {
7167 return NULL;
7168 }
7169 int end_lineno = token->end_lineno;
7170 UNUSED(end_lineno); // Only used by EXTRA macro
7171 int end_col_offset = token->end_col_offset;
7172 UNUSED(end_col_offset); // Only used by EXTRA macro
7173 res = _Py_UnaryOp ( USub , a , EXTRA );
7174 if (res == NULL && PyErr_Occurred()) {
7175 p->error_indicator = 1;
7176 return NULL;
7177 }
7178 goto done;
7179 }
7180 p->mark = mark;
7181 }
7182 { // '~' factor
7183 expr_ty a;
7184 void *literal;
7185 if (
7186 (literal = _PyPegen_expect_token(p, 31))
7187 &&
7188 (a = factor_rule(p))
7189 )
7190 {
7191 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7192 if (token == NULL) {
7193 return NULL;
7194 }
7195 int end_lineno = token->end_lineno;
7196 UNUSED(end_lineno); // Only used by EXTRA macro
7197 int end_col_offset = token->end_col_offset;
7198 UNUSED(end_col_offset); // Only used by EXTRA macro
7199 res = _Py_UnaryOp ( Invert , a , EXTRA );
7200 if (res == NULL && PyErr_Occurred()) {
7201 p->error_indicator = 1;
7202 return NULL;
7203 }
7204 goto done;
7205 }
7206 p->mark = mark;
7207 }
7208 { // power
7209 expr_ty power_var;
7210 if (
7211 (power_var = power_rule(p))
7212 )
7213 {
7214 res = power_var;
7215 goto done;
7216 }
7217 p->mark = mark;
7218 }
7219 res = NULL;
7220 done:
7221 _PyPegen_insert_memo(p, mark, factor_type, res);
7222 return res;
7223}
7224
7225// power: await_primary '**' factor | await_primary
7226static expr_ty
7227power_rule(Parser *p)
7228{
7229 if (p->error_indicator) {
7230 return NULL;
7231 }
7232 expr_ty res = NULL;
7233 int mark = p->mark;
7234 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7235 p->error_indicator = 1;
7236 return NULL;
7237 }
7238 int start_lineno = p->tokens[mark]->lineno;
7239 UNUSED(start_lineno); // Only used by EXTRA macro
7240 int start_col_offset = p->tokens[mark]->col_offset;
7241 UNUSED(start_col_offset); // Only used by EXTRA macro
7242 { // await_primary '**' factor
7243 expr_ty a;
7244 expr_ty b;
7245 void *literal;
7246 if (
7247 (a = await_primary_rule(p))
7248 &&
7249 (literal = _PyPegen_expect_token(p, 35))
7250 &&
7251 (b = factor_rule(p))
7252 )
7253 {
7254 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7255 if (token == NULL) {
7256 return NULL;
7257 }
7258 int end_lineno = token->end_lineno;
7259 UNUSED(end_lineno); // Only used by EXTRA macro
7260 int end_col_offset = token->end_col_offset;
7261 UNUSED(end_col_offset); // Only used by EXTRA macro
7262 res = _Py_BinOp ( a , Pow , b , EXTRA );
7263 if (res == NULL && PyErr_Occurred()) {
7264 p->error_indicator = 1;
7265 return NULL;
7266 }
7267 goto done;
7268 }
7269 p->mark = mark;
7270 }
7271 { // await_primary
7272 expr_ty await_primary_var;
7273 if (
7274 (await_primary_var = await_primary_rule(p))
7275 )
7276 {
7277 res = await_primary_var;
7278 goto done;
7279 }
7280 p->mark = mark;
7281 }
7282 res = NULL;
7283 done:
7284 return res;
7285}
7286
7287// await_primary: AWAIT primary | primary
7288static expr_ty
7289await_primary_rule(Parser *p)
7290{
7291 if (p->error_indicator) {
7292 return NULL;
7293 }
7294 expr_ty res = NULL;
7295 if (_PyPegen_is_memoized(p, await_primary_type, &res))
7296 return res;
7297 int mark = p->mark;
7298 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7299 p->error_indicator = 1;
7300 return NULL;
7301 }
7302 int start_lineno = p->tokens[mark]->lineno;
7303 UNUSED(start_lineno); // Only used by EXTRA macro
7304 int start_col_offset = p->tokens[mark]->col_offset;
7305 UNUSED(start_col_offset); // Only used by EXTRA macro
7306 { // AWAIT primary
7307 expr_ty a;
7308 void *await_var;
7309 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +01007310 (await_var = _PyPegen_expect_token(p, AWAIT))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007311 &&
7312 (a = primary_rule(p))
7313 )
7314 {
7315 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7316 if (token == NULL) {
7317 return NULL;
7318 }
7319 int end_lineno = token->end_lineno;
7320 UNUSED(end_lineno); // Only used by EXTRA macro
7321 int end_col_offset = token->end_col_offset;
7322 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007323 res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007324 if (res == NULL && PyErr_Occurred()) {
7325 p->error_indicator = 1;
7326 return NULL;
7327 }
7328 goto done;
7329 }
7330 p->mark = mark;
7331 }
7332 { // primary
7333 expr_ty primary_var;
7334 if (
7335 (primary_var = primary_rule(p))
7336 )
7337 {
7338 res = primary_var;
7339 goto done;
7340 }
7341 p->mark = mark;
7342 }
7343 res = NULL;
7344 done:
7345 _PyPegen_insert_memo(p, mark, await_primary_type, res);
7346 return res;
7347}
7348
7349// Left-recursive
7350// primary:
7351// | primary '.' NAME
7352// | primary genexp
7353// | primary '(' arguments? ')'
7354// | primary '[' slices ']'
7355// | atom
7356static expr_ty primary_raw(Parser *);
7357static expr_ty
7358primary_rule(Parser *p)
7359{
7360 expr_ty res = NULL;
7361 if (_PyPegen_is_memoized(p, primary_type, &res))
7362 return res;
7363 int mark = p->mark;
7364 int resmark = p->mark;
7365 while (1) {
7366 int tmpvar_7 = _PyPegen_update_memo(p, mark, primary_type, res);
7367 if (tmpvar_7) {
7368 return res;
7369 }
7370 p->mark = mark;
7371 void *raw = primary_raw(p);
7372 if (raw == NULL || p->mark <= resmark)
7373 break;
7374 resmark = p->mark;
7375 res = raw;
7376 }
7377 p->mark = resmark;
7378 return res;
7379}
7380static expr_ty
7381primary_raw(Parser *p)
7382{
7383 if (p->error_indicator) {
7384 return NULL;
7385 }
7386 expr_ty res = NULL;
7387 int mark = p->mark;
7388 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7389 p->error_indicator = 1;
7390 return NULL;
7391 }
7392 int start_lineno = p->tokens[mark]->lineno;
7393 UNUSED(start_lineno); // Only used by EXTRA macro
7394 int start_col_offset = p->tokens[mark]->col_offset;
7395 UNUSED(start_col_offset); // Only used by EXTRA macro
7396 { // primary '.' NAME
7397 expr_ty a;
7398 expr_ty b;
7399 void *literal;
7400 if (
7401 (a = primary_rule(p))
7402 &&
7403 (literal = _PyPegen_expect_token(p, 23))
7404 &&
7405 (b = _PyPegen_name_token(p))
7406 )
7407 {
7408 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7409 if (token == NULL) {
7410 return NULL;
7411 }
7412 int end_lineno = token->end_lineno;
7413 UNUSED(end_lineno); // Only used by EXTRA macro
7414 int end_col_offset = token->end_col_offset;
7415 UNUSED(end_col_offset); // Only used by EXTRA macro
7416 res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
7417 if (res == NULL && PyErr_Occurred()) {
7418 p->error_indicator = 1;
7419 return NULL;
7420 }
7421 goto done;
7422 }
7423 p->mark = mark;
7424 }
7425 { // primary genexp
7426 expr_ty a;
7427 expr_ty b;
7428 if (
7429 (a = primary_rule(p))
7430 &&
7431 (b = genexp_rule(p))
7432 )
7433 {
7434 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7435 if (token == NULL) {
7436 return NULL;
7437 }
7438 int end_lineno = token->end_lineno;
7439 UNUSED(end_lineno); // Only used by EXTRA macro
7440 int end_col_offset = token->end_col_offset;
7441 UNUSED(end_col_offset); // Only used by EXTRA macro
7442 res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
7443 if (res == NULL && PyErr_Occurred()) {
7444 p->error_indicator = 1;
7445 return NULL;
7446 }
7447 goto done;
7448 }
7449 p->mark = mark;
7450 }
7451 { // primary '(' arguments? ')'
7452 expr_ty a;
7453 void *b;
7454 void *literal;
7455 void *literal_1;
7456 if (
7457 (a = primary_rule(p))
7458 &&
7459 (literal = _PyPegen_expect_token(p, 7))
7460 &&
7461 (b = arguments_rule(p), 1)
7462 &&
7463 (literal_1 = _PyPegen_expect_token(p, 8))
7464 )
7465 {
7466 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7467 if (token == NULL) {
7468 return NULL;
7469 }
7470 int end_lineno = token->end_lineno;
7471 UNUSED(end_lineno); // Only used by EXTRA macro
7472 int end_col_offset = token->end_col_offset;
7473 UNUSED(end_col_offset); // Only used by EXTRA macro
7474 res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
7475 if (res == NULL && PyErr_Occurred()) {
7476 p->error_indicator = 1;
7477 return NULL;
7478 }
7479 goto done;
7480 }
7481 p->mark = mark;
7482 }
7483 { // primary '[' slices ']'
7484 expr_ty a;
7485 expr_ty b;
7486 void *literal;
7487 void *literal_1;
7488 if (
7489 (a = primary_rule(p))
7490 &&
7491 (literal = _PyPegen_expect_token(p, 9))
7492 &&
7493 (b = slices_rule(p))
7494 &&
7495 (literal_1 = _PyPegen_expect_token(p, 10))
7496 )
7497 {
7498 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7499 if (token == NULL) {
7500 return NULL;
7501 }
7502 int end_lineno = token->end_lineno;
7503 UNUSED(end_lineno); // Only used by EXTRA macro
7504 int end_col_offset = token->end_col_offset;
7505 UNUSED(end_col_offset); // Only used by EXTRA macro
7506 res = _Py_Subscript ( a , b , Load , EXTRA );
7507 if (res == NULL && PyErr_Occurred()) {
7508 p->error_indicator = 1;
7509 return NULL;
7510 }
7511 goto done;
7512 }
7513 p->mark = mark;
7514 }
7515 { // atom
7516 expr_ty atom_var;
7517 if (
7518 (atom_var = atom_rule(p))
7519 )
7520 {
7521 res = atom_var;
7522 goto done;
7523 }
7524 p->mark = mark;
7525 }
7526 res = NULL;
7527 done:
7528 return res;
7529}
7530
7531// slices: slice !',' | ','.slice+ ','?
7532static expr_ty
7533slices_rule(Parser *p)
7534{
7535 if (p->error_indicator) {
7536 return NULL;
7537 }
7538 expr_ty res = NULL;
7539 int mark = p->mark;
7540 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7541 p->error_indicator = 1;
7542 return NULL;
7543 }
7544 int start_lineno = p->tokens[mark]->lineno;
7545 UNUSED(start_lineno); // Only used by EXTRA macro
7546 int start_col_offset = p->tokens[mark]->col_offset;
7547 UNUSED(start_col_offset); // Only used by EXTRA macro
7548 { // slice !','
7549 expr_ty a;
7550 if (
7551 (a = slice_rule(p))
7552 &&
7553 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12)
7554 )
7555 {
7556 res = a;
7557 if (res == NULL && PyErr_Occurred()) {
7558 p->error_indicator = 1;
7559 return NULL;
7560 }
7561 goto done;
7562 }
7563 p->mark = mark;
7564 }
7565 { // ','.slice+ ','?
7566 asdl_seq * a;
7567 void *opt_var;
7568 UNUSED(opt_var); // Silence compiler warnings
7569 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007570 (a = _gather_97_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007571 &&
7572 (opt_var = _PyPegen_expect_token(p, 12), 1)
7573 )
7574 {
7575 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7576 if (token == NULL) {
7577 return NULL;
7578 }
7579 int end_lineno = token->end_lineno;
7580 UNUSED(end_lineno); // Only used by EXTRA macro
7581 int end_col_offset = token->end_col_offset;
7582 UNUSED(end_col_offset); // Only used by EXTRA macro
7583 res = _Py_Tuple ( a , Load , EXTRA );
7584 if (res == NULL && PyErr_Occurred()) {
7585 p->error_indicator = 1;
7586 return NULL;
7587 }
7588 goto done;
7589 }
7590 p->mark = mark;
7591 }
7592 res = NULL;
7593 done:
7594 return res;
7595}
7596
7597// slice: expression? ':' expression? [':' expression?] | expression
7598static expr_ty
7599slice_rule(Parser *p)
7600{
7601 if (p->error_indicator) {
7602 return NULL;
7603 }
7604 expr_ty res = NULL;
7605 int mark = p->mark;
7606 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7607 p->error_indicator = 1;
7608 return NULL;
7609 }
7610 int start_lineno = p->tokens[mark]->lineno;
7611 UNUSED(start_lineno); // Only used by EXTRA macro
7612 int start_col_offset = p->tokens[mark]->col_offset;
7613 UNUSED(start_col_offset); // Only used by EXTRA macro
7614 { // expression? ':' expression? [':' expression?]
7615 void *a;
7616 void *b;
7617 void *c;
7618 void *literal;
7619 if (
7620 (a = expression_rule(p), 1)
7621 &&
7622 (literal = _PyPegen_expect_token(p, 11))
7623 &&
7624 (b = expression_rule(p), 1)
7625 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007626 (c = _tmp_99_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007627 )
7628 {
7629 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7630 if (token == NULL) {
7631 return NULL;
7632 }
7633 int end_lineno = token->end_lineno;
7634 UNUSED(end_lineno); // Only used by EXTRA macro
7635 int end_col_offset = token->end_col_offset;
7636 UNUSED(end_col_offset); // Only used by EXTRA macro
7637 res = _Py_Slice ( a , b , c , EXTRA );
7638 if (res == NULL && PyErr_Occurred()) {
7639 p->error_indicator = 1;
7640 return NULL;
7641 }
7642 goto done;
7643 }
7644 p->mark = mark;
7645 }
7646 { // expression
7647 expr_ty a;
7648 if (
7649 (a = expression_rule(p))
7650 )
7651 {
7652 res = a;
7653 if (res == NULL && PyErr_Occurred()) {
7654 p->error_indicator = 1;
7655 return NULL;
7656 }
7657 goto done;
7658 }
7659 p->mark = mark;
7660 }
7661 res = NULL;
7662 done:
7663 return res;
7664}
7665
7666// atom:
7667// | NAME
7668// | 'True'
7669// | 'False'
7670// | 'None'
7671// | '__new_parser__'
7672// | &STRING strings
7673// | NUMBER
7674// | &'(' (tuple | group | genexp)
7675// | &'[' (list | listcomp)
7676// | &'{' (dict | set | dictcomp | setcomp)
7677// | '...'
7678static expr_ty
7679atom_rule(Parser *p)
7680{
7681 if (p->error_indicator) {
7682 return NULL;
7683 }
7684 expr_ty res = NULL;
7685 int mark = p->mark;
7686 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7687 p->error_indicator = 1;
7688 return NULL;
7689 }
7690 int start_lineno = p->tokens[mark]->lineno;
7691 UNUSED(start_lineno); // Only used by EXTRA macro
7692 int start_col_offset = p->tokens[mark]->col_offset;
7693 UNUSED(start_col_offset); // Only used by EXTRA macro
7694 { // NAME
7695 expr_ty name_var;
7696 if (
7697 (name_var = _PyPegen_name_token(p))
7698 )
7699 {
7700 res = name_var;
7701 goto done;
7702 }
7703 p->mark = mark;
7704 }
7705 { // 'True'
7706 void *keyword;
7707 if (
7708 (keyword = _PyPegen_expect_token(p, 527))
7709 )
7710 {
7711 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7712 if (token == NULL) {
7713 return NULL;
7714 }
7715 int end_lineno = token->end_lineno;
7716 UNUSED(end_lineno); // Only used by EXTRA macro
7717 int end_col_offset = token->end_col_offset;
7718 UNUSED(end_col_offset); // Only used by EXTRA macro
7719 res = _Py_Constant ( Py_True , NULL , EXTRA );
7720 if (res == NULL && PyErr_Occurred()) {
7721 p->error_indicator = 1;
7722 return NULL;
7723 }
7724 goto done;
7725 }
7726 p->mark = mark;
7727 }
7728 { // 'False'
7729 void *keyword;
7730 if (
7731 (keyword = _PyPegen_expect_token(p, 528))
7732 )
7733 {
7734 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7735 if (token == NULL) {
7736 return NULL;
7737 }
7738 int end_lineno = token->end_lineno;
7739 UNUSED(end_lineno); // Only used by EXTRA macro
7740 int end_col_offset = token->end_col_offset;
7741 UNUSED(end_col_offset); // Only used by EXTRA macro
7742 res = _Py_Constant ( Py_False , NULL , EXTRA );
7743 if (res == NULL && PyErr_Occurred()) {
7744 p->error_indicator = 1;
7745 return NULL;
7746 }
7747 goto done;
7748 }
7749 p->mark = mark;
7750 }
7751 { // 'None'
7752 void *keyword;
7753 if (
7754 (keyword = _PyPegen_expect_token(p, 529))
7755 )
7756 {
7757 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7758 if (token == NULL) {
7759 return NULL;
7760 }
7761 int end_lineno = token->end_lineno;
7762 UNUSED(end_lineno); // Only used by EXTRA macro
7763 int end_col_offset = token->end_col_offset;
7764 UNUSED(end_col_offset); // Only used by EXTRA macro
7765 res = _Py_Constant ( Py_None , NULL , EXTRA );
7766 if (res == NULL && PyErr_Occurred()) {
7767 p->error_indicator = 1;
7768 return NULL;
7769 }
7770 goto done;
7771 }
7772 p->mark = mark;
7773 }
7774 { // '__new_parser__'
7775 void *keyword;
7776 if (
7777 (keyword = _PyPegen_expect_token(p, 530))
7778 )
7779 {
7780 res = RAISE_SYNTAX_ERROR ( "You found it!" );
7781 if (res == NULL && PyErr_Occurred()) {
7782 p->error_indicator = 1;
7783 return NULL;
7784 }
7785 goto done;
7786 }
7787 p->mark = mark;
7788 }
7789 { // &STRING strings
7790 expr_ty strings_var;
7791 if (
7792 _PyPegen_lookahead(1, _PyPegen_string_token, p)
7793 &&
7794 (strings_var = strings_rule(p))
7795 )
7796 {
7797 res = strings_var;
7798 goto done;
7799 }
7800 p->mark = mark;
7801 }
7802 { // NUMBER
7803 expr_ty number_var;
7804 if (
7805 (number_var = _PyPegen_number_token(p))
7806 )
7807 {
7808 res = number_var;
7809 goto done;
7810 }
7811 p->mark = mark;
7812 }
7813 { // &'(' (tuple | group | genexp)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007814 void *_tmp_100_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007815 if (
Pablo Galindo2b74c832020-04-27 18:02:07 +01007816 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007817 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007818 (_tmp_100_var = _tmp_100_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007819 )
7820 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007821 res = _tmp_100_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007822 goto done;
7823 }
7824 p->mark = mark;
7825 }
Pablo Galindo2b74c832020-04-27 18:02:07 +01007826 { // &'[' (list | listcomp)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007827 void *_tmp_101_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007828 if (
Pablo Galindo2b74c832020-04-27 18:02:07 +01007829 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007830 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007831 (_tmp_101_var = _tmp_101_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007832 )
7833 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007834 res = _tmp_101_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007835 goto done;
7836 }
7837 p->mark = mark;
7838 }
Pablo Galindo2b74c832020-04-27 18:02:07 +01007839 { // &'{' (dict | set | dictcomp | setcomp)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007840 void *_tmp_102_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +01007841 if (
7842 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25)
7843 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007844 (_tmp_102_var = _tmp_102_rule(p))
Pablo Galindo2b74c832020-04-27 18:02:07 +01007845 )
7846 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007847 res = _tmp_102_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +01007848 goto done;
7849 }
7850 p->mark = mark;
7851 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007852 { // '...'
7853 void *literal;
7854 if (
7855 (literal = _PyPegen_expect_token(p, 52))
7856 )
7857 {
7858 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7859 if (token == NULL) {
7860 return NULL;
7861 }
7862 int end_lineno = token->end_lineno;
7863 UNUSED(end_lineno); // Only used by EXTRA macro
7864 int end_col_offset = token->end_col_offset;
7865 UNUSED(end_col_offset); // Only used by EXTRA macro
7866 res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA );
7867 if (res == NULL && PyErr_Occurred()) {
7868 p->error_indicator = 1;
7869 return NULL;
7870 }
7871 goto done;
7872 }
7873 p->mark = mark;
7874 }
7875 res = NULL;
7876 done:
7877 return res;
7878}
7879
7880// strings: STRING+
7881static expr_ty
7882strings_rule(Parser *p)
7883{
7884 if (p->error_indicator) {
7885 return NULL;
7886 }
7887 expr_ty res = NULL;
7888 if (_PyPegen_is_memoized(p, strings_type, &res))
7889 return res;
7890 int mark = p->mark;
7891 { // STRING+
7892 asdl_seq * a;
7893 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007894 (a = _loop1_103_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007895 )
7896 {
7897 res = _PyPegen_concatenate_strings ( p , a );
7898 if (res == NULL && PyErr_Occurred()) {
7899 p->error_indicator = 1;
7900 return NULL;
7901 }
7902 goto done;
7903 }
7904 p->mark = mark;
7905 }
7906 res = NULL;
7907 done:
7908 _PyPegen_insert_memo(p, mark, strings_type, res);
7909 return res;
7910}
7911
7912// list: '[' star_named_expressions? ']'
7913static expr_ty
7914list_rule(Parser *p)
7915{
7916 if (p->error_indicator) {
7917 return NULL;
7918 }
7919 expr_ty res = NULL;
7920 int mark = p->mark;
7921 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7922 p->error_indicator = 1;
7923 return NULL;
7924 }
7925 int start_lineno = p->tokens[mark]->lineno;
7926 UNUSED(start_lineno); // Only used by EXTRA macro
7927 int start_col_offset = p->tokens[mark]->col_offset;
7928 UNUSED(start_col_offset); // Only used by EXTRA macro
7929 { // '[' star_named_expressions? ']'
7930 void *a;
7931 void *literal;
7932 void *literal_1;
7933 if (
7934 (literal = _PyPegen_expect_token(p, 9))
7935 &&
7936 (a = star_named_expressions_rule(p), 1)
7937 &&
7938 (literal_1 = _PyPegen_expect_token(p, 10))
7939 )
7940 {
7941 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7942 if (token == NULL) {
7943 return NULL;
7944 }
7945 int end_lineno = token->end_lineno;
7946 UNUSED(end_lineno); // Only used by EXTRA macro
7947 int end_col_offset = token->end_col_offset;
7948 UNUSED(end_col_offset); // Only used by EXTRA macro
7949 res = _Py_List ( a , Load , EXTRA );
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 res = NULL;
7959 done:
7960 return res;
7961}
7962
7963// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension
7964static expr_ty
7965listcomp_rule(Parser *p)
7966{
7967 if (p->error_indicator) {
7968 return NULL;
7969 }
7970 expr_ty res = NULL;
7971 int mark = p->mark;
7972 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7973 p->error_indicator = 1;
7974 return NULL;
7975 }
7976 int start_lineno = p->tokens[mark]->lineno;
7977 UNUSED(start_lineno); // Only used by EXTRA macro
7978 int start_col_offset = p->tokens[mark]->col_offset;
7979 UNUSED(start_col_offset); // Only used by EXTRA macro
7980 { // '[' named_expression for_if_clauses ']'
7981 expr_ty a;
7982 asdl_seq* b;
7983 void *literal;
7984 void *literal_1;
7985 if (
7986 (literal = _PyPegen_expect_token(p, 9))
7987 &&
7988 (a = named_expression_rule(p))
7989 &&
7990 (b = for_if_clauses_rule(p))
7991 &&
7992 (literal_1 = _PyPegen_expect_token(p, 10))
7993 )
7994 {
7995 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7996 if (token == NULL) {
7997 return NULL;
7998 }
7999 int end_lineno = token->end_lineno;
8000 UNUSED(end_lineno); // Only used by EXTRA macro
8001 int end_col_offset = token->end_col_offset;
8002 UNUSED(end_col_offset); // Only used by EXTRA macro
8003 res = _Py_ListComp ( a , b , EXTRA );
8004 if (res == NULL && PyErr_Occurred()) {
8005 p->error_indicator = 1;
8006 return NULL;
8007 }
8008 goto done;
8009 }
8010 p->mark = mark;
8011 }
8012 { // invalid_comprehension
8013 void *invalid_comprehension_var;
8014 if (
8015 (invalid_comprehension_var = invalid_comprehension_rule(p))
8016 )
8017 {
8018 res = invalid_comprehension_var;
8019 goto done;
8020 }
8021 p->mark = mark;
8022 }
8023 res = NULL;
8024 done:
8025 return res;
8026}
8027
8028// tuple: '(' [star_named_expression ',' star_named_expressions?] ')'
8029static expr_ty
8030tuple_rule(Parser *p)
8031{
8032 if (p->error_indicator) {
8033 return NULL;
8034 }
8035 expr_ty res = NULL;
8036 int mark = p->mark;
8037 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8038 p->error_indicator = 1;
8039 return NULL;
8040 }
8041 int start_lineno = p->tokens[mark]->lineno;
8042 UNUSED(start_lineno); // Only used by EXTRA macro
8043 int start_col_offset = p->tokens[mark]->col_offset;
8044 UNUSED(start_col_offset); // Only used by EXTRA macro
8045 { // '(' [star_named_expression ',' star_named_expressions?] ')'
8046 void *a;
8047 void *literal;
8048 void *literal_1;
8049 if (
8050 (literal = _PyPegen_expect_token(p, 7))
8051 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008052 (a = _tmp_104_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008053 &&
8054 (literal_1 = _PyPegen_expect_token(p, 8))
8055 )
8056 {
8057 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8058 if (token == NULL) {
8059 return NULL;
8060 }
8061 int end_lineno = token->end_lineno;
8062 UNUSED(end_lineno); // Only used by EXTRA macro
8063 int end_col_offset = token->end_col_offset;
8064 UNUSED(end_col_offset); // Only used by EXTRA macro
8065 res = _Py_Tuple ( a , Load , EXTRA );
8066 if (res == NULL && PyErr_Occurred()) {
8067 p->error_indicator = 1;
8068 return NULL;
8069 }
8070 goto done;
8071 }
8072 p->mark = mark;
8073 }
8074 res = NULL;
8075 done:
8076 return res;
8077}
8078
8079// group: '(' (yield_expr | named_expression) ')'
8080static expr_ty
8081group_rule(Parser *p)
8082{
8083 if (p->error_indicator) {
8084 return NULL;
8085 }
8086 expr_ty res = NULL;
8087 int mark = p->mark;
8088 { // '(' (yield_expr | named_expression) ')'
8089 void *a;
8090 void *literal;
8091 void *literal_1;
8092 if (
8093 (literal = _PyPegen_expect_token(p, 7))
8094 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008095 (a = _tmp_105_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008096 &&
8097 (literal_1 = _PyPegen_expect_token(p, 8))
8098 )
8099 {
8100 res = a;
8101 if (res == NULL && PyErr_Occurred()) {
8102 p->error_indicator = 1;
8103 return NULL;
8104 }
8105 goto done;
8106 }
8107 p->mark = mark;
8108 }
8109 res = NULL;
8110 done:
8111 return res;
8112}
8113
8114// genexp: '(' expression for_if_clauses ')' | invalid_comprehension
8115static expr_ty
8116genexp_rule(Parser *p)
8117{
8118 if (p->error_indicator) {
8119 return NULL;
8120 }
8121 expr_ty res = NULL;
8122 int mark = p->mark;
8123 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8124 p->error_indicator = 1;
8125 return NULL;
8126 }
8127 int start_lineno = p->tokens[mark]->lineno;
8128 UNUSED(start_lineno); // Only used by EXTRA macro
8129 int start_col_offset = p->tokens[mark]->col_offset;
8130 UNUSED(start_col_offset); // Only used by EXTRA macro
8131 { // '(' expression for_if_clauses ')'
8132 expr_ty a;
8133 asdl_seq* b;
8134 void *literal;
8135 void *literal_1;
8136 if (
8137 (literal = _PyPegen_expect_token(p, 7))
8138 &&
8139 (a = expression_rule(p))
8140 &&
8141 (b = for_if_clauses_rule(p))
8142 &&
8143 (literal_1 = _PyPegen_expect_token(p, 8))
8144 )
8145 {
8146 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8147 if (token == NULL) {
8148 return NULL;
8149 }
8150 int end_lineno = token->end_lineno;
8151 UNUSED(end_lineno); // Only used by EXTRA macro
8152 int end_col_offset = token->end_col_offset;
8153 UNUSED(end_col_offset); // Only used by EXTRA macro
8154 res = _Py_GeneratorExp ( a , b , EXTRA );
8155 if (res == NULL && PyErr_Occurred()) {
8156 p->error_indicator = 1;
8157 return NULL;
8158 }
8159 goto done;
8160 }
8161 p->mark = mark;
8162 }
8163 { // invalid_comprehension
8164 void *invalid_comprehension_var;
8165 if (
8166 (invalid_comprehension_var = invalid_comprehension_rule(p))
8167 )
8168 {
8169 res = invalid_comprehension_var;
8170 goto done;
8171 }
8172 p->mark = mark;
8173 }
8174 res = NULL;
8175 done:
8176 return res;
8177}
8178
8179// set: '{' expressions_list '}'
8180static expr_ty
8181set_rule(Parser *p)
8182{
8183 if (p->error_indicator) {
8184 return NULL;
8185 }
8186 expr_ty res = NULL;
8187 int mark = p->mark;
8188 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8189 p->error_indicator = 1;
8190 return NULL;
8191 }
8192 int start_lineno = p->tokens[mark]->lineno;
8193 UNUSED(start_lineno); // Only used by EXTRA macro
8194 int start_col_offset = p->tokens[mark]->col_offset;
8195 UNUSED(start_col_offset); // Only used by EXTRA macro
8196 { // '{' expressions_list '}'
8197 asdl_seq* a;
8198 void *literal;
8199 void *literal_1;
8200 if (
8201 (literal = _PyPegen_expect_token(p, 25))
8202 &&
8203 (a = expressions_list_rule(p))
8204 &&
8205 (literal_1 = _PyPegen_expect_token(p, 26))
8206 )
8207 {
8208 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8209 if (token == NULL) {
8210 return NULL;
8211 }
8212 int end_lineno = token->end_lineno;
8213 UNUSED(end_lineno); // Only used by EXTRA macro
8214 int end_col_offset = token->end_col_offset;
8215 UNUSED(end_col_offset); // Only used by EXTRA macro
8216 res = _Py_Set ( a , EXTRA );
8217 if (res == NULL && PyErr_Occurred()) {
8218 p->error_indicator = 1;
8219 return NULL;
8220 }
8221 goto done;
8222 }
8223 p->mark = mark;
8224 }
8225 res = NULL;
8226 done:
8227 return res;
8228}
8229
8230// setcomp: '{' expression for_if_clauses '}' | invalid_comprehension
8231static expr_ty
8232setcomp_rule(Parser *p)
8233{
8234 if (p->error_indicator) {
8235 return NULL;
8236 }
8237 expr_ty res = NULL;
8238 int mark = p->mark;
8239 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8240 p->error_indicator = 1;
8241 return NULL;
8242 }
8243 int start_lineno = p->tokens[mark]->lineno;
8244 UNUSED(start_lineno); // Only used by EXTRA macro
8245 int start_col_offset = p->tokens[mark]->col_offset;
8246 UNUSED(start_col_offset); // Only used by EXTRA macro
8247 { // '{' expression for_if_clauses '}'
8248 expr_ty a;
8249 asdl_seq* b;
8250 void *literal;
8251 void *literal_1;
8252 if (
8253 (literal = _PyPegen_expect_token(p, 25))
8254 &&
8255 (a = expression_rule(p))
8256 &&
8257 (b = for_if_clauses_rule(p))
8258 &&
8259 (literal_1 = _PyPegen_expect_token(p, 26))
8260 )
8261 {
8262 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8263 if (token == NULL) {
8264 return NULL;
8265 }
8266 int end_lineno = token->end_lineno;
8267 UNUSED(end_lineno); // Only used by EXTRA macro
8268 int end_col_offset = token->end_col_offset;
8269 UNUSED(end_col_offset); // Only used by EXTRA macro
8270 res = _Py_SetComp ( a , b , EXTRA );
8271 if (res == NULL && PyErr_Occurred()) {
8272 p->error_indicator = 1;
8273 return NULL;
8274 }
8275 goto done;
8276 }
8277 p->mark = mark;
8278 }
8279 { // invalid_comprehension
8280 void *invalid_comprehension_var;
8281 if (
8282 (invalid_comprehension_var = invalid_comprehension_rule(p))
8283 )
8284 {
8285 res = invalid_comprehension_var;
8286 goto done;
8287 }
8288 p->mark = mark;
8289 }
8290 res = NULL;
8291 done:
8292 return res;
8293}
8294
8295// dict: '{' kvpairs? '}'
8296static expr_ty
8297dict_rule(Parser *p)
8298{
8299 if (p->error_indicator) {
8300 return NULL;
8301 }
8302 expr_ty res = NULL;
8303 int mark = p->mark;
8304 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8305 p->error_indicator = 1;
8306 return NULL;
8307 }
8308 int start_lineno = p->tokens[mark]->lineno;
8309 UNUSED(start_lineno); // Only used by EXTRA macro
8310 int start_col_offset = p->tokens[mark]->col_offset;
8311 UNUSED(start_col_offset); // Only used by EXTRA macro
8312 { // '{' kvpairs? '}'
8313 void *a;
8314 void *literal;
8315 void *literal_1;
8316 if (
8317 (literal = _PyPegen_expect_token(p, 25))
8318 &&
8319 (a = kvpairs_rule(p), 1)
8320 &&
8321 (literal_1 = _PyPegen_expect_token(p, 26))
8322 )
8323 {
8324 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8325 if (token == NULL) {
8326 return NULL;
8327 }
8328 int end_lineno = token->end_lineno;
8329 UNUSED(end_lineno); // Only used by EXTRA macro
8330 int end_col_offset = token->end_col_offset;
8331 UNUSED(end_col_offset); // Only used by EXTRA macro
8332 res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA );
8333 if (res == NULL && PyErr_Occurred()) {
8334 p->error_indicator = 1;
8335 return NULL;
8336 }
8337 goto done;
8338 }
8339 p->mark = mark;
8340 }
8341 res = NULL;
8342 done:
8343 return res;
8344}
8345
8346// dictcomp: '{' kvpair for_if_clauses '}'
8347static expr_ty
8348dictcomp_rule(Parser *p)
8349{
8350 if (p->error_indicator) {
8351 return NULL;
8352 }
8353 expr_ty res = NULL;
8354 int mark = p->mark;
8355 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8356 p->error_indicator = 1;
8357 return NULL;
8358 }
8359 int start_lineno = p->tokens[mark]->lineno;
8360 UNUSED(start_lineno); // Only used by EXTRA macro
8361 int start_col_offset = p->tokens[mark]->col_offset;
8362 UNUSED(start_col_offset); // Only used by EXTRA macro
8363 { // '{' kvpair for_if_clauses '}'
8364 KeyValuePair* a;
8365 asdl_seq* b;
8366 void *literal;
8367 void *literal_1;
8368 if (
8369 (literal = _PyPegen_expect_token(p, 25))
8370 &&
8371 (a = kvpair_rule(p))
8372 &&
8373 (b = for_if_clauses_rule(p))
8374 &&
8375 (literal_1 = _PyPegen_expect_token(p, 26))
8376 )
8377 {
8378 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8379 if (token == NULL) {
8380 return NULL;
8381 }
8382 int end_lineno = token->end_lineno;
8383 UNUSED(end_lineno); // Only used by EXTRA macro
8384 int end_col_offset = token->end_col_offset;
8385 UNUSED(end_col_offset); // Only used by EXTRA macro
8386 res = _Py_DictComp ( a -> key , a -> value , b , EXTRA );
8387 if (res == NULL && PyErr_Occurred()) {
8388 p->error_indicator = 1;
8389 return NULL;
8390 }
8391 goto done;
8392 }
8393 p->mark = mark;
8394 }
8395 res = NULL;
8396 done:
8397 return res;
8398}
8399
8400// kvpairs: ','.kvpair+ ','?
8401static asdl_seq*
8402kvpairs_rule(Parser *p)
8403{
8404 if (p->error_indicator) {
8405 return NULL;
8406 }
8407 asdl_seq* res = NULL;
8408 int mark = p->mark;
8409 { // ','.kvpair+ ','?
8410 asdl_seq * a;
8411 void *opt_var;
8412 UNUSED(opt_var); // Silence compiler warnings
8413 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008414 (a = _gather_106_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008415 &&
8416 (opt_var = _PyPegen_expect_token(p, 12), 1)
8417 )
8418 {
8419 res = a;
8420 if (res == NULL && PyErr_Occurred()) {
8421 p->error_indicator = 1;
8422 return NULL;
8423 }
8424 goto done;
8425 }
8426 p->mark = mark;
8427 }
8428 res = NULL;
8429 done:
8430 return res;
8431}
8432
8433// kvpair: '**' bitwise_or | expression ':' expression
8434static KeyValuePair*
8435kvpair_rule(Parser *p)
8436{
8437 if (p->error_indicator) {
8438 return NULL;
8439 }
8440 KeyValuePair* res = NULL;
8441 int mark = p->mark;
8442 { // '**' bitwise_or
8443 expr_ty a;
8444 void *literal;
8445 if (
8446 (literal = _PyPegen_expect_token(p, 35))
8447 &&
8448 (a = bitwise_or_rule(p))
8449 )
8450 {
8451 res = _PyPegen_key_value_pair ( p , NULL , a );
8452 if (res == NULL && PyErr_Occurred()) {
8453 p->error_indicator = 1;
8454 return NULL;
8455 }
8456 goto done;
8457 }
8458 p->mark = mark;
8459 }
8460 { // expression ':' expression
8461 expr_ty a;
8462 expr_ty b;
8463 void *literal;
8464 if (
8465 (a = expression_rule(p))
8466 &&
8467 (literal = _PyPegen_expect_token(p, 11))
8468 &&
8469 (b = expression_rule(p))
8470 )
8471 {
8472 res = _PyPegen_key_value_pair ( p , a , b );
8473 if (res == NULL && PyErr_Occurred()) {
8474 p->error_indicator = 1;
8475 return NULL;
8476 }
8477 goto done;
8478 }
8479 p->mark = mark;
8480 }
8481 res = NULL;
8482 done:
8483 return res;
8484}
8485
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008486// for_if_clauses: for_if_clause+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008487static asdl_seq*
8488for_if_clauses_rule(Parser *p)
8489{
8490 if (p->error_indicator) {
8491 return NULL;
8492 }
8493 asdl_seq* res = NULL;
8494 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008495 { // for_if_clause+
8496 asdl_seq * _loop1_108_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008497 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008498 (_loop1_108_var = _loop1_108_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008499 )
8500 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008501 res = _loop1_108_var;
8502 goto done;
8503 }
8504 p->mark = mark;
8505 }
8506 res = NULL;
8507 done:
8508 return res;
8509}
8510
8511// for_if_clause:
8512// | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
8513// | 'for' star_targets 'in' disjunction (('if' disjunction))*
8514static comprehension_ty
8515for_if_clause_rule(Parser *p)
8516{
8517 if (p->error_indicator) {
8518 return NULL;
8519 }
8520 comprehension_ty res = NULL;
8521 int mark = p->mark;
8522 { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
8523 expr_ty a;
8524 void *async_var;
8525 expr_ty b;
8526 asdl_seq * c;
8527 void *keyword;
8528 void *keyword_1;
8529 if (
8530 (async_var = _PyPegen_expect_token(p, ASYNC))
8531 &&
8532 (keyword = _PyPegen_expect_token(p, 517))
8533 &&
8534 (a = star_targets_rule(p))
8535 &&
8536 (keyword_1 = _PyPegen_expect_token(p, 518))
8537 &&
8538 (b = disjunction_rule(p))
8539 &&
8540 (c = _loop0_109_rule(p))
8541 )
8542 {
8543 res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) );
8544 if (res == NULL && PyErr_Occurred()) {
8545 p->error_indicator = 1;
8546 return NULL;
8547 }
8548 goto done;
8549 }
8550 p->mark = mark;
8551 }
8552 { // 'for' star_targets 'in' disjunction (('if' disjunction))*
8553 expr_ty a;
8554 expr_ty b;
8555 asdl_seq * c;
8556 void *keyword;
8557 void *keyword_1;
8558 if (
8559 (keyword = _PyPegen_expect_token(p, 517))
8560 &&
8561 (a = star_targets_rule(p))
8562 &&
8563 (keyword_1 = _PyPegen_expect_token(p, 518))
8564 &&
8565 (b = disjunction_rule(p))
8566 &&
8567 (c = _loop0_110_rule(p))
8568 )
8569 {
8570 res = _Py_comprehension ( a , b , c , 0 , p -> arena );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008571 if (res == NULL && PyErr_Occurred()) {
8572 p->error_indicator = 1;
8573 return NULL;
8574 }
8575 goto done;
8576 }
8577 p->mark = mark;
8578 }
8579 res = NULL;
8580 done:
8581 return res;
8582}
8583
8584// yield_expr: 'yield' 'from' expression | 'yield' star_expressions?
8585static expr_ty
8586yield_expr_rule(Parser *p)
8587{
8588 if (p->error_indicator) {
8589 return NULL;
8590 }
8591 expr_ty res = NULL;
8592 int mark = p->mark;
8593 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8594 p->error_indicator = 1;
8595 return NULL;
8596 }
8597 int start_lineno = p->tokens[mark]->lineno;
8598 UNUSED(start_lineno); // Only used by EXTRA macro
8599 int start_col_offset = p->tokens[mark]->col_offset;
8600 UNUSED(start_col_offset); // Only used by EXTRA macro
8601 { // 'yield' 'from' expression
8602 expr_ty a;
8603 void *keyword;
8604 void *keyword_1;
8605 if (
8606 (keyword = _PyPegen_expect_token(p, 504))
8607 &&
8608 (keyword_1 = _PyPegen_expect_token(p, 514))
8609 &&
8610 (a = expression_rule(p))
8611 )
8612 {
8613 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8614 if (token == NULL) {
8615 return NULL;
8616 }
8617 int end_lineno = token->end_lineno;
8618 UNUSED(end_lineno); // Only used by EXTRA macro
8619 int end_col_offset = token->end_col_offset;
8620 UNUSED(end_col_offset); // Only used by EXTRA macro
8621 res = _Py_YieldFrom ( a , EXTRA );
8622 if (res == NULL && PyErr_Occurred()) {
8623 p->error_indicator = 1;
8624 return NULL;
8625 }
8626 goto done;
8627 }
8628 p->mark = mark;
8629 }
8630 { // 'yield' star_expressions?
8631 void *a;
8632 void *keyword;
8633 if (
8634 (keyword = _PyPegen_expect_token(p, 504))
8635 &&
8636 (a = star_expressions_rule(p), 1)
8637 )
8638 {
8639 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8640 if (token == NULL) {
8641 return NULL;
8642 }
8643 int end_lineno = token->end_lineno;
8644 UNUSED(end_lineno); // Only used by EXTRA macro
8645 int end_col_offset = token->end_col_offset;
8646 UNUSED(end_col_offset); // Only used by EXTRA macro
8647 res = _Py_Yield ( a , EXTRA );
8648 if (res == NULL && PyErr_Occurred()) {
8649 p->error_indicator = 1;
8650 return NULL;
8651 }
8652 goto done;
8653 }
8654 p->mark = mark;
8655 }
8656 res = NULL;
8657 done:
8658 return res;
8659}
8660
8661// arguments: args ','? &')' | incorrect_arguments
8662static expr_ty
8663arguments_rule(Parser *p)
8664{
8665 if (p->error_indicator) {
8666 return NULL;
8667 }
8668 expr_ty res = NULL;
8669 if (_PyPegen_is_memoized(p, arguments_type, &res))
8670 return res;
8671 int mark = p->mark;
8672 { // args ','? &')'
8673 expr_ty a;
8674 void *opt_var;
8675 UNUSED(opt_var); // Silence compiler warnings
8676 if (
8677 (a = args_rule(p))
8678 &&
8679 (opt_var = _PyPegen_expect_token(p, 12), 1)
8680 &&
8681 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
8682 )
8683 {
8684 res = a;
8685 if (res == NULL && PyErr_Occurred()) {
8686 p->error_indicator = 1;
8687 return NULL;
8688 }
8689 goto done;
8690 }
8691 p->mark = mark;
8692 }
8693 { // incorrect_arguments
8694 void *incorrect_arguments_var;
8695 if (
8696 (incorrect_arguments_var = incorrect_arguments_rule(p))
8697 )
8698 {
8699 res = incorrect_arguments_var;
8700 goto done;
8701 }
8702 p->mark = mark;
8703 }
8704 res = NULL;
8705 done:
8706 _PyPegen_insert_memo(p, mark, arguments_type, res);
8707 return res;
8708}
8709
8710// args: starred_expression [',' args] | kwargs | named_expression [',' args]
8711static expr_ty
8712args_rule(Parser *p)
8713{
8714 if (p->error_indicator) {
8715 return NULL;
8716 }
8717 expr_ty res = NULL;
8718 int mark = p->mark;
8719 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8720 p->error_indicator = 1;
8721 return NULL;
8722 }
8723 int start_lineno = p->tokens[mark]->lineno;
8724 UNUSED(start_lineno); // Only used by EXTRA macro
8725 int start_col_offset = p->tokens[mark]->col_offset;
8726 UNUSED(start_col_offset); // Only used by EXTRA macro
8727 { // starred_expression [',' args]
8728 expr_ty a;
8729 void *b;
8730 if (
8731 (a = starred_expression_rule(p))
8732 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008733 (b = _tmp_111_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008734 )
8735 {
8736 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8737 if (token == NULL) {
8738 return NULL;
8739 }
8740 int end_lineno = token->end_lineno;
8741 UNUSED(end_lineno); // Only used by EXTRA macro
8742 int end_col_offset = token->end_col_offset;
8743 UNUSED(end_col_offset); // Only used by EXTRA macro
8744 res = _Py_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 );
8745 if (res == NULL && PyErr_Occurred()) {
8746 p->error_indicator = 1;
8747 return NULL;
8748 }
8749 goto done;
8750 }
8751 p->mark = mark;
8752 }
8753 { // kwargs
8754 asdl_seq* a;
8755 if (
8756 (a = kwargs_rule(p))
8757 )
8758 {
8759 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8760 if (token == NULL) {
8761 return NULL;
8762 }
8763 int end_lineno = token->end_lineno;
8764 UNUSED(end_lineno); // Only used by EXTRA macro
8765 int end_col_offset = token->end_col_offset;
8766 UNUSED(end_col_offset); // Only used by EXTRA macro
8767 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 );
8768 if (res == NULL && PyErr_Occurred()) {
8769 p->error_indicator = 1;
8770 return NULL;
8771 }
8772 goto done;
8773 }
8774 p->mark = mark;
8775 }
8776 { // named_expression [',' args]
8777 expr_ty a;
8778 void *b;
8779 if (
8780 (a = named_expression_rule(p))
8781 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008782 (b = _tmp_112_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008783 )
8784 {
8785 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8786 if (token == NULL) {
8787 return NULL;
8788 }
8789 int end_lineno = token->end_lineno;
8790 UNUSED(end_lineno); // Only used by EXTRA macro
8791 int end_col_offset = token->end_col_offset;
8792 UNUSED(end_col_offset); // Only used by EXTRA macro
8793 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 );
8794 if (res == NULL && PyErr_Occurred()) {
8795 p->error_indicator = 1;
8796 return NULL;
8797 }
8798 goto done;
8799 }
8800 p->mark = mark;
8801 }
8802 res = NULL;
8803 done:
8804 return res;
8805}
8806
8807// kwargs:
8808// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
8809// | ','.kwarg_or_starred+
8810// | ','.kwarg_or_double_starred+
8811static asdl_seq*
8812kwargs_rule(Parser *p)
8813{
8814 if (p->error_indicator) {
8815 return NULL;
8816 }
8817 asdl_seq* res = NULL;
8818 int mark = p->mark;
8819 { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
8820 asdl_seq * a;
8821 asdl_seq * b;
8822 void *literal;
8823 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008824 (a = _gather_113_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008825 &&
8826 (literal = _PyPegen_expect_token(p, 12))
8827 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008828 (b = _gather_115_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008829 )
8830 {
8831 res = _PyPegen_join_sequences ( p , a , b );
8832 if (res == NULL && PyErr_Occurred()) {
8833 p->error_indicator = 1;
8834 return NULL;
8835 }
8836 goto done;
8837 }
8838 p->mark = mark;
8839 }
8840 { // ','.kwarg_or_starred+
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008841 asdl_seq * _gather_117_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008842 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008843 (_gather_117_var = _gather_117_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008844 )
8845 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008846 res = _gather_117_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008847 goto done;
8848 }
8849 p->mark = mark;
8850 }
8851 { // ','.kwarg_or_double_starred+
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008852 asdl_seq * _gather_119_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008853 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008854 (_gather_119_var = _gather_119_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008855 )
8856 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008857 res = _gather_119_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008858 goto done;
8859 }
8860 p->mark = mark;
8861 }
8862 res = NULL;
8863 done:
8864 return res;
8865}
8866
8867// starred_expression: '*' expression
8868static expr_ty
8869starred_expression_rule(Parser *p)
8870{
8871 if (p->error_indicator) {
8872 return NULL;
8873 }
8874 expr_ty res = NULL;
8875 int mark = p->mark;
8876 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8877 p->error_indicator = 1;
8878 return NULL;
8879 }
8880 int start_lineno = p->tokens[mark]->lineno;
8881 UNUSED(start_lineno); // Only used by EXTRA macro
8882 int start_col_offset = p->tokens[mark]->col_offset;
8883 UNUSED(start_col_offset); // Only used by EXTRA macro
8884 { // '*' expression
8885 expr_ty a;
8886 void *literal;
8887 if (
8888 (literal = _PyPegen_expect_token(p, 16))
8889 &&
8890 (a = expression_rule(p))
8891 )
8892 {
8893 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8894 if (token == NULL) {
8895 return NULL;
8896 }
8897 int end_lineno = token->end_lineno;
8898 UNUSED(end_lineno); // Only used by EXTRA macro
8899 int end_col_offset = token->end_col_offset;
8900 UNUSED(end_col_offset); // Only used by EXTRA macro
8901 res = _Py_Starred ( a , Load , EXTRA );
8902 if (res == NULL && PyErr_Occurred()) {
8903 p->error_indicator = 1;
8904 return NULL;
8905 }
8906 goto done;
8907 }
8908 p->mark = mark;
8909 }
8910 res = NULL;
8911 done:
8912 return res;
8913}
8914
8915// kwarg_or_starred: NAME '=' expression | starred_expression
8916static KeywordOrStarred*
8917kwarg_or_starred_rule(Parser *p)
8918{
8919 if (p->error_indicator) {
8920 return NULL;
8921 }
8922 KeywordOrStarred* res = NULL;
8923 int mark = p->mark;
8924 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8925 p->error_indicator = 1;
8926 return NULL;
8927 }
8928 int start_lineno = p->tokens[mark]->lineno;
8929 UNUSED(start_lineno); // Only used by EXTRA macro
8930 int start_col_offset = p->tokens[mark]->col_offset;
8931 UNUSED(start_col_offset); // Only used by EXTRA macro
8932 { // NAME '=' expression
8933 expr_ty a;
8934 expr_ty b;
8935 void *literal;
8936 if (
8937 (a = _PyPegen_name_token(p))
8938 &&
8939 (literal = _PyPegen_expect_token(p, 22))
8940 &&
8941 (b = expression_rule(p))
8942 )
8943 {
8944 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8945 if (token == NULL) {
8946 return NULL;
8947 }
8948 int end_lineno = token->end_lineno;
8949 UNUSED(end_lineno); // Only used by EXTRA macro
8950 int end_col_offset = token->end_col_offset;
8951 UNUSED(end_col_offset); // Only used by EXTRA macro
8952 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
8953 if (res == NULL && PyErr_Occurred()) {
8954 p->error_indicator = 1;
8955 return NULL;
8956 }
8957 goto done;
8958 }
8959 p->mark = mark;
8960 }
8961 { // starred_expression
8962 expr_ty a;
8963 if (
8964 (a = starred_expression_rule(p))
8965 )
8966 {
8967 res = _PyPegen_keyword_or_starred ( p , a , 0 );
8968 if (res == NULL && PyErr_Occurred()) {
8969 p->error_indicator = 1;
8970 return NULL;
8971 }
8972 goto done;
8973 }
8974 p->mark = mark;
8975 }
8976 res = NULL;
8977 done:
8978 return res;
8979}
8980
8981// kwarg_or_double_starred: NAME '=' expression | '**' expression
8982static KeywordOrStarred*
8983kwarg_or_double_starred_rule(Parser *p)
8984{
8985 if (p->error_indicator) {
8986 return NULL;
8987 }
8988 KeywordOrStarred* res = NULL;
8989 int mark = p->mark;
8990 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8991 p->error_indicator = 1;
8992 return NULL;
8993 }
8994 int start_lineno = p->tokens[mark]->lineno;
8995 UNUSED(start_lineno); // Only used by EXTRA macro
8996 int start_col_offset = p->tokens[mark]->col_offset;
8997 UNUSED(start_col_offset); // Only used by EXTRA macro
8998 { // NAME '=' expression
8999 expr_ty a;
9000 expr_ty b;
9001 void *literal;
9002 if (
9003 (a = _PyPegen_name_token(p))
9004 &&
9005 (literal = _PyPegen_expect_token(p, 22))
9006 &&
9007 (b = expression_rule(p))
9008 )
9009 {
9010 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9011 if (token == NULL) {
9012 return NULL;
9013 }
9014 int end_lineno = token->end_lineno;
9015 UNUSED(end_lineno); // Only used by EXTRA macro
9016 int end_col_offset = token->end_col_offset;
9017 UNUSED(end_col_offset); // Only used by EXTRA macro
9018 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
9019 if (res == NULL && PyErr_Occurred()) {
9020 p->error_indicator = 1;
9021 return NULL;
9022 }
9023 goto done;
9024 }
9025 p->mark = mark;
9026 }
9027 { // '**' expression
9028 expr_ty a;
9029 void *literal;
9030 if (
9031 (literal = _PyPegen_expect_token(p, 35))
9032 &&
9033 (a = expression_rule(p))
9034 )
9035 {
9036 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9037 if (token == NULL) {
9038 return NULL;
9039 }
9040 int end_lineno = token->end_lineno;
9041 UNUSED(end_lineno); // Only used by EXTRA macro
9042 int end_col_offset = token->end_col_offset;
9043 UNUSED(end_col_offset); // Only used by EXTRA macro
9044 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 );
9045 if (res == NULL && PyErr_Occurred()) {
9046 p->error_indicator = 1;
9047 return NULL;
9048 }
9049 goto done;
9050 }
9051 p->mark = mark;
9052 }
9053 res = NULL;
9054 done:
9055 return res;
9056}
9057
9058// star_targets: star_target !',' | star_target ((',' star_target))* ','?
9059static expr_ty
9060star_targets_rule(Parser *p)
9061{
9062 if (p->error_indicator) {
9063 return NULL;
9064 }
9065 expr_ty res = NULL;
9066 int mark = p->mark;
9067 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9068 p->error_indicator = 1;
9069 return NULL;
9070 }
9071 int start_lineno = p->tokens[mark]->lineno;
9072 UNUSED(start_lineno); // Only used by EXTRA macro
9073 int start_col_offset = p->tokens[mark]->col_offset;
9074 UNUSED(start_col_offset); // Only used by EXTRA macro
9075 { // star_target !','
9076 expr_ty a;
9077 if (
9078 (a = star_target_rule(p))
9079 &&
9080 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12)
9081 )
9082 {
9083 res = a;
9084 if (res == NULL && PyErr_Occurred()) {
9085 p->error_indicator = 1;
9086 return NULL;
9087 }
9088 goto done;
9089 }
9090 p->mark = mark;
9091 }
9092 { // star_target ((',' star_target))* ','?
9093 expr_ty a;
9094 asdl_seq * b;
9095 void *opt_var;
9096 UNUSED(opt_var); // Silence compiler warnings
9097 if (
9098 (a = star_target_rule(p))
9099 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03009100 (b = _loop0_121_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009101 &&
9102 (opt_var = _PyPegen_expect_token(p, 12), 1)
9103 )
9104 {
9105 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9106 if (token == NULL) {
9107 return NULL;
9108 }
9109 int end_lineno = token->end_lineno;
9110 UNUSED(end_lineno); // Only used by EXTRA macro
9111 int end_col_offset = token->end_col_offset;
9112 UNUSED(end_col_offset); // Only used by EXTRA macro
9113 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA );
9114 if (res == NULL && PyErr_Occurred()) {
9115 p->error_indicator = 1;
9116 return NULL;
9117 }
9118 goto done;
9119 }
9120 p->mark = mark;
9121 }
9122 res = NULL;
9123 done:
9124 return res;
9125}
9126
9127// star_targets_seq: ','.star_target+ ','?
9128static asdl_seq*
9129star_targets_seq_rule(Parser *p)
9130{
9131 if (p->error_indicator) {
9132 return NULL;
9133 }
9134 asdl_seq* res = NULL;
9135 int mark = p->mark;
9136 { // ','.star_target+ ','?
9137 asdl_seq * a;
9138 void *opt_var;
9139 UNUSED(opt_var); // Silence compiler warnings
9140 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03009141 (a = _gather_122_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009142 &&
9143 (opt_var = _PyPegen_expect_token(p, 12), 1)
9144 )
9145 {
9146 res = a;
9147 if (res == NULL && PyErr_Occurred()) {
9148 p->error_indicator = 1;
9149 return NULL;
9150 }
9151 goto done;
9152 }
9153 p->mark = mark;
9154 }
9155 res = NULL;
9156 done:
9157 return res;
9158}
9159
9160// star_target:
9161// | '*' (!'*' star_target)
9162// | t_primary '.' NAME !t_lookahead
9163// | t_primary '[' slices ']' !t_lookahead
9164// | star_atom
9165static expr_ty
9166star_target_rule(Parser *p)
9167{
9168 if (p->error_indicator) {
9169 return NULL;
9170 }
9171 expr_ty res = NULL;
9172 if (_PyPegen_is_memoized(p, star_target_type, &res))
9173 return res;
9174 int mark = p->mark;
9175 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9176 p->error_indicator = 1;
9177 return NULL;
9178 }
9179 int start_lineno = p->tokens[mark]->lineno;
9180 UNUSED(start_lineno); // Only used by EXTRA macro
9181 int start_col_offset = p->tokens[mark]->col_offset;
9182 UNUSED(start_col_offset); // Only used by EXTRA macro
9183 { // '*' (!'*' star_target)
9184 void *a;
9185 void *literal;
9186 if (
9187 (literal = _PyPegen_expect_token(p, 16))
9188 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03009189 (a = _tmp_124_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009190 )
9191 {
9192 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9193 if (token == NULL) {
9194 return NULL;
9195 }
9196 int end_lineno = token->end_lineno;
9197 UNUSED(end_lineno); // Only used by EXTRA macro
9198 int end_col_offset = token->end_col_offset;
9199 UNUSED(end_col_offset); // Only used by EXTRA macro
9200 res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA );
9201 if (res == NULL && PyErr_Occurred()) {
9202 p->error_indicator = 1;
9203 return NULL;
9204 }
9205 goto done;
9206 }
9207 p->mark = mark;
9208 }
9209 { // t_primary '.' NAME !t_lookahead
9210 expr_ty a;
9211 expr_ty b;
9212 void *literal;
9213 if (
9214 (a = t_primary_rule(p))
9215 &&
9216 (literal = _PyPegen_expect_token(p, 23))
9217 &&
9218 (b = _PyPegen_name_token(p))
9219 &&
9220 _PyPegen_lookahead(0, t_lookahead_rule, p)
9221 )
9222 {
9223 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9224 if (token == NULL) {
9225 return NULL;
9226 }
9227 int end_lineno = token->end_lineno;
9228 UNUSED(end_lineno); // Only used by EXTRA macro
9229 int end_col_offset = token->end_col_offset;
9230 UNUSED(end_col_offset); // Only used by EXTRA macro
9231 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
9232 if (res == NULL && PyErr_Occurred()) {
9233 p->error_indicator = 1;
9234 return NULL;
9235 }
9236 goto done;
9237 }
9238 p->mark = mark;
9239 }
9240 { // t_primary '[' slices ']' !t_lookahead
9241 expr_ty a;
9242 expr_ty b;
9243 void *literal;
9244 void *literal_1;
9245 if (
9246 (a = t_primary_rule(p))
9247 &&
9248 (literal = _PyPegen_expect_token(p, 9))
9249 &&
9250 (b = slices_rule(p))
9251 &&
9252 (literal_1 = _PyPegen_expect_token(p, 10))
9253 &&
9254 _PyPegen_lookahead(0, t_lookahead_rule, p)
9255 )
9256 {
9257 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9258 if (token == NULL) {
9259 return NULL;
9260 }
9261 int end_lineno = token->end_lineno;
9262 UNUSED(end_lineno); // Only used by EXTRA macro
9263 int end_col_offset = token->end_col_offset;
9264 UNUSED(end_col_offset); // Only used by EXTRA macro
9265 res = _Py_Subscript ( a , b , Store , EXTRA );
9266 if (res == NULL && PyErr_Occurred()) {
9267 p->error_indicator = 1;
9268 return NULL;
9269 }
9270 goto done;
9271 }
9272 p->mark = mark;
9273 }
9274 { // star_atom
9275 expr_ty star_atom_var;
9276 if (
9277 (star_atom_var = star_atom_rule(p))
9278 )
9279 {
9280 res = star_atom_var;
9281 goto done;
9282 }
9283 p->mark = mark;
9284 }
9285 res = NULL;
9286 done:
9287 _PyPegen_insert_memo(p, mark, star_target_type, res);
9288 return res;
9289}
9290
9291// star_atom:
9292// | NAME
9293// | '(' star_target ')'
9294// | '(' star_targets_seq? ')'
9295// | '[' star_targets_seq? ']'
9296static expr_ty
9297star_atom_rule(Parser *p)
9298{
9299 if (p->error_indicator) {
9300 return NULL;
9301 }
9302 expr_ty res = NULL;
9303 int mark = p->mark;
9304 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9305 p->error_indicator = 1;
9306 return NULL;
9307 }
9308 int start_lineno = p->tokens[mark]->lineno;
9309 UNUSED(start_lineno); // Only used by EXTRA macro
9310 int start_col_offset = p->tokens[mark]->col_offset;
9311 UNUSED(start_col_offset); // Only used by EXTRA macro
9312 { // NAME
9313 expr_ty a;
9314 if (
9315 (a = _PyPegen_name_token(p))
9316 )
9317 {
9318 res = _PyPegen_set_expr_context ( p , a , Store );
9319 if (res == NULL && PyErr_Occurred()) {
9320 p->error_indicator = 1;
9321 return NULL;
9322 }
9323 goto done;
9324 }
9325 p->mark = mark;
9326 }
9327 { // '(' star_target ')'
9328 expr_ty a;
9329 void *literal;
9330 void *literal_1;
9331 if (
9332 (literal = _PyPegen_expect_token(p, 7))
9333 &&
9334 (a = star_target_rule(p))
9335 &&
9336 (literal_1 = _PyPegen_expect_token(p, 8))
9337 )
9338 {
9339 res = _PyPegen_set_expr_context ( p , a , Store );
9340 if (res == NULL && PyErr_Occurred()) {
9341 p->error_indicator = 1;
9342 return NULL;
9343 }
9344 goto done;
9345 }
9346 p->mark = mark;
9347 }
9348 { // '(' star_targets_seq? ')'
9349 void *a;
9350 void *literal;
9351 void *literal_1;
9352 if (
9353 (literal = _PyPegen_expect_token(p, 7))
9354 &&
9355 (a = star_targets_seq_rule(p), 1)
9356 &&
9357 (literal_1 = _PyPegen_expect_token(p, 8))
9358 )
9359 {
9360 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9361 if (token == NULL) {
9362 return NULL;
9363 }
9364 int end_lineno = token->end_lineno;
9365 UNUSED(end_lineno); // Only used by EXTRA macro
9366 int end_col_offset = token->end_col_offset;
9367 UNUSED(end_col_offset); // Only used by EXTRA macro
9368 res = _Py_Tuple ( a , Store , EXTRA );
9369 if (res == NULL && PyErr_Occurred()) {
9370 p->error_indicator = 1;
9371 return NULL;
9372 }
9373 goto done;
9374 }
9375 p->mark = mark;
9376 }
9377 { // '[' star_targets_seq? ']'
9378 void *a;
9379 void *literal;
9380 void *literal_1;
9381 if (
9382 (literal = _PyPegen_expect_token(p, 9))
9383 &&
9384 (a = star_targets_seq_rule(p), 1)
9385 &&
9386 (literal_1 = _PyPegen_expect_token(p, 10))
9387 )
9388 {
9389 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9390 if (token == NULL) {
9391 return NULL;
9392 }
9393 int end_lineno = token->end_lineno;
9394 UNUSED(end_lineno); // Only used by EXTRA macro
9395 int end_col_offset = token->end_col_offset;
9396 UNUSED(end_col_offset); // Only used by EXTRA macro
9397 res = _Py_List ( a , Store , EXTRA );
9398 if (res == NULL && PyErr_Occurred()) {
9399 p->error_indicator = 1;
9400 return NULL;
9401 }
9402 goto done;
9403 }
9404 p->mark = mark;
9405 }
9406 res = NULL;
9407 done:
9408 return res;
9409}
9410
9411// inside_paren_ann_assign_target:
9412// | ann_assign_subscript_attribute_target
9413// | NAME
9414// | '(' inside_paren_ann_assign_target ')'
9415static expr_ty
9416inside_paren_ann_assign_target_rule(Parser *p)
9417{
9418 if (p->error_indicator) {
9419 return NULL;
9420 }
9421 expr_ty res = NULL;
9422 int mark = p->mark;
9423 { // ann_assign_subscript_attribute_target
9424 expr_ty ann_assign_subscript_attribute_target_var;
9425 if (
9426 (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p))
9427 )
9428 {
9429 res = ann_assign_subscript_attribute_target_var;
9430 goto done;
9431 }
9432 p->mark = mark;
9433 }
9434 { // NAME
9435 expr_ty a;
9436 if (
9437 (a = _PyPegen_name_token(p))
9438 )
9439 {
9440 res = _PyPegen_set_expr_context ( p , a , Store );
9441 if (res == NULL && PyErr_Occurred()) {
9442 p->error_indicator = 1;
9443 return NULL;
9444 }
9445 goto done;
9446 }
9447 p->mark = mark;
9448 }
9449 { // '(' inside_paren_ann_assign_target ')'
9450 expr_ty a;
9451 void *literal;
9452 void *literal_1;
9453 if (
9454 (literal = _PyPegen_expect_token(p, 7))
9455 &&
9456 (a = inside_paren_ann_assign_target_rule(p))
9457 &&
9458 (literal_1 = _PyPegen_expect_token(p, 8))
9459 )
9460 {
9461 res = a;
9462 if (res == NULL && PyErr_Occurred()) {
9463 p->error_indicator = 1;
9464 return NULL;
9465 }
9466 goto done;
9467 }
9468 p->mark = mark;
9469 }
9470 res = NULL;
9471 done:
9472 return res;
9473}
9474
9475// ann_assign_subscript_attribute_target:
9476// | t_primary '.' NAME !t_lookahead
9477// | t_primary '[' slices ']' !t_lookahead
9478static expr_ty
9479ann_assign_subscript_attribute_target_rule(Parser *p)
9480{
9481 if (p->error_indicator) {
9482 return NULL;
9483 }
9484 expr_ty res = NULL;
9485 int mark = p->mark;
9486 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9487 p->error_indicator = 1;
9488 return NULL;
9489 }
9490 int start_lineno = p->tokens[mark]->lineno;
9491 UNUSED(start_lineno); // Only used by EXTRA macro
9492 int start_col_offset = p->tokens[mark]->col_offset;
9493 UNUSED(start_col_offset); // Only used by EXTRA macro
9494 { // t_primary '.' NAME !t_lookahead
9495 expr_ty a;
9496 expr_ty b;
9497 void *literal;
9498 if (
9499 (a = t_primary_rule(p))
9500 &&
9501 (literal = _PyPegen_expect_token(p, 23))
9502 &&
9503 (b = _PyPegen_name_token(p))
9504 &&
9505 _PyPegen_lookahead(0, t_lookahead_rule, p)
9506 )
9507 {
9508 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9509 if (token == NULL) {
9510 return NULL;
9511 }
9512 int end_lineno = token->end_lineno;
9513 UNUSED(end_lineno); // Only used by EXTRA macro
9514 int end_col_offset = token->end_col_offset;
9515 UNUSED(end_col_offset); // Only used by EXTRA macro
9516 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
9517 if (res == NULL && PyErr_Occurred()) {
9518 p->error_indicator = 1;
9519 return NULL;
9520 }
9521 goto done;
9522 }
9523 p->mark = mark;
9524 }
9525 { // t_primary '[' slices ']' !t_lookahead
9526 expr_ty a;
9527 expr_ty b;
9528 void *literal;
9529 void *literal_1;
9530 if (
9531 (a = t_primary_rule(p))
9532 &&
9533 (literal = _PyPegen_expect_token(p, 9))
9534 &&
9535 (b = slices_rule(p))
9536 &&
9537 (literal_1 = _PyPegen_expect_token(p, 10))
9538 &&
9539 _PyPegen_lookahead(0, t_lookahead_rule, p)
9540 )
9541 {
9542 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9543 if (token == NULL) {
9544 return NULL;
9545 }
9546 int end_lineno = token->end_lineno;
9547 UNUSED(end_lineno); // Only used by EXTRA macro
9548 int end_col_offset = token->end_col_offset;
9549 UNUSED(end_col_offset); // Only used by EXTRA macro
9550 res = _Py_Subscript ( a , b , Store , EXTRA );
9551 if (res == NULL && PyErr_Occurred()) {
9552 p->error_indicator = 1;
9553 return NULL;
9554 }
9555 goto done;
9556 }
9557 p->mark = mark;
9558 }
9559 res = NULL;
9560 done:
9561 return res;
9562}
9563
9564// del_targets: ','.del_target+ ','?
9565static asdl_seq*
9566del_targets_rule(Parser *p)
9567{
9568 if (p->error_indicator) {
9569 return NULL;
9570 }
9571 asdl_seq* res = NULL;
9572 int mark = p->mark;
9573 { // ','.del_target+ ','?
9574 asdl_seq * a;
9575 void *opt_var;
9576 UNUSED(opt_var); // Silence compiler warnings
9577 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03009578 (a = _gather_125_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009579 &&
9580 (opt_var = _PyPegen_expect_token(p, 12), 1)
9581 )
9582 {
9583 res = a;
9584 if (res == NULL && PyErr_Occurred()) {
9585 p->error_indicator = 1;
9586 return NULL;
9587 }
9588 goto done;
9589 }
9590 p->mark = mark;
9591 }
9592 res = NULL;
9593 done:
9594 return res;
9595}
9596
9597// del_target:
9598// | t_primary '.' NAME !t_lookahead
9599// | t_primary '[' slices ']' !t_lookahead
9600// | del_t_atom
9601static expr_ty
9602del_target_rule(Parser *p)
9603{
9604 if (p->error_indicator) {
9605 return NULL;
9606 }
9607 expr_ty res = NULL;
9608 if (_PyPegen_is_memoized(p, del_target_type, &res))
9609 return res;
9610 int mark = p->mark;
9611 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9612 p->error_indicator = 1;
9613 return NULL;
9614 }
9615 int start_lineno = p->tokens[mark]->lineno;
9616 UNUSED(start_lineno); // Only used by EXTRA macro
9617 int start_col_offset = p->tokens[mark]->col_offset;
9618 UNUSED(start_col_offset); // Only used by EXTRA macro
9619 { // t_primary '.' NAME !t_lookahead
9620 expr_ty a;
9621 expr_ty b;
9622 void *literal;
9623 if (
9624 (a = t_primary_rule(p))
9625 &&
9626 (literal = _PyPegen_expect_token(p, 23))
9627 &&
9628 (b = _PyPegen_name_token(p))
9629 &&
9630 _PyPegen_lookahead(0, t_lookahead_rule, p)
9631 )
9632 {
9633 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9634 if (token == NULL) {
9635 return NULL;
9636 }
9637 int end_lineno = token->end_lineno;
9638 UNUSED(end_lineno); // Only used by EXTRA macro
9639 int end_col_offset = token->end_col_offset;
9640 UNUSED(end_col_offset); // Only used by EXTRA macro
9641 res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA );
9642 if (res == NULL && PyErr_Occurred()) {
9643 p->error_indicator = 1;
9644 return NULL;
9645 }
9646 goto done;
9647 }
9648 p->mark = mark;
9649 }
9650 { // t_primary '[' slices ']' !t_lookahead
9651 expr_ty a;
9652 expr_ty b;
9653 void *literal;
9654 void *literal_1;
9655 if (
9656 (a = t_primary_rule(p))
9657 &&
9658 (literal = _PyPegen_expect_token(p, 9))
9659 &&
9660 (b = slices_rule(p))
9661 &&
9662 (literal_1 = _PyPegen_expect_token(p, 10))
9663 &&
9664 _PyPegen_lookahead(0, t_lookahead_rule, p)
9665 )
9666 {
9667 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9668 if (token == NULL) {
9669 return NULL;
9670 }
9671 int end_lineno = token->end_lineno;
9672 UNUSED(end_lineno); // Only used by EXTRA macro
9673 int end_col_offset = token->end_col_offset;
9674 UNUSED(end_col_offset); // Only used by EXTRA macro
9675 res = _Py_Subscript ( a , b , Del , EXTRA );
9676 if (res == NULL && PyErr_Occurred()) {
9677 p->error_indicator = 1;
9678 return NULL;
9679 }
9680 goto done;
9681 }
9682 p->mark = mark;
9683 }
9684 { // del_t_atom
9685 expr_ty del_t_atom_var;
9686 if (
9687 (del_t_atom_var = del_t_atom_rule(p))
9688 )
9689 {
9690 res = del_t_atom_var;
9691 goto done;
9692 }
9693 p->mark = mark;
9694 }
9695 res = NULL;
9696 done:
9697 _PyPegen_insert_memo(p, mark, del_target_type, res);
9698 return res;
9699}
9700
9701// del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']'
9702static expr_ty
9703del_t_atom_rule(Parser *p)
9704{
9705 if (p->error_indicator) {
9706 return NULL;
9707 }
9708 expr_ty res = NULL;
9709 int mark = p->mark;
9710 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9711 p->error_indicator = 1;
9712 return NULL;
9713 }
9714 int start_lineno = p->tokens[mark]->lineno;
9715 UNUSED(start_lineno); // Only used by EXTRA macro
9716 int start_col_offset = p->tokens[mark]->col_offset;
9717 UNUSED(start_col_offset); // Only used by EXTRA macro
9718 { // NAME
9719 expr_ty a;
9720 if (
9721 (a = _PyPegen_name_token(p))
9722 )
9723 {
9724 res = _PyPegen_set_expr_context ( p , a , Del );
9725 if (res == NULL && PyErr_Occurred()) {
9726 p->error_indicator = 1;
9727 return NULL;
9728 }
9729 goto done;
9730 }
9731 p->mark = mark;
9732 }
9733 { // '(' del_target ')'
9734 expr_ty a;
9735 void *literal;
9736 void *literal_1;
9737 if (
9738 (literal = _PyPegen_expect_token(p, 7))
9739 &&
9740 (a = del_target_rule(p))
9741 &&
9742 (literal_1 = _PyPegen_expect_token(p, 8))
9743 )
9744 {
9745 res = _PyPegen_set_expr_context ( p , a , Del );
9746 if (res == NULL && PyErr_Occurred()) {
9747 p->error_indicator = 1;
9748 return NULL;
9749 }
9750 goto done;
9751 }
9752 p->mark = mark;
9753 }
9754 { // '(' del_targets? ')'
9755 void *a;
9756 void *literal;
9757 void *literal_1;
9758 if (
9759 (literal = _PyPegen_expect_token(p, 7))
9760 &&
9761 (a = del_targets_rule(p), 1)
9762 &&
9763 (literal_1 = _PyPegen_expect_token(p, 8))
9764 )
9765 {
9766 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9767 if (token == NULL) {
9768 return NULL;
9769 }
9770 int end_lineno = token->end_lineno;
9771 UNUSED(end_lineno); // Only used by EXTRA macro
9772 int end_col_offset = token->end_col_offset;
9773 UNUSED(end_col_offset); // Only used by EXTRA macro
9774 res = _Py_Tuple ( a , Del , EXTRA );
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 { // '[' del_targets? ']'
9784 void *a;
9785 void *literal;
9786 void *literal_1;
9787 if (
9788 (literal = _PyPegen_expect_token(p, 9))
9789 &&
9790 (a = del_targets_rule(p), 1)
9791 &&
9792 (literal_1 = _PyPegen_expect_token(p, 10))
9793 )
9794 {
9795 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9796 if (token == NULL) {
9797 return NULL;
9798 }
9799 int end_lineno = token->end_lineno;
9800 UNUSED(end_lineno); // Only used by EXTRA macro
9801 int end_col_offset = token->end_col_offset;
9802 UNUSED(end_col_offset); // Only used by EXTRA macro
9803 res = _Py_List ( a , Del , EXTRA );
9804 if (res == NULL && PyErr_Occurred()) {
9805 p->error_indicator = 1;
9806 return NULL;
9807 }
9808 goto done;
9809 }
9810 p->mark = mark;
9811 }
9812 res = NULL;
9813 done:
9814 return res;
9815}
9816
9817// targets: ','.target+ ','?
9818static asdl_seq*
9819targets_rule(Parser *p)
9820{
9821 if (p->error_indicator) {
9822 return NULL;
9823 }
9824 asdl_seq* res = NULL;
9825 int mark = p->mark;
9826 { // ','.target+ ','?
9827 asdl_seq * a;
9828 void *opt_var;
9829 UNUSED(opt_var); // Silence compiler warnings
9830 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03009831 (a = _gather_127_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009832 &&
9833 (opt_var = _PyPegen_expect_token(p, 12), 1)
9834 )
9835 {
9836 res = a;
9837 if (res == NULL && PyErr_Occurred()) {
9838 p->error_indicator = 1;
9839 return NULL;
9840 }
9841 goto done;
9842 }
9843 p->mark = mark;
9844 }
9845 res = NULL;
9846 done:
9847 return res;
9848}
9849
9850// target:
9851// | t_primary '.' NAME !t_lookahead
9852// | t_primary '[' slices ']' !t_lookahead
9853// | t_atom
9854static expr_ty
9855target_rule(Parser *p)
9856{
9857 if (p->error_indicator) {
9858 return NULL;
9859 }
9860 expr_ty res = NULL;
9861 if (_PyPegen_is_memoized(p, target_type, &res))
9862 return res;
9863 int mark = p->mark;
9864 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9865 p->error_indicator = 1;
9866 return NULL;
9867 }
9868 int start_lineno = p->tokens[mark]->lineno;
9869 UNUSED(start_lineno); // Only used by EXTRA macro
9870 int start_col_offset = p->tokens[mark]->col_offset;
9871 UNUSED(start_col_offset); // Only used by EXTRA macro
9872 { // t_primary '.' NAME !t_lookahead
9873 expr_ty a;
9874 expr_ty b;
9875 void *literal;
9876 if (
9877 (a = t_primary_rule(p))
9878 &&
9879 (literal = _PyPegen_expect_token(p, 23))
9880 &&
9881 (b = _PyPegen_name_token(p))
9882 &&
9883 _PyPegen_lookahead(0, t_lookahead_rule, p)
9884 )
9885 {
9886 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9887 if (token == NULL) {
9888 return NULL;
9889 }
9890 int end_lineno = token->end_lineno;
9891 UNUSED(end_lineno); // Only used by EXTRA macro
9892 int end_col_offset = token->end_col_offset;
9893 UNUSED(end_col_offset); // Only used by EXTRA macro
9894 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
9895 if (res == NULL && PyErr_Occurred()) {
9896 p->error_indicator = 1;
9897 return NULL;
9898 }
9899 goto done;
9900 }
9901 p->mark = mark;
9902 }
9903 { // t_primary '[' slices ']' !t_lookahead
9904 expr_ty a;
9905 expr_ty b;
9906 void *literal;
9907 void *literal_1;
9908 if (
9909 (a = t_primary_rule(p))
9910 &&
9911 (literal = _PyPegen_expect_token(p, 9))
9912 &&
9913 (b = slices_rule(p))
9914 &&
9915 (literal_1 = _PyPegen_expect_token(p, 10))
9916 &&
9917 _PyPegen_lookahead(0, t_lookahead_rule, p)
9918 )
9919 {
9920 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9921 if (token == NULL) {
9922 return NULL;
9923 }
9924 int end_lineno = token->end_lineno;
9925 UNUSED(end_lineno); // Only used by EXTRA macro
9926 int end_col_offset = token->end_col_offset;
9927 UNUSED(end_col_offset); // Only used by EXTRA macro
9928 res = _Py_Subscript ( a , b , Store , EXTRA );
9929 if (res == NULL && PyErr_Occurred()) {
9930 p->error_indicator = 1;
9931 return NULL;
9932 }
9933 goto done;
9934 }
9935 p->mark = mark;
9936 }
9937 { // t_atom
9938 expr_ty t_atom_var;
9939 if (
9940 (t_atom_var = t_atom_rule(p))
9941 )
9942 {
9943 res = t_atom_var;
9944 goto done;
9945 }
9946 p->mark = mark;
9947 }
9948 res = NULL;
9949 done:
9950 _PyPegen_insert_memo(p, mark, target_type, res);
9951 return res;
9952}
9953
9954// Left-recursive
9955// t_primary:
9956// | t_primary '.' NAME &t_lookahead
9957// | t_primary '[' slices ']' &t_lookahead
9958// | t_primary genexp &t_lookahead
9959// | t_primary '(' arguments? ')' &t_lookahead
9960// | atom &t_lookahead
9961static expr_ty t_primary_raw(Parser *);
9962static expr_ty
9963t_primary_rule(Parser *p)
9964{
9965 expr_ty res = NULL;
9966 if (_PyPegen_is_memoized(p, t_primary_type, &res))
9967 return res;
9968 int mark = p->mark;
9969 int resmark = p->mark;
9970 while (1) {
9971 int tmpvar_8 = _PyPegen_update_memo(p, mark, t_primary_type, res);
9972 if (tmpvar_8) {
9973 return res;
9974 }
9975 p->mark = mark;
9976 void *raw = t_primary_raw(p);
9977 if (raw == NULL || p->mark <= resmark)
9978 break;
9979 resmark = p->mark;
9980 res = raw;
9981 }
9982 p->mark = resmark;
9983 return res;
9984}
9985static expr_ty
9986t_primary_raw(Parser *p)
9987{
9988 if (p->error_indicator) {
9989 return NULL;
9990 }
9991 expr_ty res = NULL;
9992 int mark = p->mark;
9993 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9994 p->error_indicator = 1;
9995 return NULL;
9996 }
9997 int start_lineno = p->tokens[mark]->lineno;
9998 UNUSED(start_lineno); // Only used by EXTRA macro
9999 int start_col_offset = p->tokens[mark]->col_offset;
10000 UNUSED(start_col_offset); // Only used by EXTRA macro
10001 { // t_primary '.' NAME &t_lookahead
10002 expr_ty a;
10003 expr_ty b;
10004 void *literal;
10005 if (
10006 (a = t_primary_rule(p))
10007 &&
10008 (literal = _PyPegen_expect_token(p, 23))
10009 &&
10010 (b = _PyPegen_name_token(p))
10011 &&
10012 _PyPegen_lookahead(1, t_lookahead_rule, p)
10013 )
10014 {
10015 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10016 if (token == NULL) {
10017 return NULL;
10018 }
10019 int end_lineno = token->end_lineno;
10020 UNUSED(end_lineno); // Only used by EXTRA macro
10021 int end_col_offset = token->end_col_offset;
10022 UNUSED(end_col_offset); // Only used by EXTRA macro
10023 res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
10024 if (res == NULL && PyErr_Occurred()) {
10025 p->error_indicator = 1;
10026 return NULL;
10027 }
10028 goto done;
10029 }
10030 p->mark = mark;
10031 }
10032 { // t_primary '[' slices ']' &t_lookahead
10033 expr_ty a;
10034 expr_ty b;
10035 void *literal;
10036 void *literal_1;
10037 if (
10038 (a = t_primary_rule(p))
10039 &&
10040 (literal = _PyPegen_expect_token(p, 9))
10041 &&
10042 (b = slices_rule(p))
10043 &&
10044 (literal_1 = _PyPegen_expect_token(p, 10))
10045 &&
10046 _PyPegen_lookahead(1, t_lookahead_rule, p)
10047 )
10048 {
10049 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10050 if (token == NULL) {
10051 return NULL;
10052 }
10053 int end_lineno = token->end_lineno;
10054 UNUSED(end_lineno); // Only used by EXTRA macro
10055 int end_col_offset = token->end_col_offset;
10056 UNUSED(end_col_offset); // Only used by EXTRA macro
10057 res = _Py_Subscript ( a , b , Load , EXTRA );
10058 if (res == NULL && PyErr_Occurred()) {
10059 p->error_indicator = 1;
10060 return NULL;
10061 }
10062 goto done;
10063 }
10064 p->mark = mark;
10065 }
10066 { // t_primary genexp &t_lookahead
10067 expr_ty a;
10068 expr_ty b;
10069 if (
10070 (a = t_primary_rule(p))
10071 &&
10072 (b = genexp_rule(p))
10073 &&
10074 _PyPegen_lookahead(1, 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_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , 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 '(' arguments? ')' &t_lookahead
10095 expr_ty a;
10096 void *b;
10097 void *literal;
10098 void *literal_1;
10099 if (
10100 (a = t_primary_rule(p))
10101 &&
10102 (literal = _PyPegen_expect_token(p, 7))
10103 &&
10104 (b = arguments_rule(p), 1)
10105 &&
10106 (literal_1 = _PyPegen_expect_token(p, 8))
10107 &&
10108 _PyPegen_lookahead(1, 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_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , 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 { // atom &t_lookahead
10129 expr_ty a;
10130 if (
10131 (a = atom_rule(p))
10132 &&
10133 _PyPegen_lookahead(1, t_lookahead_rule, p)
10134 )
10135 {
10136 res = a;
10137 if (res == NULL && PyErr_Occurred()) {
10138 p->error_indicator = 1;
10139 return NULL;
10140 }
10141 goto done;
10142 }
10143 p->mark = mark;
10144 }
10145 res = NULL;
10146 done:
10147 return res;
10148}
10149
10150// t_lookahead: '(' | '[' | '.'
10151static void *
10152t_lookahead_rule(Parser *p)
10153{
10154 if (p->error_indicator) {
10155 return NULL;
10156 }
10157 void * res = NULL;
10158 int mark = p->mark;
10159 { // '('
10160 void *literal;
10161 if (
10162 (literal = _PyPegen_expect_token(p, 7))
10163 )
10164 {
10165 res = literal;
10166 goto done;
10167 }
10168 p->mark = mark;
10169 }
10170 { // '['
10171 void *literal;
10172 if (
10173 (literal = _PyPegen_expect_token(p, 9))
10174 )
10175 {
10176 res = literal;
10177 goto done;
10178 }
10179 p->mark = mark;
10180 }
10181 { // '.'
10182 void *literal;
10183 if (
10184 (literal = _PyPegen_expect_token(p, 23))
10185 )
10186 {
10187 res = literal;
10188 goto done;
10189 }
10190 p->mark = mark;
10191 }
10192 res = NULL;
10193 done:
10194 return res;
10195}
10196
10197// t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']'
10198static expr_ty
10199t_atom_rule(Parser *p)
10200{
10201 if (p->error_indicator) {
10202 return NULL;
10203 }
10204 expr_ty res = NULL;
10205 int mark = p->mark;
10206 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
10207 p->error_indicator = 1;
10208 return NULL;
10209 }
10210 int start_lineno = p->tokens[mark]->lineno;
10211 UNUSED(start_lineno); // Only used by EXTRA macro
10212 int start_col_offset = p->tokens[mark]->col_offset;
10213 UNUSED(start_col_offset); // Only used by EXTRA macro
10214 { // NAME
10215 expr_ty a;
10216 if (
10217 (a = _PyPegen_name_token(p))
10218 )
10219 {
10220 res = _PyPegen_set_expr_context ( p , a , Store );
10221 if (res == NULL && PyErr_Occurred()) {
10222 p->error_indicator = 1;
10223 return NULL;
10224 }
10225 goto done;
10226 }
10227 p->mark = mark;
10228 }
10229 { // '(' target ')'
10230 expr_ty a;
10231 void *literal;
10232 void *literal_1;
10233 if (
10234 (literal = _PyPegen_expect_token(p, 7))
10235 &&
10236 (a = target_rule(p))
10237 &&
10238 (literal_1 = _PyPegen_expect_token(p, 8))
10239 )
10240 {
10241 res = _PyPegen_set_expr_context ( p , a , Store );
10242 if (res == NULL && PyErr_Occurred()) {
10243 p->error_indicator = 1;
10244 return NULL;
10245 }
10246 goto done;
10247 }
10248 p->mark = mark;
10249 }
10250 { // '(' targets? ')'
10251 void *b;
10252 void *literal;
10253 void *literal_1;
10254 if (
10255 (literal = _PyPegen_expect_token(p, 7))
10256 &&
10257 (b = targets_rule(p), 1)
10258 &&
10259 (literal_1 = _PyPegen_expect_token(p, 8))
10260 )
10261 {
10262 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10263 if (token == NULL) {
10264 return NULL;
10265 }
10266 int end_lineno = token->end_lineno;
10267 UNUSED(end_lineno); // Only used by EXTRA macro
10268 int end_col_offset = token->end_col_offset;
10269 UNUSED(end_col_offset); // Only used by EXTRA macro
10270 res = _Py_Tuple ( b , Store , EXTRA );
10271 if (res == NULL && PyErr_Occurred()) {
10272 p->error_indicator = 1;
10273 return NULL;
10274 }
10275 goto done;
10276 }
10277 p->mark = mark;
10278 }
10279 { // '[' targets? ']'
10280 void *b;
10281 void *literal;
10282 void *literal_1;
10283 if (
10284 (literal = _PyPegen_expect_token(p, 9))
10285 &&
10286 (b = targets_rule(p), 1)
10287 &&
10288 (literal_1 = _PyPegen_expect_token(p, 10))
10289 )
10290 {
10291 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10292 if (token == NULL) {
10293 return NULL;
10294 }
10295 int end_lineno = token->end_lineno;
10296 UNUSED(end_lineno); // Only used by EXTRA macro
10297 int end_col_offset = token->end_col_offset;
10298 UNUSED(end_col_offset); // Only used by EXTRA macro
10299 res = _Py_List ( b , Store , EXTRA );
10300 if (res == NULL && PyErr_Occurred()) {
10301 p->error_indicator = 1;
10302 return NULL;
10303 }
10304 goto done;
10305 }
10306 p->mark = mark;
10307 }
10308 res = NULL;
10309 done:
10310 return res;
10311}
10312
10313// incorrect_arguments:
10314// | args ',' '*'
10315// | expression for_if_clauses ',' [args | expression for_if_clauses]
10316// | args ',' args
10317static void *
10318incorrect_arguments_rule(Parser *p)
10319{
10320 if (p->error_indicator) {
10321 return NULL;
10322 }
10323 void * res = NULL;
10324 int mark = p->mark;
10325 { // args ',' '*'
10326 expr_ty args_var;
10327 void *literal;
10328 void *literal_1;
10329 if (
10330 (args_var = args_rule(p))
10331 &&
10332 (literal = _PyPegen_expect_token(p, 12))
10333 &&
10334 (literal_1 = _PyPegen_expect_token(p, 16))
10335 )
10336 {
10337 res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" );
10338 if (res == NULL && PyErr_Occurred()) {
10339 p->error_indicator = 1;
10340 return NULL;
10341 }
10342 goto done;
10343 }
10344 p->mark = mark;
10345 }
10346 { // expression for_if_clauses ',' [args | expression for_if_clauses]
10347 expr_ty expression_var;
10348 asdl_seq* for_if_clauses_var;
10349 void *literal;
10350 void *opt_var;
10351 UNUSED(opt_var); // Silence compiler warnings
10352 if (
10353 (expression_var = expression_rule(p))
10354 &&
10355 (for_if_clauses_var = for_if_clauses_rule(p))
10356 &&
10357 (literal = _PyPegen_expect_token(p, 12))
10358 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010359 (opt_var = _tmp_129_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010360 )
10361 {
10362 res = RAISE_SYNTAX_ERROR ( "Generator expression must be parenthesized" );
10363 if (res == NULL && PyErr_Occurred()) {
10364 p->error_indicator = 1;
10365 return NULL;
10366 }
10367 goto done;
10368 }
10369 p->mark = mark;
10370 }
10371 { // args ',' args
10372 expr_ty a;
10373 expr_ty args_var;
10374 void *literal;
10375 if (
10376 (a = args_rule(p))
10377 &&
10378 (literal = _PyPegen_expect_token(p, 12))
10379 &&
10380 (args_var = args_rule(p))
10381 )
10382 {
10383 res = _PyPegen_arguments_parsing_error ( p , a );
10384 if (res == NULL && PyErr_Occurred()) {
10385 p->error_indicator = 1;
10386 return NULL;
10387 }
10388 goto done;
10389 }
10390 p->mark = mark;
10391 }
10392 res = NULL;
10393 done:
10394 return res;
10395}
10396
10397// invalid_named_expression: expression ':=' expression
10398static void *
10399invalid_named_expression_rule(Parser *p)
10400{
10401 if (p->error_indicator) {
10402 return NULL;
10403 }
10404 void * res = NULL;
10405 int mark = p->mark;
10406 { // expression ':=' expression
10407 expr_ty a;
10408 expr_ty expression_var;
10409 void *literal;
10410 if (
10411 (a = expression_rule(p))
10412 &&
10413 (literal = _PyPegen_expect_token(p, 53))
10414 &&
10415 (expression_var = expression_rule(p))
10416 )
10417 {
10418 res = RAISE_SYNTAX_ERROR ( "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) );
10419 if (res == NULL && PyErr_Occurred()) {
10420 p->error_indicator = 1;
10421 return NULL;
10422 }
10423 goto done;
10424 }
10425 p->mark = mark;
10426 }
10427 res = NULL;
10428 done:
10429 return res;
10430}
10431
10432// invalid_assignment:
10433// | list ':'
10434// | tuple ':'
10435// | expression ':' expression ['=' annotated_rhs]
10436// | expression ('=' | augassign) (yield_expr | star_expressions)
10437static void *
10438invalid_assignment_rule(Parser *p)
10439{
10440 if (p->error_indicator) {
10441 return NULL;
10442 }
10443 void * res = NULL;
10444 int mark = p->mark;
10445 { // list ':'
10446 expr_ty list_var;
10447 void *literal;
10448 if (
10449 (list_var = list_rule(p))
10450 &&
10451 (literal = _PyPegen_expect_token(p, 11))
10452 )
10453 {
10454 res = RAISE_SYNTAX_ERROR ( "only single target (not list) can be annotated" );
10455 if (res == NULL && PyErr_Occurred()) {
10456 p->error_indicator = 1;
10457 return NULL;
10458 }
10459 goto done;
10460 }
10461 p->mark = mark;
10462 }
10463 { // tuple ':'
10464 void *literal;
10465 expr_ty tuple_var;
10466 if (
10467 (tuple_var = tuple_rule(p))
10468 &&
10469 (literal = _PyPegen_expect_token(p, 11))
10470 )
10471 {
10472 res = RAISE_SYNTAX_ERROR ( "only single target (not tuple) can be annotated" );
10473 if (res == NULL && PyErr_Occurred()) {
10474 p->error_indicator = 1;
10475 return NULL;
10476 }
10477 goto done;
10478 }
10479 p->mark = mark;
10480 }
10481 { // expression ':' expression ['=' annotated_rhs]
10482 expr_ty expression_var;
10483 expr_ty expression_var_1;
10484 void *literal;
10485 void *opt_var;
10486 UNUSED(opt_var); // Silence compiler warnings
10487 if (
10488 (expression_var = expression_rule(p))
10489 &&
10490 (literal = _PyPegen_expect_token(p, 11))
10491 &&
10492 (expression_var_1 = expression_rule(p))
10493 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010494 (opt_var = _tmp_130_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010495 )
10496 {
10497 res = RAISE_SYNTAX_ERROR ( "illegal target for annotation" );
10498 if (res == NULL && PyErr_Occurred()) {
10499 p->error_indicator = 1;
10500 return NULL;
10501 }
10502 goto done;
10503 }
10504 p->mark = mark;
10505 }
10506 { // expression ('=' | augassign) (yield_expr | star_expressions)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010507 void *_tmp_131_var;
10508 void *_tmp_132_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010509 expr_ty a;
10510 if (
10511 (a = expression_rule(p))
10512 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010513 (_tmp_131_var = _tmp_131_rule(p))
Pablo Galindo2b74c832020-04-27 18:02:07 +010010514 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010515 (_tmp_132_var = _tmp_132_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010516 )
10517 {
10518 res = RAISE_SYNTAX_ERROR ( "cannot assign to %s" , _PyPegen_get_expr_name ( a ) );
10519 if (res == NULL && PyErr_Occurred()) {
10520 p->error_indicator = 1;
10521 return NULL;
10522 }
10523 goto done;
10524 }
10525 p->mark = mark;
10526 }
10527 res = NULL;
10528 done:
10529 return res;
10530}
10531
10532// invalid_block: NEWLINE !INDENT
10533static void *
10534invalid_block_rule(Parser *p)
10535{
10536 if (p->error_indicator) {
10537 return NULL;
10538 }
10539 void * res = NULL;
10540 int mark = p->mark;
10541 { // NEWLINE !INDENT
10542 void *newline_var;
10543 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +010010544 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010545 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +010010546 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010547 )
10548 {
10549 res = RAISE_INDENTATION_ERROR ( "expected an indented block" );
10550 if (res == NULL && PyErr_Occurred()) {
10551 p->error_indicator = 1;
10552 return NULL;
10553 }
10554 goto done;
10555 }
10556 p->mark = mark;
10557 }
10558 res = NULL;
10559 done:
10560 return res;
10561}
10562
10563// invalid_comprehension: ('[' | '(' | '{') '*' expression for_if_clauses
10564static void *
10565invalid_comprehension_rule(Parser *p)
10566{
10567 if (p->error_indicator) {
10568 return NULL;
10569 }
10570 void * res = NULL;
10571 int mark = p->mark;
10572 { // ('[' | '(' | '{') '*' expression for_if_clauses
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010573 void *_tmp_133_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010574 expr_ty expression_var;
10575 asdl_seq* for_if_clauses_var;
10576 void *literal;
10577 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010578 (_tmp_133_var = _tmp_133_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010579 &&
10580 (literal = _PyPegen_expect_token(p, 16))
10581 &&
10582 (expression_var = expression_rule(p))
10583 &&
10584 (for_if_clauses_var = for_if_clauses_rule(p))
10585 )
10586 {
10587 res = RAISE_SYNTAX_ERROR ( "iterable unpacking cannot be used in comprehension" );
10588 if (res == NULL && PyErr_Occurred()) {
10589 p->error_indicator = 1;
10590 return NULL;
10591 }
10592 goto done;
10593 }
10594 p->mark = mark;
10595 }
10596 res = NULL;
10597 done:
10598 return res;
10599}
10600
10601// invalid_parameters:
Guido van Rossumc001c092020-04-30 12:12:19 -070010602// | param_no_default* (slash_with_default | param_with_default+) param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010603static void *
10604invalid_parameters_rule(Parser *p)
10605{
10606 if (p->error_indicator) {
10607 return NULL;
10608 }
10609 void * res = NULL;
10610 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070010611 { // param_no_default* (slash_with_default | param_with_default+) param_no_default
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010612 asdl_seq * _loop0_134_var;
10613 void *_tmp_135_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070010614 arg_ty param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010615 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010616 (_loop0_134_var = _loop0_134_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010617 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030010618 (_tmp_135_var = _tmp_135_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010619 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070010620 (param_no_default_var = param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010621 )
10622 {
10623 res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" );
10624 if (res == NULL && PyErr_Occurred()) {
10625 p->error_indicator = 1;
10626 return NULL;
10627 }
10628 goto done;
10629 }
10630 p->mark = mark;
10631 }
10632 res = NULL;
10633 done:
10634 return res;
10635}
10636
Guido van Rossumc001c092020-04-30 12:12:19 -070010637// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
10638static void *
10639invalid_double_type_comments_rule(Parser *p)
10640{
10641 if (p->error_indicator) {
10642 return NULL;
10643 }
10644 void * res = NULL;
10645 int mark = p->mark;
10646 { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
10647 void *indent_var;
10648 void *newline_var;
10649 void *newline_var_1;
10650 void *type_comment_var;
10651 void *type_comment_var_1;
10652 if (
10653 (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT))
10654 &&
10655 (newline_var = _PyPegen_expect_token(p, NEWLINE))
10656 &&
10657 (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT))
10658 &&
10659 (newline_var_1 = _PyPegen_expect_token(p, NEWLINE))
10660 &&
10661 (indent_var = _PyPegen_expect_token(p, INDENT))
10662 )
10663 {
10664 res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" );
10665 if (res == NULL && PyErr_Occurred()) {
10666 p->error_indicator = 1;
10667 return NULL;
10668 }
10669 goto done;
10670 }
10671 p->mark = mark;
10672 }
10673 res = NULL;
10674 done:
10675 return res;
10676}
10677
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010678// _loop0_1: NEWLINE
10679static asdl_seq *
10680_loop0_1_rule(Parser *p)
10681{
10682 if (p->error_indicator) {
10683 return NULL;
10684 }
10685 void *res = NULL;
10686 int mark = p->mark;
10687 int start_mark = p->mark;
10688 void **children = PyMem_Malloc(sizeof(void *));
10689 if (!children) {
10690 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
10691 return NULL;
10692 }
10693 ssize_t children_capacity = 1;
10694 ssize_t n = 0;
10695 { // NEWLINE
10696 void *newline_var;
10697 while (
Pablo Galindo4db245e2020-04-29 10:42:21 +010010698 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010699 )
10700 {
10701 res = newline_var;
10702 if (n == children_capacity) {
10703 children_capacity *= 2;
10704 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
10705 if (!children) {
10706 PyErr_Format(PyExc_MemoryError, "realloc None");
10707 return NULL;
10708 }
10709 }
10710 children[n++] = res;
10711 mark = p->mark;
10712 }
10713 p->mark = mark;
10714 }
10715 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
10716 if (!seq) {
10717 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1");
10718 PyMem_Free(children);
10719 return NULL;
10720 }
10721 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
10722 PyMem_Free(children);
10723 _PyPegen_insert_memo(p, start_mark, _loop0_1_type, seq);
10724 return seq;
10725}
10726
Guido van Rossumc001c092020-04-30 12:12:19 -070010727// _loop0_2: NEWLINE
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010728static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070010729_loop0_2_rule(Parser *p)
10730{
10731 if (p->error_indicator) {
10732 return NULL;
10733 }
10734 void *res = NULL;
10735 int mark = p->mark;
10736 int start_mark = p->mark;
10737 void **children = PyMem_Malloc(sizeof(void *));
10738 if (!children) {
10739 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
10740 return NULL;
10741 }
10742 ssize_t children_capacity = 1;
10743 ssize_t n = 0;
10744 { // NEWLINE
10745 void *newline_var;
10746 while (
10747 (newline_var = _PyPegen_expect_token(p, NEWLINE))
10748 )
10749 {
10750 res = newline_var;
10751 if (n == children_capacity) {
10752 children_capacity *= 2;
10753 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
10754 if (!children) {
10755 PyErr_Format(PyExc_MemoryError, "realloc None");
10756 return NULL;
10757 }
10758 }
10759 children[n++] = res;
10760 mark = p->mark;
10761 }
10762 p->mark = mark;
10763 }
10764 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
10765 if (!seq) {
10766 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2");
10767 PyMem_Free(children);
10768 return NULL;
10769 }
10770 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
10771 PyMem_Free(children);
10772 _PyPegen_insert_memo(p, start_mark, _loop0_2_type, seq);
10773 return seq;
10774}
10775
10776// _loop0_4: ',' expression
10777static asdl_seq *
10778_loop0_4_rule(Parser *p)
10779{
10780 if (p->error_indicator) {
10781 return NULL;
10782 }
10783 void *res = NULL;
10784 int mark = p->mark;
10785 int start_mark = p->mark;
10786 void **children = PyMem_Malloc(sizeof(void *));
10787 if (!children) {
10788 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
10789 return NULL;
10790 }
10791 ssize_t children_capacity = 1;
10792 ssize_t n = 0;
10793 { // ',' expression
10794 expr_ty elem;
10795 void *literal;
10796 while (
10797 (literal = _PyPegen_expect_token(p, 12))
10798 &&
10799 (elem = expression_rule(p))
10800 )
10801 {
10802 res = elem;
10803 if (res == NULL && PyErr_Occurred()) {
10804 p->error_indicator = 1;
10805 PyMem_Free(children);
10806 return NULL;
10807 }
10808 if (n == children_capacity) {
10809 children_capacity *= 2;
10810 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
10811 if (!children) {
10812 PyErr_Format(PyExc_MemoryError, "realloc None");
10813 return NULL;
10814 }
10815 }
10816 children[n++] = res;
10817 mark = p->mark;
10818 }
10819 p->mark = mark;
10820 }
10821 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
10822 if (!seq) {
10823 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4");
10824 PyMem_Free(children);
10825 return NULL;
10826 }
10827 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
10828 PyMem_Free(children);
10829 _PyPegen_insert_memo(p, start_mark, _loop0_4_type, seq);
10830 return seq;
10831}
10832
10833// _gather_3: expression _loop0_4
10834static asdl_seq *
10835_gather_3_rule(Parser *p)
10836{
10837 if (p->error_indicator) {
10838 return NULL;
10839 }
10840 asdl_seq * res = NULL;
10841 int mark = p->mark;
10842 { // expression _loop0_4
10843 expr_ty elem;
10844 asdl_seq * seq;
10845 if (
10846 (elem = expression_rule(p))
10847 &&
10848 (seq = _loop0_4_rule(p))
10849 )
10850 {
10851 res = _PyPegen_seq_insert_in_front(p, elem, seq);
10852 goto done;
10853 }
10854 p->mark = mark;
10855 }
10856 res = NULL;
10857 done:
10858 return res;
10859}
10860
10861// _loop0_6: ',' expression
10862static asdl_seq *
10863_loop0_6_rule(Parser *p)
10864{
10865 if (p->error_indicator) {
10866 return NULL;
10867 }
10868 void *res = NULL;
10869 int mark = p->mark;
10870 int start_mark = p->mark;
10871 void **children = PyMem_Malloc(sizeof(void *));
10872 if (!children) {
10873 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
10874 return NULL;
10875 }
10876 ssize_t children_capacity = 1;
10877 ssize_t n = 0;
10878 { // ',' expression
10879 expr_ty elem;
10880 void *literal;
10881 while (
10882 (literal = _PyPegen_expect_token(p, 12))
10883 &&
10884 (elem = expression_rule(p))
10885 )
10886 {
10887 res = elem;
10888 if (res == NULL && PyErr_Occurred()) {
10889 p->error_indicator = 1;
10890 PyMem_Free(children);
10891 return NULL;
10892 }
10893 if (n == children_capacity) {
10894 children_capacity *= 2;
10895 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
10896 if (!children) {
10897 PyErr_Format(PyExc_MemoryError, "realloc None");
10898 return NULL;
10899 }
10900 }
10901 children[n++] = res;
10902 mark = p->mark;
10903 }
10904 p->mark = mark;
10905 }
10906 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
10907 if (!seq) {
10908 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6");
10909 PyMem_Free(children);
10910 return NULL;
10911 }
10912 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
10913 PyMem_Free(children);
10914 _PyPegen_insert_memo(p, start_mark, _loop0_6_type, seq);
10915 return seq;
10916}
10917
10918// _gather_5: expression _loop0_6
10919static asdl_seq *
10920_gather_5_rule(Parser *p)
10921{
10922 if (p->error_indicator) {
10923 return NULL;
10924 }
10925 asdl_seq * res = NULL;
10926 int mark = p->mark;
10927 { // expression _loop0_6
10928 expr_ty elem;
10929 asdl_seq * seq;
10930 if (
10931 (elem = expression_rule(p))
10932 &&
10933 (seq = _loop0_6_rule(p))
10934 )
10935 {
10936 res = _PyPegen_seq_insert_in_front(p, elem, seq);
10937 goto done;
10938 }
10939 p->mark = mark;
10940 }
10941 res = NULL;
10942 done:
10943 return res;
10944}
10945
10946// _loop0_8: ',' expression
10947static asdl_seq *
10948_loop0_8_rule(Parser *p)
10949{
10950 if (p->error_indicator) {
10951 return NULL;
10952 }
10953 void *res = NULL;
10954 int mark = p->mark;
10955 int start_mark = p->mark;
10956 void **children = PyMem_Malloc(sizeof(void *));
10957 if (!children) {
10958 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
10959 return NULL;
10960 }
10961 ssize_t children_capacity = 1;
10962 ssize_t n = 0;
10963 { // ',' expression
10964 expr_ty elem;
10965 void *literal;
10966 while (
10967 (literal = _PyPegen_expect_token(p, 12))
10968 &&
10969 (elem = expression_rule(p))
10970 )
10971 {
10972 res = elem;
10973 if (res == NULL && PyErr_Occurred()) {
10974 p->error_indicator = 1;
10975 PyMem_Free(children);
10976 return NULL;
10977 }
10978 if (n == children_capacity) {
10979 children_capacity *= 2;
10980 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
10981 if (!children) {
10982 PyErr_Format(PyExc_MemoryError, "realloc None");
10983 return NULL;
10984 }
10985 }
10986 children[n++] = res;
10987 mark = p->mark;
10988 }
10989 p->mark = mark;
10990 }
10991 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
10992 if (!seq) {
10993 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8");
10994 PyMem_Free(children);
10995 return NULL;
10996 }
10997 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
10998 PyMem_Free(children);
10999 _PyPegen_insert_memo(p, start_mark, _loop0_8_type, seq);
11000 return seq;
11001}
11002
11003// _gather_7: expression _loop0_8
11004static asdl_seq *
11005_gather_7_rule(Parser *p)
11006{
11007 if (p->error_indicator) {
11008 return NULL;
11009 }
11010 asdl_seq * res = NULL;
11011 int mark = p->mark;
11012 { // expression _loop0_8
11013 expr_ty elem;
11014 asdl_seq * seq;
11015 if (
11016 (elem = expression_rule(p))
11017 &&
11018 (seq = _loop0_8_rule(p))
11019 )
11020 {
11021 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11022 goto done;
11023 }
11024 p->mark = mark;
11025 }
11026 res = NULL;
11027 done:
11028 return res;
11029}
11030
11031// _loop0_10: ',' expression
11032static asdl_seq *
11033_loop0_10_rule(Parser *p)
11034{
11035 if (p->error_indicator) {
11036 return NULL;
11037 }
11038 void *res = NULL;
11039 int mark = p->mark;
11040 int start_mark = p->mark;
11041 void **children = PyMem_Malloc(sizeof(void *));
11042 if (!children) {
11043 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11044 return NULL;
11045 }
11046 ssize_t children_capacity = 1;
11047 ssize_t n = 0;
11048 { // ',' expression
11049 expr_ty elem;
11050 void *literal;
11051 while (
11052 (literal = _PyPegen_expect_token(p, 12))
11053 &&
11054 (elem = expression_rule(p))
11055 )
11056 {
11057 res = elem;
11058 if (res == NULL && PyErr_Occurred()) {
11059 p->error_indicator = 1;
11060 PyMem_Free(children);
11061 return NULL;
11062 }
11063 if (n == children_capacity) {
11064 children_capacity *= 2;
11065 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11066 if (!children) {
11067 PyErr_Format(PyExc_MemoryError, "realloc None");
11068 return NULL;
11069 }
11070 }
11071 children[n++] = res;
11072 mark = p->mark;
11073 }
11074 p->mark = mark;
11075 }
11076 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11077 if (!seq) {
11078 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10");
11079 PyMem_Free(children);
11080 return NULL;
11081 }
11082 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11083 PyMem_Free(children);
11084 _PyPegen_insert_memo(p, start_mark, _loop0_10_type, seq);
11085 return seq;
11086}
11087
11088// _gather_9: expression _loop0_10
11089static asdl_seq *
11090_gather_9_rule(Parser *p)
11091{
11092 if (p->error_indicator) {
11093 return NULL;
11094 }
11095 asdl_seq * res = NULL;
11096 int mark = p->mark;
11097 { // expression _loop0_10
11098 expr_ty elem;
11099 asdl_seq * seq;
11100 if (
11101 (elem = expression_rule(p))
11102 &&
11103 (seq = _loop0_10_rule(p))
11104 )
11105 {
11106 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11107 goto done;
11108 }
11109 p->mark = mark;
11110 }
11111 res = NULL;
11112 done:
11113 return res;
11114}
11115
11116// _loop1_11: statement
11117static asdl_seq *
11118_loop1_11_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011119{
11120 if (p->error_indicator) {
11121 return NULL;
11122 }
11123 void *res = NULL;
11124 int mark = p->mark;
11125 int start_mark = p->mark;
11126 void **children = PyMem_Malloc(sizeof(void *));
11127 if (!children) {
11128 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11129 return NULL;
11130 }
11131 ssize_t children_capacity = 1;
11132 ssize_t n = 0;
11133 { // statement
11134 asdl_seq* statement_var;
11135 while (
11136 (statement_var = statement_rule(p))
11137 )
11138 {
11139 res = statement_var;
11140 if (n == children_capacity) {
11141 children_capacity *= 2;
11142 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11143 if (!children) {
11144 PyErr_Format(PyExc_MemoryError, "realloc None");
11145 return NULL;
11146 }
11147 }
11148 children[n++] = res;
11149 mark = p->mark;
11150 }
11151 p->mark = mark;
11152 }
11153 if (n == 0) {
11154 PyMem_Free(children);
11155 return NULL;
11156 }
11157 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11158 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070011159 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011160 PyMem_Free(children);
11161 return NULL;
11162 }
11163 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11164 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070011165 _PyPegen_insert_memo(p, start_mark, _loop1_11_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011166 return seq;
11167}
11168
Guido van Rossumc001c092020-04-30 12:12:19 -070011169// _loop0_13: ';' small_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011170static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011171_loop0_13_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011172{
11173 if (p->error_indicator) {
11174 return NULL;
11175 }
11176 void *res = NULL;
11177 int mark = p->mark;
11178 int start_mark = p->mark;
11179 void **children = PyMem_Malloc(sizeof(void *));
11180 if (!children) {
11181 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11182 return NULL;
11183 }
11184 ssize_t children_capacity = 1;
11185 ssize_t n = 0;
11186 { // ';' small_stmt
11187 stmt_ty elem;
11188 void *literal;
11189 while (
11190 (literal = _PyPegen_expect_token(p, 13))
11191 &&
11192 (elem = small_stmt_rule(p))
11193 )
11194 {
11195 res = elem;
11196 if (res == NULL && PyErr_Occurred()) {
11197 p->error_indicator = 1;
11198 PyMem_Free(children);
11199 return NULL;
11200 }
11201 if (n == children_capacity) {
11202 children_capacity *= 2;
11203 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11204 if (!children) {
11205 PyErr_Format(PyExc_MemoryError, "realloc None");
11206 return NULL;
11207 }
11208 }
11209 children[n++] = res;
11210 mark = p->mark;
11211 }
11212 p->mark = mark;
11213 }
11214 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11215 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070011216 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011217 PyMem_Free(children);
11218 return NULL;
11219 }
11220 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11221 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070011222 _PyPegen_insert_memo(p, start_mark, _loop0_13_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011223 return seq;
11224}
11225
Guido van Rossumc001c092020-04-30 12:12:19 -070011226// _gather_12: small_stmt _loop0_13
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011227static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011228_gather_12_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011229{
11230 if (p->error_indicator) {
11231 return NULL;
11232 }
11233 asdl_seq * res = NULL;
11234 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070011235 { // small_stmt _loop0_13
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011236 stmt_ty elem;
11237 asdl_seq * seq;
11238 if (
11239 (elem = small_stmt_rule(p))
11240 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070011241 (seq = _loop0_13_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011242 )
11243 {
11244 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11245 goto done;
11246 }
11247 p->mark = mark;
11248 }
11249 res = NULL;
11250 done:
11251 return res;
11252}
11253
Guido van Rossumc001c092020-04-30 12:12:19 -070011254// _tmp_14: 'import' | 'from'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011255static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011256_tmp_14_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011257{
11258 if (p->error_indicator) {
11259 return NULL;
11260 }
11261 void * res = NULL;
11262 int mark = p->mark;
11263 { // 'import'
11264 void *keyword;
11265 if (
11266 (keyword = _PyPegen_expect_token(p, 513))
11267 )
11268 {
11269 res = keyword;
11270 goto done;
11271 }
11272 p->mark = mark;
11273 }
11274 { // 'from'
11275 void *keyword;
11276 if (
11277 (keyword = _PyPegen_expect_token(p, 514))
11278 )
11279 {
11280 res = keyword;
11281 goto done;
11282 }
11283 p->mark = mark;
11284 }
11285 res = NULL;
11286 done:
11287 return res;
11288}
11289
Guido van Rossumc001c092020-04-30 12:12:19 -070011290// _tmp_15: 'def' | '@' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011291static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011292_tmp_15_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011293{
11294 if (p->error_indicator) {
11295 return NULL;
11296 }
11297 void * res = NULL;
11298 int mark = p->mark;
11299 { // 'def'
11300 void *keyword;
11301 if (
11302 (keyword = _PyPegen_expect_token(p, 522))
11303 )
11304 {
11305 res = keyword;
11306 goto done;
11307 }
11308 p->mark = mark;
11309 }
11310 { // '@'
11311 void *literal;
11312 if (
11313 (literal = _PyPegen_expect_token(p, 49))
11314 )
11315 {
11316 res = literal;
11317 goto done;
11318 }
11319 p->mark = mark;
11320 }
11321 { // ASYNC
11322 void *async_var;
11323 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +010011324 (async_var = _PyPegen_expect_token(p, ASYNC))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011325 )
11326 {
11327 res = async_var;
11328 goto done;
11329 }
11330 p->mark = mark;
11331 }
11332 res = NULL;
11333 done:
11334 return res;
11335}
11336
Guido van Rossumc001c092020-04-30 12:12:19 -070011337// _tmp_16: 'class' | '@'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011338static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011339_tmp_16_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011340{
11341 if (p->error_indicator) {
11342 return NULL;
11343 }
11344 void * res = NULL;
11345 int mark = p->mark;
11346 { // 'class'
11347 void *keyword;
11348 if (
11349 (keyword = _PyPegen_expect_token(p, 523))
11350 )
11351 {
11352 res = keyword;
11353 goto done;
11354 }
11355 p->mark = mark;
11356 }
11357 { // '@'
11358 void *literal;
11359 if (
11360 (literal = _PyPegen_expect_token(p, 49))
11361 )
11362 {
11363 res = literal;
11364 goto done;
11365 }
11366 p->mark = mark;
11367 }
11368 res = NULL;
11369 done:
11370 return res;
11371}
11372
Guido van Rossumc001c092020-04-30 12:12:19 -070011373// _tmp_17: 'with' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011374static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011375_tmp_17_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011376{
11377 if (p->error_indicator) {
11378 return NULL;
11379 }
11380 void * res = NULL;
11381 int mark = p->mark;
11382 { // 'with'
11383 void *keyword;
11384 if (
11385 (keyword = _PyPegen_expect_token(p, 519))
11386 )
11387 {
11388 res = keyword;
11389 goto done;
11390 }
11391 p->mark = mark;
11392 }
11393 { // ASYNC
11394 void *async_var;
11395 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +010011396 (async_var = _PyPegen_expect_token(p, ASYNC))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011397 )
11398 {
11399 res = async_var;
11400 goto done;
11401 }
11402 p->mark = mark;
11403 }
11404 res = NULL;
11405 done:
11406 return res;
11407}
11408
Guido van Rossumc001c092020-04-30 12:12:19 -070011409// _tmp_18: 'for' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011410static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011411_tmp_18_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011412{
11413 if (p->error_indicator) {
11414 return NULL;
11415 }
11416 void * res = NULL;
11417 int mark = p->mark;
11418 { // 'for'
11419 void *keyword;
11420 if (
11421 (keyword = _PyPegen_expect_token(p, 517))
11422 )
11423 {
11424 res = keyword;
11425 goto done;
11426 }
11427 p->mark = mark;
11428 }
11429 { // ASYNC
11430 void *async_var;
11431 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +010011432 (async_var = _PyPegen_expect_token(p, ASYNC))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011433 )
11434 {
11435 res = async_var;
11436 goto done;
11437 }
11438 p->mark = mark;
11439 }
11440 res = NULL;
11441 done:
11442 return res;
11443}
11444
Guido van Rossumc001c092020-04-30 12:12:19 -070011445// _tmp_19: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011446static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011447_tmp_19_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011448{
11449 if (p->error_indicator) {
11450 return NULL;
11451 }
11452 void * res = NULL;
11453 int mark = p->mark;
11454 { // '=' annotated_rhs
11455 expr_ty d;
11456 void *literal;
11457 if (
11458 (literal = _PyPegen_expect_token(p, 22))
11459 &&
11460 (d = annotated_rhs_rule(p))
11461 )
11462 {
11463 res = d;
11464 if (res == NULL && PyErr_Occurred()) {
11465 p->error_indicator = 1;
11466 return NULL;
11467 }
11468 goto done;
11469 }
11470 p->mark = mark;
11471 }
11472 res = NULL;
11473 done:
11474 return res;
11475}
11476
Guido van Rossumc001c092020-04-30 12:12:19 -070011477// _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011478static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011479_tmp_20_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011480{
11481 if (p->error_indicator) {
11482 return NULL;
11483 }
11484 void * res = NULL;
11485 int mark = p->mark;
11486 { // '(' inside_paren_ann_assign_target ')'
11487 expr_ty b;
11488 void *literal;
11489 void *literal_1;
11490 if (
11491 (literal = _PyPegen_expect_token(p, 7))
11492 &&
11493 (b = inside_paren_ann_assign_target_rule(p))
11494 &&
11495 (literal_1 = _PyPegen_expect_token(p, 8))
11496 )
11497 {
11498 res = b;
11499 if (res == NULL && PyErr_Occurred()) {
11500 p->error_indicator = 1;
11501 return NULL;
11502 }
11503 goto done;
11504 }
11505 p->mark = mark;
11506 }
11507 { // ann_assign_subscript_attribute_target
11508 expr_ty ann_assign_subscript_attribute_target_var;
11509 if (
11510 (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p))
11511 )
11512 {
11513 res = ann_assign_subscript_attribute_target_var;
11514 goto done;
11515 }
11516 p->mark = mark;
11517 }
11518 res = NULL;
11519 done:
11520 return res;
11521}
11522
Guido van Rossumc001c092020-04-30 12:12:19 -070011523// _tmp_21: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011524static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011525_tmp_21_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011526{
11527 if (p->error_indicator) {
11528 return NULL;
11529 }
11530 void * res = NULL;
11531 int mark = p->mark;
11532 { // '=' annotated_rhs
11533 expr_ty d;
11534 void *literal;
11535 if (
11536 (literal = _PyPegen_expect_token(p, 22))
11537 &&
11538 (d = annotated_rhs_rule(p))
11539 )
11540 {
11541 res = d;
11542 if (res == NULL && PyErr_Occurred()) {
11543 p->error_indicator = 1;
11544 return NULL;
11545 }
11546 goto done;
11547 }
11548 p->mark = mark;
11549 }
11550 res = NULL;
11551 done:
11552 return res;
11553}
11554
Guido van Rossumc001c092020-04-30 12:12:19 -070011555// _loop1_22: (star_targets '=')
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011556static asdl_seq *
11557_loop1_22_rule(Parser *p)
11558{
11559 if (p->error_indicator) {
11560 return NULL;
11561 }
11562 void *res = NULL;
11563 int mark = p->mark;
11564 int start_mark = p->mark;
11565 void **children = PyMem_Malloc(sizeof(void *));
11566 if (!children) {
11567 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11568 return NULL;
11569 }
11570 ssize_t children_capacity = 1;
11571 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070011572 { // (star_targets '=')
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011573 void *_tmp_136_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011574 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011575 (_tmp_136_var = _tmp_136_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011576 )
11577 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011578 res = _tmp_136_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011579 if (n == children_capacity) {
11580 children_capacity *= 2;
11581 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11582 if (!children) {
11583 PyErr_Format(PyExc_MemoryError, "realloc None");
11584 return NULL;
11585 }
11586 }
11587 children[n++] = res;
11588 mark = p->mark;
11589 }
11590 p->mark = mark;
11591 }
11592 if (n == 0) {
11593 PyMem_Free(children);
11594 return NULL;
11595 }
11596 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11597 if (!seq) {
11598 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22");
11599 PyMem_Free(children);
11600 return NULL;
11601 }
11602 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11603 PyMem_Free(children);
11604 _PyPegen_insert_memo(p, start_mark, _loop1_22_type, seq);
11605 return seq;
11606}
11607
Guido van Rossumc001c092020-04-30 12:12:19 -070011608// _tmp_23: yield_expr | star_expressions
11609static void *
11610_tmp_23_rule(Parser *p)
11611{
11612 if (p->error_indicator) {
11613 return NULL;
11614 }
11615 void * res = NULL;
11616 int mark = p->mark;
11617 { // yield_expr
11618 expr_ty yield_expr_var;
11619 if (
11620 (yield_expr_var = yield_expr_rule(p))
11621 )
11622 {
11623 res = yield_expr_var;
11624 goto done;
11625 }
11626 p->mark = mark;
11627 }
11628 { // star_expressions
11629 expr_ty star_expressions_var;
11630 if (
11631 (star_expressions_var = star_expressions_rule(p))
11632 )
11633 {
11634 res = star_expressions_var;
11635 goto done;
11636 }
11637 p->mark = mark;
11638 }
11639 res = NULL;
11640 done:
11641 return res;
11642}
11643
11644// _tmp_24: yield_expr | star_expressions
11645static void *
11646_tmp_24_rule(Parser *p)
11647{
11648 if (p->error_indicator) {
11649 return NULL;
11650 }
11651 void * res = NULL;
11652 int mark = p->mark;
11653 { // yield_expr
11654 expr_ty yield_expr_var;
11655 if (
11656 (yield_expr_var = yield_expr_rule(p))
11657 )
11658 {
11659 res = yield_expr_var;
11660 goto done;
11661 }
11662 p->mark = mark;
11663 }
11664 { // star_expressions
11665 expr_ty star_expressions_var;
11666 if (
11667 (star_expressions_var = star_expressions_rule(p))
11668 )
11669 {
11670 res = star_expressions_var;
11671 goto done;
11672 }
11673 p->mark = mark;
11674 }
11675 res = NULL;
11676 done:
11677 return res;
11678}
11679
11680// _loop0_26: ',' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011681static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011682_loop0_26_rule(Parser *p)
11683{
11684 if (p->error_indicator) {
11685 return NULL;
11686 }
11687 void *res = NULL;
11688 int mark = p->mark;
11689 int start_mark = p->mark;
11690 void **children = PyMem_Malloc(sizeof(void *));
11691 if (!children) {
11692 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11693 return NULL;
11694 }
11695 ssize_t children_capacity = 1;
11696 ssize_t n = 0;
11697 { // ',' NAME
11698 expr_ty elem;
11699 void *literal;
11700 while (
11701 (literal = _PyPegen_expect_token(p, 12))
11702 &&
11703 (elem = _PyPegen_name_token(p))
11704 )
11705 {
11706 res = elem;
11707 if (res == NULL && PyErr_Occurred()) {
11708 p->error_indicator = 1;
11709 PyMem_Free(children);
11710 return NULL;
11711 }
11712 if (n == children_capacity) {
11713 children_capacity *= 2;
11714 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11715 if (!children) {
11716 PyErr_Format(PyExc_MemoryError, "realloc None");
11717 return NULL;
11718 }
11719 }
11720 children[n++] = res;
11721 mark = p->mark;
11722 }
11723 p->mark = mark;
11724 }
11725 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11726 if (!seq) {
11727 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26");
11728 PyMem_Free(children);
11729 return NULL;
11730 }
11731 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11732 PyMem_Free(children);
11733 _PyPegen_insert_memo(p, start_mark, _loop0_26_type, seq);
11734 return seq;
11735}
11736
11737// _gather_25: NAME _loop0_26
11738static asdl_seq *
11739_gather_25_rule(Parser *p)
11740{
11741 if (p->error_indicator) {
11742 return NULL;
11743 }
11744 asdl_seq * res = NULL;
11745 int mark = p->mark;
11746 { // NAME _loop0_26
11747 expr_ty elem;
11748 asdl_seq * seq;
11749 if (
11750 (elem = _PyPegen_name_token(p))
11751 &&
11752 (seq = _loop0_26_rule(p))
11753 )
11754 {
11755 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11756 goto done;
11757 }
11758 p->mark = mark;
11759 }
11760 res = NULL;
11761 done:
11762 return res;
11763}
11764
11765// _loop0_28: ',' NAME
11766static asdl_seq *
11767_loop0_28_rule(Parser *p)
11768{
11769 if (p->error_indicator) {
11770 return NULL;
11771 }
11772 void *res = NULL;
11773 int mark = p->mark;
11774 int start_mark = p->mark;
11775 void **children = PyMem_Malloc(sizeof(void *));
11776 if (!children) {
11777 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11778 return NULL;
11779 }
11780 ssize_t children_capacity = 1;
11781 ssize_t n = 0;
11782 { // ',' NAME
11783 expr_ty elem;
11784 void *literal;
11785 while (
11786 (literal = _PyPegen_expect_token(p, 12))
11787 &&
11788 (elem = _PyPegen_name_token(p))
11789 )
11790 {
11791 res = elem;
11792 if (res == NULL && PyErr_Occurred()) {
11793 p->error_indicator = 1;
11794 PyMem_Free(children);
11795 return NULL;
11796 }
11797 if (n == children_capacity) {
11798 children_capacity *= 2;
11799 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11800 if (!children) {
11801 PyErr_Format(PyExc_MemoryError, "realloc None");
11802 return NULL;
11803 }
11804 }
11805 children[n++] = res;
11806 mark = p->mark;
11807 }
11808 p->mark = mark;
11809 }
11810 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11811 if (!seq) {
11812 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28");
11813 PyMem_Free(children);
11814 return NULL;
11815 }
11816 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11817 PyMem_Free(children);
11818 _PyPegen_insert_memo(p, start_mark, _loop0_28_type, seq);
11819 return seq;
11820}
11821
11822// _gather_27: NAME _loop0_28
11823static asdl_seq *
11824_gather_27_rule(Parser *p)
11825{
11826 if (p->error_indicator) {
11827 return NULL;
11828 }
11829 asdl_seq * res = NULL;
11830 int mark = p->mark;
11831 { // NAME _loop0_28
11832 expr_ty elem;
11833 asdl_seq * seq;
11834 if (
11835 (elem = _PyPegen_name_token(p))
11836 &&
11837 (seq = _loop0_28_rule(p))
11838 )
11839 {
11840 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11841 goto done;
11842 }
11843 p->mark = mark;
11844 }
11845 res = NULL;
11846 done:
11847 return res;
11848}
11849
11850// _tmp_29: ',' expression
11851static void *
11852_tmp_29_rule(Parser *p)
11853{
11854 if (p->error_indicator) {
11855 return NULL;
11856 }
11857 void * res = NULL;
11858 int mark = p->mark;
11859 { // ',' expression
11860 void *literal;
11861 expr_ty z;
11862 if (
11863 (literal = _PyPegen_expect_token(p, 12))
11864 &&
11865 (z = expression_rule(p))
11866 )
11867 {
11868 res = z;
11869 if (res == NULL && PyErr_Occurred()) {
11870 p->error_indicator = 1;
11871 return NULL;
11872 }
11873 goto done;
11874 }
11875 p->mark = mark;
11876 }
11877 res = NULL;
11878 done:
11879 return res;
11880}
11881
11882// _loop0_30: ('.' | '...')
11883static asdl_seq *
11884_loop0_30_rule(Parser *p)
11885{
11886 if (p->error_indicator) {
11887 return NULL;
11888 }
11889 void *res = NULL;
11890 int mark = p->mark;
11891 int start_mark = p->mark;
11892 void **children = PyMem_Malloc(sizeof(void *));
11893 if (!children) {
11894 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11895 return NULL;
11896 }
11897 ssize_t children_capacity = 1;
11898 ssize_t n = 0;
11899 { // ('.' | '...')
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011900 void *_tmp_137_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070011901 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011902 (_tmp_137_var = _tmp_137_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070011903 )
11904 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011905 res = _tmp_137_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070011906 if (n == children_capacity) {
11907 children_capacity *= 2;
11908 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11909 if (!children) {
11910 PyErr_Format(PyExc_MemoryError, "realloc None");
11911 return NULL;
11912 }
11913 }
11914 children[n++] = res;
11915 mark = p->mark;
11916 }
11917 p->mark = mark;
11918 }
11919 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11920 if (!seq) {
11921 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30");
11922 PyMem_Free(children);
11923 return NULL;
11924 }
11925 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11926 PyMem_Free(children);
11927 _PyPegen_insert_memo(p, start_mark, _loop0_30_type, seq);
11928 return seq;
11929}
11930
11931// _loop1_31: ('.' | '...')
11932static asdl_seq *
11933_loop1_31_rule(Parser *p)
11934{
11935 if (p->error_indicator) {
11936 return NULL;
11937 }
11938 void *res = NULL;
11939 int mark = p->mark;
11940 int start_mark = p->mark;
11941 void **children = PyMem_Malloc(sizeof(void *));
11942 if (!children) {
11943 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11944 return NULL;
11945 }
11946 ssize_t children_capacity = 1;
11947 ssize_t n = 0;
11948 { // ('.' | '...')
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011949 void *_tmp_138_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070011950 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011951 (_tmp_138_var = _tmp_138_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070011952 )
11953 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030011954 res = _tmp_138_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070011955 if (n == children_capacity) {
11956 children_capacity *= 2;
11957 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11958 if (!children) {
11959 PyErr_Format(PyExc_MemoryError, "realloc None");
11960 return NULL;
11961 }
11962 }
11963 children[n++] = res;
11964 mark = p->mark;
11965 }
11966 p->mark = mark;
11967 }
11968 if (n == 0) {
11969 PyMem_Free(children);
11970 return NULL;
11971 }
11972 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11973 if (!seq) {
11974 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31");
11975 PyMem_Free(children);
11976 return NULL;
11977 }
11978 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11979 PyMem_Free(children);
11980 _PyPegen_insert_memo(p, start_mark, _loop1_31_type, seq);
11981 return seq;
11982}
11983
11984// _loop0_33: ',' import_from_as_name
11985static asdl_seq *
11986_loop0_33_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011987{
11988 if (p->error_indicator) {
11989 return NULL;
11990 }
11991 void *res = NULL;
11992 int mark = p->mark;
11993 int start_mark = p->mark;
11994 void **children = PyMem_Malloc(sizeof(void *));
11995 if (!children) {
11996 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11997 return NULL;
11998 }
11999 ssize_t children_capacity = 1;
12000 ssize_t n = 0;
12001 { // ',' import_from_as_name
12002 alias_ty elem;
12003 void *literal;
12004 while (
12005 (literal = _PyPegen_expect_token(p, 12))
12006 &&
12007 (elem = import_from_as_name_rule(p))
12008 )
12009 {
12010 res = elem;
12011 if (res == NULL && PyErr_Occurred()) {
12012 p->error_indicator = 1;
12013 PyMem_Free(children);
12014 return NULL;
12015 }
12016 if (n == children_capacity) {
12017 children_capacity *= 2;
12018 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12019 if (!children) {
12020 PyErr_Format(PyExc_MemoryError, "realloc None");
12021 return NULL;
12022 }
12023 }
12024 children[n++] = res;
12025 mark = p->mark;
12026 }
12027 p->mark = mark;
12028 }
12029 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12030 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012031 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012032 PyMem_Free(children);
12033 return NULL;
12034 }
12035 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12036 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012037 _PyPegen_insert_memo(p, start_mark, _loop0_33_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012038 return seq;
12039}
12040
Guido van Rossumc001c092020-04-30 12:12:19 -070012041// _gather_32: import_from_as_name _loop0_33
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012042static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012043_gather_32_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012044{
12045 if (p->error_indicator) {
12046 return NULL;
12047 }
12048 asdl_seq * res = NULL;
12049 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012050 { // import_from_as_name _loop0_33
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012051 alias_ty elem;
12052 asdl_seq * seq;
12053 if (
12054 (elem = import_from_as_name_rule(p))
12055 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012056 (seq = _loop0_33_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012057 )
12058 {
12059 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12060 goto done;
12061 }
12062 p->mark = mark;
12063 }
12064 res = NULL;
12065 done:
12066 return res;
12067}
12068
Guido van Rossumc001c092020-04-30 12:12:19 -070012069// _tmp_34: 'as' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012070static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070012071_tmp_34_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012072{
12073 if (p->error_indicator) {
12074 return NULL;
12075 }
12076 void * res = NULL;
12077 int mark = p->mark;
12078 { // 'as' NAME
12079 void *keyword;
12080 expr_ty z;
12081 if (
12082 (keyword = _PyPegen_expect_token(p, 531))
12083 &&
12084 (z = _PyPegen_name_token(p))
12085 )
12086 {
12087 res = z;
12088 if (res == NULL && PyErr_Occurred()) {
12089 p->error_indicator = 1;
12090 return NULL;
12091 }
12092 goto done;
12093 }
12094 p->mark = mark;
12095 }
12096 res = NULL;
12097 done:
12098 return res;
12099}
12100
Guido van Rossumc001c092020-04-30 12:12:19 -070012101// _loop0_36: ',' dotted_as_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012102static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012103_loop0_36_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012104{
12105 if (p->error_indicator) {
12106 return NULL;
12107 }
12108 void *res = NULL;
12109 int mark = p->mark;
12110 int start_mark = p->mark;
12111 void **children = PyMem_Malloc(sizeof(void *));
12112 if (!children) {
12113 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12114 return NULL;
12115 }
12116 ssize_t children_capacity = 1;
12117 ssize_t n = 0;
12118 { // ',' dotted_as_name
12119 alias_ty elem;
12120 void *literal;
12121 while (
12122 (literal = _PyPegen_expect_token(p, 12))
12123 &&
12124 (elem = dotted_as_name_rule(p))
12125 )
12126 {
12127 res = elem;
12128 if (res == NULL && PyErr_Occurred()) {
12129 p->error_indicator = 1;
12130 PyMem_Free(children);
12131 return NULL;
12132 }
12133 if (n == children_capacity) {
12134 children_capacity *= 2;
12135 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12136 if (!children) {
12137 PyErr_Format(PyExc_MemoryError, "realloc None");
12138 return NULL;
12139 }
12140 }
12141 children[n++] = res;
12142 mark = p->mark;
12143 }
12144 p->mark = mark;
12145 }
12146 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12147 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012148 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012149 PyMem_Free(children);
12150 return NULL;
12151 }
12152 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12153 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012154 _PyPegen_insert_memo(p, start_mark, _loop0_36_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012155 return seq;
12156}
12157
Guido van Rossumc001c092020-04-30 12:12:19 -070012158// _gather_35: dotted_as_name _loop0_36
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012159static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012160_gather_35_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012161{
12162 if (p->error_indicator) {
12163 return NULL;
12164 }
12165 asdl_seq * res = NULL;
12166 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012167 { // dotted_as_name _loop0_36
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012168 alias_ty elem;
12169 asdl_seq * seq;
12170 if (
12171 (elem = dotted_as_name_rule(p))
12172 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012173 (seq = _loop0_36_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012174 )
12175 {
12176 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12177 goto done;
12178 }
12179 p->mark = mark;
12180 }
12181 res = NULL;
12182 done:
12183 return res;
12184}
12185
Guido van Rossumc001c092020-04-30 12:12:19 -070012186// _tmp_37: 'as' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012187static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070012188_tmp_37_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012189{
12190 if (p->error_indicator) {
12191 return NULL;
12192 }
12193 void * res = NULL;
12194 int mark = p->mark;
12195 { // 'as' NAME
12196 void *keyword;
12197 expr_ty z;
12198 if (
12199 (keyword = _PyPegen_expect_token(p, 531))
12200 &&
12201 (z = _PyPegen_name_token(p))
12202 )
12203 {
12204 res = z;
12205 if (res == NULL && PyErr_Occurred()) {
12206 p->error_indicator = 1;
12207 return NULL;
12208 }
12209 goto done;
12210 }
12211 p->mark = mark;
12212 }
12213 res = NULL;
12214 done:
12215 return res;
12216}
12217
Guido van Rossumc001c092020-04-30 12:12:19 -070012218// _loop0_39: ',' with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012219static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012220_loop0_39_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012221{
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 { // ',' with_item
12236 withitem_ty elem;
12237 void *literal;
12238 while (
12239 (literal = _PyPegen_expect_token(p, 12))
12240 &&
12241 (elem = with_item_rule(p))
12242 )
12243 {
12244 res = elem;
12245 if (res == NULL && PyErr_Occurred()) {
12246 p->error_indicator = 1;
12247 PyMem_Free(children);
12248 return NULL;
12249 }
12250 if (n == children_capacity) {
12251 children_capacity *= 2;
12252 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12253 if (!children) {
12254 PyErr_Format(PyExc_MemoryError, "realloc None");
12255 return NULL;
12256 }
12257 }
12258 children[n++] = res;
12259 mark = p->mark;
12260 }
12261 p->mark = mark;
12262 }
12263 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12264 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012265 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012266 PyMem_Free(children);
12267 return NULL;
12268 }
12269 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12270 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012271 _PyPegen_insert_memo(p, start_mark, _loop0_39_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012272 return seq;
12273}
12274
Guido van Rossumc001c092020-04-30 12:12:19 -070012275// _gather_38: with_item _loop0_39
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012276static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012277_gather_38_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012278{
12279 if (p->error_indicator) {
12280 return NULL;
12281 }
12282 asdl_seq * res = NULL;
12283 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012284 { // with_item _loop0_39
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012285 withitem_ty elem;
12286 asdl_seq * seq;
12287 if (
12288 (elem = with_item_rule(p))
12289 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012290 (seq = _loop0_39_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012291 )
12292 {
12293 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12294 goto done;
12295 }
12296 p->mark = mark;
12297 }
12298 res = NULL;
12299 done:
12300 return res;
12301}
12302
Guido van Rossumc001c092020-04-30 12:12:19 -070012303// _loop0_41: ',' with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012304static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012305_loop0_41_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012306{
12307 if (p->error_indicator) {
12308 return NULL;
12309 }
12310 void *res = NULL;
12311 int mark = p->mark;
12312 int start_mark = p->mark;
12313 void **children = PyMem_Malloc(sizeof(void *));
12314 if (!children) {
12315 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12316 return NULL;
12317 }
12318 ssize_t children_capacity = 1;
12319 ssize_t n = 0;
12320 { // ',' with_item
12321 withitem_ty elem;
12322 void *literal;
12323 while (
12324 (literal = _PyPegen_expect_token(p, 12))
12325 &&
12326 (elem = with_item_rule(p))
12327 )
12328 {
12329 res = elem;
12330 if (res == NULL && PyErr_Occurred()) {
12331 p->error_indicator = 1;
12332 PyMem_Free(children);
12333 return NULL;
12334 }
12335 if (n == children_capacity) {
12336 children_capacity *= 2;
12337 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12338 if (!children) {
12339 PyErr_Format(PyExc_MemoryError, "realloc None");
12340 return NULL;
12341 }
12342 }
12343 children[n++] = res;
12344 mark = p->mark;
12345 }
12346 p->mark = mark;
12347 }
12348 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12349 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012350 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012351 PyMem_Free(children);
12352 return NULL;
12353 }
12354 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12355 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012356 _PyPegen_insert_memo(p, start_mark, _loop0_41_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012357 return seq;
12358}
12359
Guido van Rossumc001c092020-04-30 12:12:19 -070012360// _gather_40: with_item _loop0_41
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012361static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012362_gather_40_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012363{
12364 if (p->error_indicator) {
12365 return NULL;
12366 }
12367 asdl_seq * res = NULL;
12368 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012369 { // with_item _loop0_41
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012370 withitem_ty elem;
12371 asdl_seq * seq;
12372 if (
12373 (elem = with_item_rule(p))
12374 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012375 (seq = _loop0_41_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012376 )
12377 {
12378 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12379 goto done;
12380 }
12381 p->mark = mark;
12382 }
12383 res = NULL;
12384 done:
12385 return res;
12386}
12387
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012388// _loop0_43: ',' with_item
12389static asdl_seq *
12390_loop0_43_rule(Parser *p)
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 { // ',' with_item
12406 withitem_ty elem;
12407 void *literal;
12408 while (
12409 (literal = _PyPegen_expect_token(p, 12))
12410 &&
12411 (elem = with_item_rule(p))
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) {
12435 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43");
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);
12441 _PyPegen_insert_memo(p, start_mark, _loop0_43_type, seq);
12442 return seq;
12443}
12444
12445// _gather_42: with_item _loop0_43
12446static asdl_seq *
12447_gather_42_rule(Parser *p)
12448{
12449 if (p->error_indicator) {
12450 return NULL;
12451 }
12452 asdl_seq * res = NULL;
12453 int mark = p->mark;
12454 { // with_item _loop0_43
12455 withitem_ty elem;
12456 asdl_seq * seq;
12457 if (
12458 (elem = with_item_rule(p))
12459 &&
12460 (seq = _loop0_43_rule(p))
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
12473// _loop0_45: ',' with_item
12474static asdl_seq *
12475_loop0_45_rule(Parser *p)
12476{
12477 if (p->error_indicator) {
12478 return NULL;
12479 }
12480 void *res = NULL;
12481 int mark = p->mark;
12482 int start_mark = p->mark;
12483 void **children = PyMem_Malloc(sizeof(void *));
12484 if (!children) {
12485 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12486 return NULL;
12487 }
12488 ssize_t children_capacity = 1;
12489 ssize_t n = 0;
12490 { // ',' with_item
12491 withitem_ty elem;
12492 void *literal;
12493 while (
12494 (literal = _PyPegen_expect_token(p, 12))
12495 &&
12496 (elem = with_item_rule(p))
12497 )
12498 {
12499 res = elem;
12500 if (res == NULL && PyErr_Occurred()) {
12501 p->error_indicator = 1;
12502 PyMem_Free(children);
12503 return NULL;
12504 }
12505 if (n == children_capacity) {
12506 children_capacity *= 2;
12507 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12508 if (!children) {
12509 PyErr_Format(PyExc_MemoryError, "realloc None");
12510 return NULL;
12511 }
12512 }
12513 children[n++] = res;
12514 mark = p->mark;
12515 }
12516 p->mark = mark;
12517 }
12518 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12519 if (!seq) {
12520 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45");
12521 PyMem_Free(children);
12522 return NULL;
12523 }
12524 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12525 PyMem_Free(children);
12526 _PyPegen_insert_memo(p, start_mark, _loop0_45_type, seq);
12527 return seq;
12528}
12529
12530// _gather_44: with_item _loop0_45
12531static asdl_seq *
12532_gather_44_rule(Parser *p)
12533{
12534 if (p->error_indicator) {
12535 return NULL;
12536 }
12537 asdl_seq * res = NULL;
12538 int mark = p->mark;
12539 { // with_item _loop0_45
12540 withitem_ty elem;
12541 asdl_seq * seq;
12542 if (
12543 (elem = with_item_rule(p))
12544 &&
12545 (seq = _loop0_45_rule(p))
12546 )
12547 {
12548 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12549 goto done;
12550 }
12551 p->mark = mark;
12552 }
12553 res = NULL;
12554 done:
12555 return res;
12556}
12557
12558// _tmp_46: 'as' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012559static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012560_tmp_46_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012561{
12562 if (p->error_indicator) {
12563 return NULL;
12564 }
12565 void * res = NULL;
12566 int mark = p->mark;
12567 { // 'as' target
12568 void *keyword;
12569 expr_ty t;
12570 if (
12571 (keyword = _PyPegen_expect_token(p, 531))
12572 &&
12573 (t = target_rule(p))
12574 )
12575 {
12576 res = t;
12577 if (res == NULL && PyErr_Occurred()) {
12578 p->error_indicator = 1;
12579 return NULL;
12580 }
12581 goto done;
12582 }
12583 p->mark = mark;
12584 }
12585 res = NULL;
12586 done:
12587 return res;
12588}
12589
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012590// _loop1_47: except_block
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012591static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012592_loop1_47_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012593{
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 { // except_block
12608 excepthandler_ty except_block_var;
12609 while (
12610 (except_block_var = except_block_rule(p))
12611 )
12612 {
12613 res = except_block_var;
12614 if (n == children_capacity) {
12615 children_capacity *= 2;
12616 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12617 if (!children) {
12618 PyErr_Format(PyExc_MemoryError, "realloc None");
12619 return NULL;
12620 }
12621 }
12622 children[n++] = res;
12623 mark = p->mark;
12624 }
12625 p->mark = mark;
12626 }
12627 if (n == 0) {
12628 PyMem_Free(children);
12629 return NULL;
12630 }
12631 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12632 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012633 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012634 PyMem_Free(children);
12635 return NULL;
12636 }
12637 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12638 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012639 _PyPegen_insert_memo(p, start_mark, _loop1_47_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012640 return seq;
12641}
12642
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012643// _tmp_48: 'as' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012644static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012645_tmp_48_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012646{
12647 if (p->error_indicator) {
12648 return NULL;
12649 }
12650 void * res = NULL;
12651 int mark = p->mark;
12652 { // 'as' target
12653 void *keyword;
12654 expr_ty z;
12655 if (
12656 (keyword = _PyPegen_expect_token(p, 531))
12657 &&
12658 (z = target_rule(p))
12659 )
12660 {
12661 res = z;
12662 if (res == NULL && PyErr_Occurred()) {
12663 p->error_indicator = 1;
12664 return NULL;
12665 }
12666 goto done;
12667 }
12668 p->mark = mark;
12669 }
12670 res = NULL;
12671 done:
12672 return res;
12673}
12674
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012675// _tmp_49: 'from' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012676static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012677_tmp_49_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012678{
12679 if (p->error_indicator) {
12680 return NULL;
12681 }
12682 void * res = NULL;
12683 int mark = p->mark;
12684 { // 'from' expression
12685 void *keyword;
12686 expr_ty z;
12687 if (
12688 (keyword = _PyPegen_expect_token(p, 514))
12689 &&
12690 (z = expression_rule(p))
12691 )
12692 {
12693 res = z;
12694 if (res == NULL && PyErr_Occurred()) {
12695 p->error_indicator = 1;
12696 return NULL;
12697 }
12698 goto done;
12699 }
12700 p->mark = mark;
12701 }
12702 res = NULL;
12703 done:
12704 return res;
12705}
12706
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012707// _tmp_50: '->' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012708static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012709_tmp_50_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012710{
12711 if (p->error_indicator) {
12712 return NULL;
12713 }
12714 void * res = NULL;
12715 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012716 { // '->' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012717 void *literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070012718 expr_ty z;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012719 if (
Guido van Rossumc001c092020-04-30 12:12:19 -070012720 (literal = _PyPegen_expect_token(p, 51))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012721 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012722 (z = expression_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012723 )
12724 {
Guido van Rossumc001c092020-04-30 12:12:19 -070012725 res = z;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012726 if (res == NULL && PyErr_Occurred()) {
12727 p->error_indicator = 1;
12728 return NULL;
12729 }
12730 goto done;
12731 }
12732 p->mark = mark;
12733 }
12734 res = NULL;
12735 done:
12736 return res;
12737}
12738
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012739// _tmp_51: '->' expression
Guido van Rossumc001c092020-04-30 12:12:19 -070012740static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012741_tmp_51_rule(Parser *p)
12742{
12743 if (p->error_indicator) {
12744 return NULL;
12745 }
12746 void * res = NULL;
12747 int mark = p->mark;
12748 { // '->' expression
12749 void *literal;
12750 expr_ty z;
12751 if (
12752 (literal = _PyPegen_expect_token(p, 51))
12753 &&
12754 (z = expression_rule(p))
12755 )
12756 {
12757 res = z;
12758 if (res == NULL && PyErr_Occurred()) {
12759 p->error_indicator = 1;
12760 return NULL;
12761 }
12762 goto done;
12763 }
12764 p->mark = mark;
12765 }
12766 res = NULL;
12767 done:
12768 return res;
12769}
12770
12771// _tmp_52: NEWLINE INDENT
12772static void *
12773_tmp_52_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070012774{
12775 if (p->error_indicator) {
12776 return NULL;
12777 }
12778 void * res = NULL;
12779 int mark = p->mark;
12780 { // NEWLINE INDENT
12781 void *indent_var;
12782 void *newline_var;
12783 if (
12784 (newline_var = _PyPegen_expect_token(p, NEWLINE))
12785 &&
12786 (indent_var = _PyPegen_expect_token(p, INDENT))
12787 )
12788 {
12789 res = _PyPegen_dummy_name(p, newline_var, indent_var);
12790 goto done;
12791 }
12792 p->mark = mark;
12793 }
12794 res = NULL;
12795 done:
12796 return res;
12797}
12798
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012799// _loop0_53: param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012800static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012801_loop0_53_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012802{
12803 if (p->error_indicator) {
12804 return NULL;
12805 }
12806 void *res = NULL;
12807 int mark = p->mark;
12808 int start_mark = p->mark;
12809 void **children = PyMem_Malloc(sizeof(void *));
12810 if (!children) {
12811 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12812 return NULL;
12813 }
12814 ssize_t children_capacity = 1;
12815 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070012816 { // param_no_default
12817 arg_ty param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012818 while (
Guido van Rossumc001c092020-04-30 12:12:19 -070012819 (param_no_default_var = param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012820 )
12821 {
Guido van Rossumc001c092020-04-30 12:12:19 -070012822 res = param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012823 if (n == children_capacity) {
12824 children_capacity *= 2;
12825 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12826 if (!children) {
12827 PyErr_Format(PyExc_MemoryError, "realloc None");
12828 return NULL;
12829 }
12830 }
12831 children[n++] = res;
12832 mark = p->mark;
12833 }
12834 p->mark = mark;
12835 }
12836 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12837 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012838 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012839 PyMem_Free(children);
12840 return NULL;
12841 }
12842 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12843 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012844 _PyPegen_insert_memo(p, start_mark, _loop0_53_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012845 return seq;
12846}
12847
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012848// _loop0_54: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012849static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012850_loop0_54_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012851{
12852 if (p->error_indicator) {
12853 return NULL;
12854 }
12855 void *res = NULL;
12856 int mark = p->mark;
12857 int start_mark = p->mark;
12858 void **children = PyMem_Malloc(sizeof(void *));
12859 if (!children) {
12860 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12861 return NULL;
12862 }
12863 ssize_t children_capacity = 1;
12864 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070012865 { // param_with_default
12866 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012867 while (
Guido van Rossumc001c092020-04-30 12:12:19 -070012868 (param_with_default_var = param_with_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012869 )
12870 {
Guido van Rossumc001c092020-04-30 12:12:19 -070012871 res = param_with_default_var;
12872 if (n == children_capacity) {
12873 children_capacity *= 2;
12874 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12875 if (!children) {
12876 PyErr_Format(PyExc_MemoryError, "realloc None");
12877 return NULL;
12878 }
12879 }
12880 children[n++] = res;
12881 mark = p->mark;
12882 }
12883 p->mark = mark;
12884 }
12885 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12886 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012887 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54");
Guido van Rossumc001c092020-04-30 12:12:19 -070012888 PyMem_Free(children);
12889 return NULL;
12890 }
12891 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12892 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012893 _PyPegen_insert_memo(p, start_mark, _loop0_54_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070012894 return seq;
12895}
12896
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012897// _loop0_55: param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070012898static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012899_loop0_55_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070012900{
12901 if (p->error_indicator) {
12902 return NULL;
12903 }
12904 void *res = NULL;
12905 int mark = p->mark;
12906 int start_mark = p->mark;
12907 void **children = PyMem_Malloc(sizeof(void *));
12908 if (!children) {
12909 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12910 return NULL;
12911 }
12912 ssize_t children_capacity = 1;
12913 ssize_t n = 0;
12914 { // param_with_default
12915 NameDefaultPair* param_with_default_var;
12916 while (
12917 (param_with_default_var = param_with_default_rule(p))
12918 )
12919 {
12920 res = param_with_default_var;
12921 if (n == children_capacity) {
12922 children_capacity *= 2;
12923 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12924 if (!children) {
12925 PyErr_Format(PyExc_MemoryError, "realloc None");
12926 return NULL;
12927 }
12928 }
12929 children[n++] = res;
12930 mark = p->mark;
12931 }
12932 p->mark = mark;
12933 }
12934 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12935 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012936 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55");
Guido van Rossumc001c092020-04-30 12:12:19 -070012937 PyMem_Free(children);
12938 return NULL;
12939 }
12940 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12941 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012942 _PyPegen_insert_memo(p, start_mark, _loop0_55_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070012943 return seq;
12944}
12945
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012946// _loop1_56: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070012947static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012948_loop1_56_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070012949{
12950 if (p->error_indicator) {
12951 return NULL;
12952 }
12953 void *res = NULL;
12954 int mark = p->mark;
12955 int start_mark = p->mark;
12956 void **children = PyMem_Malloc(sizeof(void *));
12957 if (!children) {
12958 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12959 return NULL;
12960 }
12961 ssize_t children_capacity = 1;
12962 ssize_t n = 0;
12963 { // param_no_default
12964 arg_ty param_no_default_var;
12965 while (
12966 (param_no_default_var = param_no_default_rule(p))
12967 )
12968 {
12969 res = param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012970 if (n == children_capacity) {
12971 children_capacity *= 2;
12972 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12973 if (!children) {
12974 PyErr_Format(PyExc_MemoryError, "realloc None");
12975 return NULL;
12976 }
12977 }
12978 children[n++] = res;
12979 mark = p->mark;
12980 }
12981 p->mark = mark;
12982 }
12983 if (n == 0) {
12984 PyMem_Free(children);
12985 return NULL;
12986 }
12987 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12988 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012989 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012990 PyMem_Free(children);
12991 return NULL;
12992 }
12993 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12994 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012995 _PyPegen_insert_memo(p, start_mark, _loop1_56_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012996 return seq;
12997}
12998
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012999// _loop0_57: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013000static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013001_loop0_57_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013002{
13003 if (p->error_indicator) {
13004 return NULL;
13005 }
13006 void *res = NULL;
13007 int mark = p->mark;
13008 int start_mark = p->mark;
13009 void **children = PyMem_Malloc(sizeof(void *));
13010 if (!children) {
13011 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13012 return NULL;
13013 }
13014 ssize_t children_capacity = 1;
13015 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013016 { // param_with_default
13017 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013018 while (
Guido van Rossumc001c092020-04-30 12:12:19 -070013019 (param_with_default_var = param_with_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013020 )
13021 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013022 res = param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013023 if (n == children_capacity) {
13024 children_capacity *= 2;
13025 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13026 if (!children) {
13027 PyErr_Format(PyExc_MemoryError, "realloc None");
13028 return NULL;
13029 }
13030 }
13031 children[n++] = res;
13032 mark = p->mark;
13033 }
13034 p->mark = mark;
13035 }
13036 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13037 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013038 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013039 PyMem_Free(children);
13040 return NULL;
13041 }
13042 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13043 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013044 _PyPegen_insert_memo(p, start_mark, _loop0_57_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013045 return seq;
13046}
13047
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013048// _loop1_58: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013049static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013050_loop1_58_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013051{
13052 if (p->error_indicator) {
13053 return NULL;
13054 }
13055 void *res = NULL;
13056 int mark = p->mark;
13057 int start_mark = p->mark;
13058 void **children = PyMem_Malloc(sizeof(void *));
13059 if (!children) {
13060 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13061 return NULL;
13062 }
13063 ssize_t children_capacity = 1;
13064 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013065 { // param_with_default
13066 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013067 while (
Guido van Rossumc001c092020-04-30 12:12:19 -070013068 (param_with_default_var = param_with_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013069 )
13070 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013071 res = param_with_default_var;
13072 if (n == children_capacity) {
13073 children_capacity *= 2;
13074 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13075 if (!children) {
13076 PyErr_Format(PyExc_MemoryError, "realloc None");
13077 return NULL;
13078 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013079 }
Guido van Rossumc001c092020-04-30 12:12:19 -070013080 children[n++] = res;
13081 mark = p->mark;
13082 }
13083 p->mark = mark;
13084 }
13085 if (n == 0) {
13086 PyMem_Free(children);
13087 return NULL;
13088 }
13089 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13090 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013091 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58");
Guido van Rossumc001c092020-04-30 12:12:19 -070013092 PyMem_Free(children);
13093 return NULL;
13094 }
13095 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13096 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013097 _PyPegen_insert_memo(p, start_mark, _loop1_58_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013098 return seq;
13099}
13100
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013101// _loop1_59: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013102static asdl_seq *
13103_loop1_59_rule(Parser *p)
13104{
13105 if (p->error_indicator) {
13106 return NULL;
13107 }
13108 void *res = NULL;
13109 int mark = p->mark;
13110 int start_mark = p->mark;
13111 void **children = PyMem_Malloc(sizeof(void *));
13112 if (!children) {
13113 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13114 return NULL;
13115 }
13116 ssize_t children_capacity = 1;
13117 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013118 { // param_no_default
13119 arg_ty param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013120 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013121 (param_no_default_var = param_no_default_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070013122 )
13123 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013124 res = param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013125 if (n == children_capacity) {
13126 children_capacity *= 2;
13127 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13128 if (!children) {
13129 PyErr_Format(PyExc_MemoryError, "realloc None");
13130 return NULL;
13131 }
13132 }
13133 children[n++] = res;
13134 mark = p->mark;
13135 }
13136 p->mark = mark;
13137 }
13138 if (n == 0) {
13139 PyMem_Free(children);
13140 return NULL;
13141 }
13142 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13143 if (!seq) {
13144 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59");
13145 PyMem_Free(children);
13146 return NULL;
13147 }
13148 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13149 PyMem_Free(children);
13150 _PyPegen_insert_memo(p, start_mark, _loop1_59_type, seq);
13151 return seq;
13152}
13153
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013154// _loop1_60: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013155static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013156_loop1_60_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013157{
13158 if (p->error_indicator) {
13159 return NULL;
13160 }
13161 void *res = NULL;
13162 int mark = p->mark;
13163 int start_mark = p->mark;
13164 void **children = PyMem_Malloc(sizeof(void *));
13165 if (!children) {
13166 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13167 return NULL;
13168 }
13169 ssize_t children_capacity = 1;
13170 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013171 { // param_no_default
13172 arg_ty param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013173 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013174 (param_no_default_var = param_no_default_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070013175 )
13176 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013177 res = param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013178 if (n == children_capacity) {
13179 children_capacity *= 2;
13180 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13181 if (!children) {
13182 PyErr_Format(PyExc_MemoryError, "realloc None");
13183 return NULL;
13184 }
13185 }
13186 children[n++] = res;
13187 mark = p->mark;
13188 }
13189 p->mark = mark;
13190 }
13191 if (n == 0) {
13192 PyMem_Free(children);
13193 return NULL;
13194 }
13195 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13196 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013197 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60");
Guido van Rossumc001c092020-04-30 12:12:19 -070013198 PyMem_Free(children);
13199 return NULL;
13200 }
13201 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13202 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013203 _PyPegen_insert_memo(p, start_mark, _loop1_60_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013204 return seq;
13205}
13206
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013207// _loop0_61: param_no_default
13208static asdl_seq *
13209_loop0_61_rule(Parser *p)
13210{
13211 if (p->error_indicator) {
13212 return NULL;
13213 }
13214 void *res = NULL;
13215 int mark = p->mark;
13216 int start_mark = p->mark;
13217 void **children = PyMem_Malloc(sizeof(void *));
13218 if (!children) {
13219 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13220 return NULL;
13221 }
13222 ssize_t children_capacity = 1;
13223 ssize_t n = 0;
13224 { // param_no_default
13225 arg_ty param_no_default_var;
13226 while (
13227 (param_no_default_var = param_no_default_rule(p))
13228 )
13229 {
13230 res = param_no_default_var;
13231 if (n == children_capacity) {
13232 children_capacity *= 2;
13233 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13234 if (!children) {
13235 PyErr_Format(PyExc_MemoryError, "realloc None");
13236 return NULL;
13237 }
13238 }
13239 children[n++] = res;
13240 mark = p->mark;
13241 }
13242 p->mark = mark;
13243 }
13244 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13245 if (!seq) {
13246 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61");
13247 PyMem_Free(children);
13248 return NULL;
13249 }
13250 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13251 PyMem_Free(children);
13252 _PyPegen_insert_memo(p, start_mark, _loop0_61_type, seq);
13253 return seq;
13254}
13255
13256// _loop1_62: param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013257static asdl_seq *
13258_loop1_62_rule(Parser *p)
13259{
13260 if (p->error_indicator) {
13261 return NULL;
13262 }
13263 void *res = NULL;
13264 int mark = p->mark;
13265 int start_mark = p->mark;
13266 void **children = PyMem_Malloc(sizeof(void *));
13267 if (!children) {
13268 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13269 return NULL;
13270 }
13271 ssize_t children_capacity = 1;
13272 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013273 { // param_with_default
13274 NameDefaultPair* param_with_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013275 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013276 (param_with_default_var = param_with_default_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070013277 )
13278 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013279 res = param_with_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013280 if (n == children_capacity) {
13281 children_capacity *= 2;
13282 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13283 if (!children) {
13284 PyErr_Format(PyExc_MemoryError, "realloc None");
13285 return NULL;
13286 }
13287 }
13288 children[n++] = res;
13289 mark = p->mark;
13290 }
13291 p->mark = mark;
13292 }
13293 if (n == 0) {
13294 PyMem_Free(children);
13295 return NULL;
13296 }
13297 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13298 if (!seq) {
13299 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62");
13300 PyMem_Free(children);
13301 return NULL;
13302 }
13303 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13304 PyMem_Free(children);
13305 _PyPegen_insert_memo(p, start_mark, _loop1_62_type, seq);
13306 return seq;
13307}
13308
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013309// _loop0_63: param_no_default
13310static asdl_seq *
13311_loop0_63_rule(Parser *p)
13312{
13313 if (p->error_indicator) {
13314 return NULL;
13315 }
13316 void *res = NULL;
13317 int mark = p->mark;
13318 int start_mark = p->mark;
13319 void **children = PyMem_Malloc(sizeof(void *));
13320 if (!children) {
13321 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13322 return NULL;
13323 }
13324 ssize_t children_capacity = 1;
13325 ssize_t n = 0;
13326 { // param_no_default
13327 arg_ty param_no_default_var;
13328 while (
13329 (param_no_default_var = param_no_default_rule(p))
13330 )
13331 {
13332 res = param_no_default_var;
13333 if (n == children_capacity) {
13334 children_capacity *= 2;
13335 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13336 if (!children) {
13337 PyErr_Format(PyExc_MemoryError, "realloc None");
13338 return NULL;
13339 }
13340 }
13341 children[n++] = res;
13342 mark = p->mark;
13343 }
13344 p->mark = mark;
13345 }
13346 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13347 if (!seq) {
13348 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63");
13349 PyMem_Free(children);
13350 return NULL;
13351 }
13352 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13353 PyMem_Free(children);
13354 _PyPegen_insert_memo(p, start_mark, _loop0_63_type, seq);
13355 return seq;
13356}
13357
13358// _loop1_64: param_with_default
13359static asdl_seq *
13360_loop1_64_rule(Parser *p)
13361{
13362 if (p->error_indicator) {
13363 return NULL;
13364 }
13365 void *res = NULL;
13366 int mark = p->mark;
13367 int start_mark = p->mark;
13368 void **children = PyMem_Malloc(sizeof(void *));
13369 if (!children) {
13370 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13371 return NULL;
13372 }
13373 ssize_t children_capacity = 1;
13374 ssize_t n = 0;
13375 { // param_with_default
13376 NameDefaultPair* param_with_default_var;
13377 while (
13378 (param_with_default_var = param_with_default_rule(p))
13379 )
13380 {
13381 res = param_with_default_var;
13382 if (n == children_capacity) {
13383 children_capacity *= 2;
13384 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13385 if (!children) {
13386 PyErr_Format(PyExc_MemoryError, "realloc None");
13387 return NULL;
13388 }
13389 }
13390 children[n++] = res;
13391 mark = p->mark;
13392 }
13393 p->mark = mark;
13394 }
13395 if (n == 0) {
13396 PyMem_Free(children);
13397 return NULL;
13398 }
13399 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13400 if (!seq) {
13401 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64");
13402 PyMem_Free(children);
13403 return NULL;
13404 }
13405 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13406 PyMem_Free(children);
13407 _PyPegen_insert_memo(p, start_mark, _loop1_64_type, seq);
13408 return seq;
13409}
13410
13411// _loop0_65: param_maybe_default
13412static asdl_seq *
13413_loop0_65_rule(Parser *p)
13414{
13415 if (p->error_indicator) {
13416 return NULL;
13417 }
13418 void *res = NULL;
13419 int mark = p->mark;
13420 int start_mark = p->mark;
13421 void **children = PyMem_Malloc(sizeof(void *));
13422 if (!children) {
13423 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13424 return NULL;
13425 }
13426 ssize_t children_capacity = 1;
13427 ssize_t n = 0;
13428 { // param_maybe_default
13429 NameDefaultPair* param_maybe_default_var;
13430 while (
13431 (param_maybe_default_var = param_maybe_default_rule(p))
13432 )
13433 {
13434 res = param_maybe_default_var;
13435 if (n == children_capacity) {
13436 children_capacity *= 2;
13437 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13438 if (!children) {
13439 PyErr_Format(PyExc_MemoryError, "realloc None");
13440 return NULL;
13441 }
13442 }
13443 children[n++] = res;
13444 mark = p->mark;
13445 }
13446 p->mark = mark;
13447 }
13448 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13449 if (!seq) {
13450 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65");
13451 PyMem_Free(children);
13452 return NULL;
13453 }
13454 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13455 PyMem_Free(children);
13456 _PyPegen_insert_memo(p, start_mark, _loop0_65_type, seq);
13457 return seq;
13458}
13459
13460// _loop1_66: param_maybe_default
13461static asdl_seq *
13462_loop1_66_rule(Parser *p)
13463{
13464 if (p->error_indicator) {
13465 return NULL;
13466 }
13467 void *res = NULL;
13468 int mark = p->mark;
13469 int start_mark = p->mark;
13470 void **children = PyMem_Malloc(sizeof(void *));
13471 if (!children) {
13472 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13473 return NULL;
13474 }
13475 ssize_t children_capacity = 1;
13476 ssize_t n = 0;
13477 { // param_maybe_default
13478 NameDefaultPair* param_maybe_default_var;
13479 while (
13480 (param_maybe_default_var = param_maybe_default_rule(p))
13481 )
13482 {
13483 res = param_maybe_default_var;
13484 if (n == children_capacity) {
13485 children_capacity *= 2;
13486 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13487 if (!children) {
13488 PyErr_Format(PyExc_MemoryError, "realloc None");
13489 return NULL;
13490 }
13491 }
13492 children[n++] = res;
13493 mark = p->mark;
13494 }
13495 p->mark = mark;
13496 }
13497 if (n == 0) {
13498 PyMem_Free(children);
13499 return NULL;
13500 }
13501 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13502 if (!seq) {
13503 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66");
13504 PyMem_Free(children);
13505 return NULL;
13506 }
13507 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13508 PyMem_Free(children);
13509 _PyPegen_insert_memo(p, start_mark, _loop1_66_type, seq);
13510 return seq;
13511}
13512
13513// _loop1_67: ('@' named_expression NEWLINE)
13514static asdl_seq *
13515_loop1_67_rule(Parser *p)
13516{
13517 if (p->error_indicator) {
13518 return NULL;
13519 }
13520 void *res = NULL;
13521 int mark = p->mark;
13522 int start_mark = p->mark;
13523 void **children = PyMem_Malloc(sizeof(void *));
13524 if (!children) {
13525 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13526 return NULL;
13527 }
13528 ssize_t children_capacity = 1;
13529 ssize_t n = 0;
13530 { // ('@' named_expression NEWLINE)
13531 void *_tmp_139_var;
13532 while (
13533 (_tmp_139_var = _tmp_139_rule(p))
13534 )
13535 {
13536 res = _tmp_139_var;
13537 if (n == children_capacity) {
13538 children_capacity *= 2;
13539 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13540 if (!children) {
13541 PyErr_Format(PyExc_MemoryError, "realloc None");
13542 return NULL;
13543 }
13544 }
13545 children[n++] = res;
13546 mark = p->mark;
13547 }
13548 p->mark = mark;
13549 }
13550 if (n == 0) {
13551 PyMem_Free(children);
13552 return NULL;
13553 }
13554 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13555 if (!seq) {
13556 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67");
13557 PyMem_Free(children);
13558 return NULL;
13559 }
13560 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13561 PyMem_Free(children);
13562 _PyPegen_insert_memo(p, start_mark, _loop1_67_type, seq);
13563 return seq;
13564}
13565
13566// _tmp_68: '(' arguments? ')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013567static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013568_tmp_68_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013569{
13570 if (p->error_indicator) {
13571 return NULL;
13572 }
13573 void * res = NULL;
13574 int mark = p->mark;
13575 { // '(' arguments? ')'
13576 void *literal;
13577 void *literal_1;
13578 void *z;
13579 if (
13580 (literal = _PyPegen_expect_token(p, 7))
13581 &&
13582 (z = arguments_rule(p), 1)
13583 &&
13584 (literal_1 = _PyPegen_expect_token(p, 8))
13585 )
13586 {
13587 res = z;
13588 if (res == NULL && PyErr_Occurred()) {
13589 p->error_indicator = 1;
13590 return NULL;
13591 }
13592 goto done;
13593 }
13594 p->mark = mark;
13595 }
13596 res = NULL;
13597 done:
13598 return res;
13599}
13600
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013601// _loop0_70: ',' star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013602static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013603_loop0_70_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013604{
13605 if (p->error_indicator) {
13606 return NULL;
13607 }
13608 void *res = NULL;
13609 int mark = p->mark;
13610 int start_mark = p->mark;
13611 void **children = PyMem_Malloc(sizeof(void *));
13612 if (!children) {
13613 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13614 return NULL;
13615 }
13616 ssize_t children_capacity = 1;
13617 ssize_t n = 0;
13618 { // ',' star_expression
13619 expr_ty elem;
13620 void *literal;
13621 while (
13622 (literal = _PyPegen_expect_token(p, 12))
13623 &&
13624 (elem = star_expression_rule(p))
13625 )
13626 {
13627 res = elem;
13628 if (res == NULL && PyErr_Occurred()) {
13629 p->error_indicator = 1;
13630 PyMem_Free(children);
13631 return NULL;
13632 }
13633 if (n == children_capacity) {
13634 children_capacity *= 2;
13635 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13636 if (!children) {
13637 PyErr_Format(PyExc_MemoryError, "realloc None");
13638 return NULL;
13639 }
13640 }
13641 children[n++] = res;
13642 mark = p->mark;
13643 }
13644 p->mark = mark;
13645 }
13646 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13647 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013648 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013649 PyMem_Free(children);
13650 return NULL;
13651 }
13652 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13653 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013654 _PyPegen_insert_memo(p, start_mark, _loop0_70_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013655 return seq;
13656}
13657
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013658// _gather_69: star_expression _loop0_70
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013659static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013660_gather_69_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013661{
13662 if (p->error_indicator) {
13663 return NULL;
13664 }
13665 asdl_seq * res = NULL;
13666 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013667 { // star_expression _loop0_70
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013668 expr_ty elem;
13669 asdl_seq * seq;
13670 if (
13671 (elem = star_expression_rule(p))
13672 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013673 (seq = _loop0_70_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013674 )
13675 {
13676 res = _PyPegen_seq_insert_in_front(p, elem, seq);
13677 goto done;
13678 }
13679 p->mark = mark;
13680 }
13681 res = NULL;
13682 done:
13683 return res;
13684}
13685
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013686// _loop1_71: (',' star_expression)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013687static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013688_loop1_71_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013689{
13690 if (p->error_indicator) {
13691 return NULL;
13692 }
13693 void *res = NULL;
13694 int mark = p->mark;
13695 int start_mark = p->mark;
13696 void **children = PyMem_Malloc(sizeof(void *));
13697 if (!children) {
13698 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13699 return NULL;
13700 }
13701 ssize_t children_capacity = 1;
13702 ssize_t n = 0;
13703 { // (',' star_expression)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013704 void *_tmp_140_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013705 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013706 (_tmp_140_var = _tmp_140_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013707 )
13708 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013709 res = _tmp_140_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013710 if (n == children_capacity) {
13711 children_capacity *= 2;
13712 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13713 if (!children) {
13714 PyErr_Format(PyExc_MemoryError, "realloc None");
13715 return NULL;
13716 }
13717 }
13718 children[n++] = res;
13719 mark = p->mark;
13720 }
13721 p->mark = mark;
13722 }
13723 if (n == 0) {
13724 PyMem_Free(children);
13725 return NULL;
13726 }
13727 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13728 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013729 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013730 PyMem_Free(children);
13731 return NULL;
13732 }
13733 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13734 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013735 _PyPegen_insert_memo(p, start_mark, _loop1_71_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013736 return seq;
13737}
13738
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013739// _loop0_73: ',' star_named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013740static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013741_loop0_73_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013742{
13743 if (p->error_indicator) {
13744 return NULL;
13745 }
13746 void *res = NULL;
13747 int mark = p->mark;
13748 int start_mark = p->mark;
13749 void **children = PyMem_Malloc(sizeof(void *));
13750 if (!children) {
13751 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13752 return NULL;
13753 }
13754 ssize_t children_capacity = 1;
13755 ssize_t n = 0;
13756 { // ',' star_named_expression
13757 expr_ty elem;
13758 void *literal;
13759 while (
13760 (literal = _PyPegen_expect_token(p, 12))
13761 &&
13762 (elem = star_named_expression_rule(p))
13763 )
13764 {
13765 res = elem;
13766 if (res == NULL && PyErr_Occurred()) {
13767 p->error_indicator = 1;
13768 PyMem_Free(children);
13769 return NULL;
13770 }
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 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13785 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013786 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013787 PyMem_Free(children);
13788 return NULL;
13789 }
13790 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13791 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013792 _PyPegen_insert_memo(p, start_mark, _loop0_73_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013793 return seq;
13794}
13795
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013796// _gather_72: star_named_expression _loop0_73
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013797static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013798_gather_72_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013799{
13800 if (p->error_indicator) {
13801 return NULL;
13802 }
13803 asdl_seq * res = NULL;
13804 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013805 { // star_named_expression _loop0_73
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013806 expr_ty elem;
13807 asdl_seq * seq;
13808 if (
13809 (elem = star_named_expression_rule(p))
13810 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013811 (seq = _loop0_73_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013812 )
13813 {
13814 res = _PyPegen_seq_insert_in_front(p, elem, seq);
13815 goto done;
13816 }
13817 p->mark = mark;
13818 }
13819 res = NULL;
13820 done:
13821 return res;
13822}
13823
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013824// _loop1_74: (',' expression)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013825static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013826_loop1_74_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013827{
13828 if (p->error_indicator) {
13829 return NULL;
13830 }
13831 void *res = NULL;
13832 int mark = p->mark;
13833 int start_mark = p->mark;
13834 void **children = PyMem_Malloc(sizeof(void *));
13835 if (!children) {
13836 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13837 return NULL;
13838 }
13839 ssize_t children_capacity = 1;
13840 ssize_t n = 0;
13841 { // (',' expression)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013842 void *_tmp_141_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013843 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013844 (_tmp_141_var = _tmp_141_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013845 )
13846 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013847 res = _tmp_141_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013848 if (n == children_capacity) {
13849 children_capacity *= 2;
13850 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13851 if (!children) {
13852 PyErr_Format(PyExc_MemoryError, "realloc None");
13853 return NULL;
13854 }
13855 }
13856 children[n++] = res;
13857 mark = p->mark;
13858 }
13859 p->mark = mark;
13860 }
13861 if (n == 0) {
13862 PyMem_Free(children);
13863 return NULL;
13864 }
13865 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13866 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013867 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013868 PyMem_Free(children);
13869 return NULL;
13870 }
13871 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13872 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013873 _PyPegen_insert_memo(p, start_mark, _loop1_74_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013874 return seq;
13875}
13876
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013877// _tmp_75: ',' lambda_plain_names
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013878static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013879_tmp_75_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013880{
13881 if (p->error_indicator) {
13882 return NULL;
13883 }
13884 void * res = NULL;
13885 int mark = p->mark;
13886 { // ',' lambda_plain_names
13887 void *literal;
13888 asdl_seq* x;
13889 if (
13890 (literal = _PyPegen_expect_token(p, 12))
13891 &&
13892 (x = lambda_plain_names_rule(p))
13893 )
13894 {
13895 res = x;
13896 if (res == NULL && PyErr_Occurred()) {
13897 p->error_indicator = 1;
13898 return NULL;
13899 }
13900 goto done;
13901 }
13902 p->mark = mark;
13903 }
13904 res = NULL;
13905 done:
13906 return res;
13907}
13908
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013909// _tmp_76: ',' lambda_names_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013910static void *
13911_tmp_76_rule(Parser *p)
13912{
13913 if (p->error_indicator) {
13914 return NULL;
13915 }
13916 void * res = NULL;
13917 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013918 { // ',' lambda_names_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013919 void *literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013920 asdl_seq* y;
Guido van Rossumc001c092020-04-30 12:12:19 -070013921 if (
13922 (literal = _PyPegen_expect_token(p, 12))
13923 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013924 (y = lambda_names_with_default_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070013925 )
13926 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013927 res = y;
Guido van Rossumc001c092020-04-30 12:12:19 -070013928 if (res == NULL && PyErr_Occurred()) {
13929 p->error_indicator = 1;
13930 return NULL;
13931 }
13932 goto done;
13933 }
13934 p->mark = mark;
13935 }
13936 res = NULL;
13937 done:
13938 return res;
13939}
13940
13941// _tmp_77: ',' lambda_star_etc?
13942static void *
13943_tmp_77_rule(Parser *p)
13944{
13945 if (p->error_indicator) {
13946 return NULL;
13947 }
13948 void * res = NULL;
13949 int mark = p->mark;
13950 { // ',' lambda_star_etc?
13951 void *literal;
13952 void *z;
13953 if (
13954 (literal = _PyPegen_expect_token(p, 12))
13955 &&
13956 (z = lambda_star_etc_rule(p), 1)
13957 )
13958 {
13959 res = z;
13960 if (res == NULL && PyErr_Occurred()) {
13961 p->error_indicator = 1;
13962 return NULL;
13963 }
13964 goto done;
13965 }
13966 p->mark = mark;
13967 }
13968 res = NULL;
13969 done:
13970 return res;
13971}
13972
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013973// _tmp_78: ',' lambda_names_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013974static void *
13975_tmp_78_rule(Parser *p)
13976{
13977 if (p->error_indicator) {
13978 return NULL;
13979 }
13980 void * res = NULL;
13981 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013982 { // ',' lambda_names_with_default
13983 void *literal;
13984 asdl_seq* y;
13985 if (
13986 (literal = _PyPegen_expect_token(p, 12))
13987 &&
13988 (y = lambda_names_with_default_rule(p))
13989 )
13990 {
13991 res = y;
13992 if (res == NULL && PyErr_Occurred()) {
13993 p->error_indicator = 1;
13994 return NULL;
13995 }
13996 goto done;
13997 }
13998 p->mark = mark;
13999 }
14000 res = NULL;
14001 done:
14002 return res;
14003}
14004
14005// _tmp_79: ',' lambda_star_etc?
14006static void *
14007_tmp_79_rule(Parser *p)
14008{
14009 if (p->error_indicator) {
14010 return NULL;
14011 }
14012 void * res = NULL;
14013 int mark = p->mark;
14014 { // ',' lambda_star_etc?
14015 void *literal;
14016 void *z;
14017 if (
14018 (literal = _PyPegen_expect_token(p, 12))
14019 &&
14020 (z = lambda_star_etc_rule(p), 1)
14021 )
14022 {
14023 res = z;
14024 if (res == NULL && PyErr_Occurred()) {
14025 p->error_indicator = 1;
14026 return NULL;
14027 }
14028 goto done;
14029 }
14030 p->mark = mark;
14031 }
14032 res = NULL;
14033 done:
14034 return res;
14035}
14036
14037// _tmp_80: ',' lambda_names_with_default
14038static void *
14039_tmp_80_rule(Parser *p)
14040{
14041 if (p->error_indicator) {
14042 return NULL;
14043 }
14044 void * res = NULL;
14045 int mark = p->mark;
14046 { // ',' lambda_names_with_default
14047 void *literal;
14048 asdl_seq* y;
14049 if (
14050 (literal = _PyPegen_expect_token(p, 12))
14051 &&
14052 (y = lambda_names_with_default_rule(p))
14053 )
14054 {
14055 res = y;
14056 if (res == NULL && PyErr_Occurred()) {
14057 p->error_indicator = 1;
14058 return NULL;
14059 }
14060 goto done;
14061 }
14062 p->mark = mark;
14063 }
14064 res = NULL;
14065 done:
14066 return res;
14067}
14068
14069// _tmp_81: ',' lambda_star_etc?
14070static void *
14071_tmp_81_rule(Parser *p)
14072{
14073 if (p->error_indicator) {
14074 return NULL;
14075 }
14076 void * res = NULL;
14077 int mark = p->mark;
14078 { // ',' lambda_star_etc?
14079 void *literal;
14080 void *z;
14081 if (
14082 (literal = _PyPegen_expect_token(p, 12))
14083 &&
14084 (z = lambda_star_etc_rule(p), 1)
14085 )
14086 {
14087 res = z;
14088 if (res == NULL && PyErr_Occurred()) {
14089 p->error_indicator = 1;
14090 return NULL;
14091 }
14092 goto done;
14093 }
14094 p->mark = mark;
14095 }
14096 res = NULL;
14097 done:
14098 return res;
14099}
14100
14101// _tmp_82: ',' lambda_star_etc?
14102static void *
14103_tmp_82_rule(Parser *p)
14104{
14105 if (p->error_indicator) {
14106 return NULL;
14107 }
14108 void * res = NULL;
14109 int mark = p->mark;
14110 { // ',' lambda_star_etc?
14111 void *literal;
14112 void *z;
14113 if (
14114 (literal = _PyPegen_expect_token(p, 12))
14115 &&
14116 (z = lambda_star_etc_rule(p), 1)
14117 )
14118 {
14119 res = z;
14120 if (res == NULL && PyErr_Occurred()) {
14121 p->error_indicator = 1;
14122 return NULL;
14123 }
14124 goto done;
14125 }
14126 p->mark = mark;
14127 }
14128 res = NULL;
14129 done:
14130 return res;
14131}
14132
14133// _tmp_83: lambda_plain_names ','
14134static void *
14135_tmp_83_rule(Parser *p)
14136{
14137 if (p->error_indicator) {
14138 return NULL;
14139 }
14140 void * res = NULL;
14141 int mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014142 { // lambda_plain_names ','
14143 void *literal;
14144 asdl_seq* n;
14145 if (
14146 (n = lambda_plain_names_rule(p))
14147 &&
14148 (literal = _PyPegen_expect_token(p, 12))
14149 )
14150 {
14151 res = n;
14152 if (res == NULL && PyErr_Occurred()) {
14153 p->error_indicator = 1;
14154 return NULL;
14155 }
14156 goto done;
14157 }
14158 p->mark = mark;
14159 }
14160 res = NULL;
14161 done:
14162 return res;
14163}
14164
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014165// _loop0_84: lambda_name_with_optional_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014166static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014167_loop0_84_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014168{
14169 if (p->error_indicator) {
14170 return NULL;
14171 }
14172 void *res = NULL;
14173 int mark = p->mark;
14174 int start_mark = p->mark;
14175 void **children = PyMem_Malloc(sizeof(void *));
14176 if (!children) {
14177 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14178 return NULL;
14179 }
14180 ssize_t children_capacity = 1;
14181 ssize_t n = 0;
14182 { // lambda_name_with_optional_default
14183 NameDefaultPair* lambda_name_with_optional_default_var;
14184 while (
14185 (lambda_name_with_optional_default_var = lambda_name_with_optional_default_rule(p))
14186 )
14187 {
14188 res = lambda_name_with_optional_default_var;
14189 if (n == children_capacity) {
14190 children_capacity *= 2;
14191 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14192 if (!children) {
14193 PyErr_Format(PyExc_MemoryError, "realloc None");
14194 return NULL;
14195 }
14196 }
14197 children[n++] = res;
14198 mark = p->mark;
14199 }
14200 p->mark = mark;
14201 }
14202 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14203 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014204 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_84");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014205 PyMem_Free(children);
14206 return NULL;
14207 }
14208 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14209 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014210 _PyPegen_insert_memo(p, start_mark, _loop0_84_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014211 return seq;
14212}
14213
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014214// _tmp_85: ',' lambda_kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014215static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014216_tmp_85_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014217{
14218 if (p->error_indicator) {
14219 return NULL;
14220 }
14221 void * res = NULL;
14222 int mark = p->mark;
14223 { // ',' lambda_kwds
14224 arg_ty d;
14225 void *literal;
14226 if (
14227 (literal = _PyPegen_expect_token(p, 12))
14228 &&
14229 (d = lambda_kwds_rule(p))
14230 )
14231 {
14232 res = d;
14233 if (res == NULL && PyErr_Occurred()) {
14234 p->error_indicator = 1;
14235 return NULL;
14236 }
14237 goto done;
14238 }
14239 p->mark = mark;
14240 }
14241 res = NULL;
14242 done:
14243 return res;
14244}
14245
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014246// _loop1_86: lambda_name_with_optional_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014247static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014248_loop1_86_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014249{
14250 if (p->error_indicator) {
14251 return NULL;
14252 }
14253 void *res = NULL;
14254 int mark = p->mark;
14255 int start_mark = p->mark;
14256 void **children = PyMem_Malloc(sizeof(void *));
14257 if (!children) {
14258 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14259 return NULL;
14260 }
14261 ssize_t children_capacity = 1;
14262 ssize_t n = 0;
14263 { // lambda_name_with_optional_default
14264 NameDefaultPair* lambda_name_with_optional_default_var;
14265 while (
14266 (lambda_name_with_optional_default_var = lambda_name_with_optional_default_rule(p))
14267 )
14268 {
14269 res = lambda_name_with_optional_default_var;
14270 if (n == children_capacity) {
14271 children_capacity *= 2;
14272 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14273 if (!children) {
14274 PyErr_Format(PyExc_MemoryError, "realloc None");
14275 return NULL;
14276 }
14277 }
14278 children[n++] = res;
14279 mark = p->mark;
14280 }
14281 p->mark = mark;
14282 }
14283 if (n == 0) {
14284 PyMem_Free(children);
14285 return NULL;
14286 }
14287 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14288 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014289 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014290 PyMem_Free(children);
14291 return NULL;
14292 }
14293 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14294 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014295 _PyPegen_insert_memo(p, start_mark, _loop1_86_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014296 return seq;
14297}
14298
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014299// _tmp_87: ',' lambda_kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014300static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014301_tmp_87_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014302{
14303 if (p->error_indicator) {
14304 return NULL;
14305 }
14306 void * res = NULL;
14307 int mark = p->mark;
14308 { // ',' lambda_kwds
14309 arg_ty d;
14310 void *literal;
14311 if (
14312 (literal = _PyPegen_expect_token(p, 12))
14313 &&
14314 (d = lambda_kwds_rule(p))
14315 )
14316 {
14317 res = d;
14318 if (res == NULL && PyErr_Occurred()) {
14319 p->error_indicator = 1;
14320 return NULL;
14321 }
14322 goto done;
14323 }
14324 p->mark = mark;
14325 }
14326 res = NULL;
14327 done:
14328 return res;
14329}
14330
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014331// _tmp_88: '=' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014332static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014333_tmp_88_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014334{
14335 if (p->error_indicator) {
14336 return NULL;
14337 }
14338 void * res = NULL;
14339 int mark = p->mark;
14340 { // '=' expression
14341 expr_ty e;
14342 void *literal;
14343 if (
14344 (literal = _PyPegen_expect_token(p, 22))
14345 &&
14346 (e = expression_rule(p))
14347 )
14348 {
14349 res = e;
14350 if (res == NULL && PyErr_Occurred()) {
14351 p->error_indicator = 1;
14352 return NULL;
14353 }
14354 goto done;
14355 }
14356 p->mark = mark;
14357 }
14358 res = NULL;
14359 done:
14360 return res;
14361}
14362
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014363// _loop0_90: ',' lambda_name_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014364static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014365_loop0_90_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014366{
14367 if (p->error_indicator) {
14368 return NULL;
14369 }
14370 void *res = NULL;
14371 int mark = p->mark;
14372 int start_mark = p->mark;
14373 void **children = PyMem_Malloc(sizeof(void *));
14374 if (!children) {
14375 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14376 return NULL;
14377 }
14378 ssize_t children_capacity = 1;
14379 ssize_t n = 0;
14380 { // ',' lambda_name_with_default
14381 NameDefaultPair* elem;
14382 void *literal;
14383 while (
14384 (literal = _PyPegen_expect_token(p, 12))
14385 &&
14386 (elem = lambda_name_with_default_rule(p))
14387 )
14388 {
14389 res = elem;
14390 if (res == NULL && PyErr_Occurred()) {
14391 p->error_indicator = 1;
14392 PyMem_Free(children);
14393 return NULL;
14394 }
14395 if (n == children_capacity) {
14396 children_capacity *= 2;
14397 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14398 if (!children) {
14399 PyErr_Format(PyExc_MemoryError, "realloc None");
14400 return NULL;
14401 }
14402 }
14403 children[n++] = res;
14404 mark = p->mark;
14405 }
14406 p->mark = mark;
14407 }
14408 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14409 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014410 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_90");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014411 PyMem_Free(children);
14412 return NULL;
14413 }
14414 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14415 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014416 _PyPegen_insert_memo(p, start_mark, _loop0_90_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014417 return seq;
14418}
14419
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014420// _gather_89: lambda_name_with_default _loop0_90
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014421static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014422_gather_89_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014423{
14424 if (p->error_indicator) {
14425 return NULL;
14426 }
14427 asdl_seq * res = NULL;
14428 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014429 { // lambda_name_with_default _loop0_90
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014430 NameDefaultPair* elem;
14431 asdl_seq * seq;
14432 if (
14433 (elem = lambda_name_with_default_rule(p))
14434 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014435 (seq = _loop0_90_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014436 )
14437 {
14438 res = _PyPegen_seq_insert_in_front(p, elem, seq);
14439 goto done;
14440 }
14441 p->mark = mark;
14442 }
14443 res = NULL;
14444 done:
14445 return res;
14446}
14447
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014448// _loop0_92: ',' (lambda_plain_name !'=')
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014449static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014450_loop0_92_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014451{
14452 if (p->error_indicator) {
14453 return NULL;
14454 }
14455 void *res = NULL;
14456 int mark = p->mark;
14457 int start_mark = p->mark;
14458 void **children = PyMem_Malloc(sizeof(void *));
14459 if (!children) {
14460 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14461 return NULL;
14462 }
14463 ssize_t children_capacity = 1;
14464 ssize_t n = 0;
14465 { // ',' (lambda_plain_name !'=')
14466 void *elem;
14467 void *literal;
14468 while (
14469 (literal = _PyPegen_expect_token(p, 12))
14470 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014471 (elem = _tmp_142_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014472 )
14473 {
14474 res = elem;
14475 if (res == NULL && PyErr_Occurred()) {
14476 p->error_indicator = 1;
14477 PyMem_Free(children);
14478 return NULL;
14479 }
14480 if (n == children_capacity) {
14481 children_capacity *= 2;
14482 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14483 if (!children) {
14484 PyErr_Format(PyExc_MemoryError, "realloc None");
14485 return NULL;
14486 }
14487 }
14488 children[n++] = res;
14489 mark = p->mark;
14490 }
14491 p->mark = mark;
14492 }
14493 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14494 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014495 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_92");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014496 PyMem_Free(children);
14497 return NULL;
14498 }
14499 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14500 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014501 _PyPegen_insert_memo(p, start_mark, _loop0_92_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014502 return seq;
14503}
14504
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014505// _gather_91: (lambda_plain_name !'=') _loop0_92
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014506static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014507_gather_91_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014508{
14509 if (p->error_indicator) {
14510 return NULL;
14511 }
14512 asdl_seq * res = NULL;
14513 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014514 { // (lambda_plain_name !'=') _loop0_92
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014515 void *elem;
14516 asdl_seq * seq;
14517 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014518 (elem = _tmp_142_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014519 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014520 (seq = _loop0_92_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014521 )
14522 {
14523 res = _PyPegen_seq_insert_in_front(p, elem, seq);
14524 goto done;
14525 }
14526 p->mark = mark;
14527 }
14528 res = NULL;
14529 done:
14530 return res;
14531}
14532
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014533// _loop1_93: ('or' conjunction)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014534static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014535_loop1_93_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014536{
14537 if (p->error_indicator) {
14538 return NULL;
14539 }
14540 void *res = NULL;
14541 int mark = p->mark;
14542 int start_mark = p->mark;
14543 void **children = PyMem_Malloc(sizeof(void *));
14544 if (!children) {
14545 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14546 return NULL;
14547 }
14548 ssize_t children_capacity = 1;
14549 ssize_t n = 0;
14550 { // ('or' conjunction)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014551 void *_tmp_143_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014552 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014553 (_tmp_143_var = _tmp_143_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014554 )
14555 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014556 res = _tmp_143_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014557 if (n == children_capacity) {
14558 children_capacity *= 2;
14559 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14560 if (!children) {
14561 PyErr_Format(PyExc_MemoryError, "realloc None");
14562 return NULL;
14563 }
14564 }
14565 children[n++] = res;
14566 mark = p->mark;
14567 }
14568 p->mark = mark;
14569 }
14570 if (n == 0) {
14571 PyMem_Free(children);
14572 return NULL;
14573 }
14574 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14575 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014576 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_93");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014577 PyMem_Free(children);
14578 return NULL;
14579 }
14580 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14581 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014582 _PyPegen_insert_memo(p, start_mark, _loop1_93_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014583 return seq;
14584}
14585
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014586// _loop1_94: ('and' inversion)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014587static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014588_loop1_94_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014589{
14590 if (p->error_indicator) {
14591 return NULL;
14592 }
14593 void *res = NULL;
14594 int mark = p->mark;
14595 int start_mark = p->mark;
14596 void **children = PyMem_Malloc(sizeof(void *));
14597 if (!children) {
14598 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14599 return NULL;
14600 }
14601 ssize_t children_capacity = 1;
14602 ssize_t n = 0;
14603 { // ('and' inversion)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014604 void *_tmp_144_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014605 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014606 (_tmp_144_var = _tmp_144_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014607 )
14608 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014609 res = _tmp_144_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014610 if (n == children_capacity) {
14611 children_capacity *= 2;
14612 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14613 if (!children) {
14614 PyErr_Format(PyExc_MemoryError, "realloc None");
14615 return NULL;
14616 }
14617 }
14618 children[n++] = res;
14619 mark = p->mark;
14620 }
14621 p->mark = mark;
14622 }
14623 if (n == 0) {
14624 PyMem_Free(children);
14625 return NULL;
14626 }
14627 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14628 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014629 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_94");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014630 PyMem_Free(children);
14631 return NULL;
14632 }
14633 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14634 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014635 _PyPegen_insert_memo(p, start_mark, _loop1_94_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014636 return seq;
14637}
14638
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014639// _loop1_95: compare_op_bitwise_or_pair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014640static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014641_loop1_95_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014642{
14643 if (p->error_indicator) {
14644 return NULL;
14645 }
14646 void *res = NULL;
14647 int mark = p->mark;
14648 int start_mark = p->mark;
14649 void **children = PyMem_Malloc(sizeof(void *));
14650 if (!children) {
14651 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14652 return NULL;
14653 }
14654 ssize_t children_capacity = 1;
14655 ssize_t n = 0;
14656 { // compare_op_bitwise_or_pair
14657 CmpopExprPair* compare_op_bitwise_or_pair_var;
14658 while (
14659 (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p))
14660 )
14661 {
14662 res = compare_op_bitwise_or_pair_var;
14663 if (n == children_capacity) {
14664 children_capacity *= 2;
14665 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14666 if (!children) {
14667 PyErr_Format(PyExc_MemoryError, "realloc None");
14668 return NULL;
14669 }
14670 }
14671 children[n++] = res;
14672 mark = p->mark;
14673 }
14674 p->mark = mark;
14675 }
14676 if (n == 0) {
14677 PyMem_Free(children);
14678 return NULL;
14679 }
14680 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14681 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014682 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_95");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014683 PyMem_Free(children);
14684 return NULL;
14685 }
14686 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14687 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014688 _PyPegen_insert_memo(p, start_mark, _loop1_95_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014689 return seq;
14690}
14691
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014692// _tmp_96: '!='
Pablo Galindo2b74c832020-04-27 18:02:07 +010014693static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014694_tmp_96_rule(Parser *p)
Pablo Galindo2b74c832020-04-27 18:02:07 +010014695{
14696 if (p->error_indicator) {
14697 return NULL;
14698 }
14699 void * res = NULL;
14700 int mark = p->mark;
14701 { // '!='
14702 void *tok;
14703 if (
14704 (tok = _PyPegen_expect_token(p, 28))
14705 )
14706 {
14707 res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok;
14708 if (res == NULL && PyErr_Occurred()) {
14709 p->error_indicator = 1;
14710 return NULL;
14711 }
14712 goto done;
14713 }
14714 p->mark = mark;
14715 }
14716 res = NULL;
14717 done:
14718 return res;
14719}
14720
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014721// _loop0_98: ',' slice
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014722static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014723_loop0_98_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014724{
14725 if (p->error_indicator) {
14726 return NULL;
14727 }
14728 void *res = NULL;
14729 int mark = p->mark;
14730 int start_mark = p->mark;
14731 void **children = PyMem_Malloc(sizeof(void *));
14732 if (!children) {
14733 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14734 return NULL;
14735 }
14736 ssize_t children_capacity = 1;
14737 ssize_t n = 0;
14738 { // ',' slice
14739 expr_ty elem;
14740 void *literal;
14741 while (
14742 (literal = _PyPegen_expect_token(p, 12))
14743 &&
14744 (elem = slice_rule(p))
14745 )
14746 {
14747 res = elem;
14748 if (res == NULL && PyErr_Occurred()) {
14749 p->error_indicator = 1;
14750 PyMem_Free(children);
14751 return NULL;
14752 }
14753 if (n == children_capacity) {
14754 children_capacity *= 2;
14755 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14756 if (!children) {
14757 PyErr_Format(PyExc_MemoryError, "realloc None");
14758 return NULL;
14759 }
14760 }
14761 children[n++] = res;
14762 mark = p->mark;
14763 }
14764 p->mark = mark;
14765 }
14766 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14767 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014768 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_98");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014769 PyMem_Free(children);
14770 return NULL;
14771 }
14772 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14773 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014774 _PyPegen_insert_memo(p, start_mark, _loop0_98_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014775 return seq;
14776}
14777
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014778// _gather_97: slice _loop0_98
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014779static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014780_gather_97_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014781{
14782 if (p->error_indicator) {
14783 return NULL;
14784 }
14785 asdl_seq * res = NULL;
14786 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014787 { // slice _loop0_98
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014788 expr_ty elem;
14789 asdl_seq * seq;
14790 if (
14791 (elem = slice_rule(p))
14792 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014793 (seq = _loop0_98_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014794 )
14795 {
14796 res = _PyPegen_seq_insert_in_front(p, elem, seq);
14797 goto done;
14798 }
14799 p->mark = mark;
14800 }
14801 res = NULL;
14802 done:
14803 return res;
14804}
14805
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014806// _tmp_99: ':' expression?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014807static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014808_tmp_99_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014809{
14810 if (p->error_indicator) {
14811 return NULL;
14812 }
14813 void * res = NULL;
14814 int mark = p->mark;
14815 { // ':' expression?
14816 void *d;
14817 void *literal;
14818 if (
14819 (literal = _PyPegen_expect_token(p, 11))
14820 &&
14821 (d = expression_rule(p), 1)
14822 )
14823 {
14824 res = d;
14825 if (res == NULL && PyErr_Occurred()) {
14826 p->error_indicator = 1;
14827 return NULL;
14828 }
14829 goto done;
14830 }
14831 p->mark = mark;
14832 }
14833 res = NULL;
14834 done:
14835 return res;
14836}
14837
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014838// _tmp_100: tuple | group | genexp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014839static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014840_tmp_100_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014841{
14842 if (p->error_indicator) {
14843 return NULL;
14844 }
14845 void * res = NULL;
14846 int mark = p->mark;
14847 { // tuple
14848 expr_ty tuple_var;
14849 if (
14850 (tuple_var = tuple_rule(p))
14851 )
14852 {
14853 res = tuple_var;
14854 goto done;
14855 }
14856 p->mark = mark;
14857 }
14858 { // group
14859 expr_ty group_var;
14860 if (
14861 (group_var = group_rule(p))
14862 )
14863 {
14864 res = group_var;
14865 goto done;
14866 }
14867 p->mark = mark;
14868 }
14869 { // genexp
14870 expr_ty genexp_var;
14871 if (
14872 (genexp_var = genexp_rule(p))
14873 )
14874 {
14875 res = genexp_var;
14876 goto done;
14877 }
14878 p->mark = mark;
14879 }
14880 res = NULL;
14881 done:
14882 return res;
14883}
14884
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014885// _tmp_101: list | listcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014886static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014887_tmp_101_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014888{
14889 if (p->error_indicator) {
14890 return NULL;
14891 }
14892 void * res = NULL;
14893 int mark = p->mark;
14894 { // list
14895 expr_ty list_var;
14896 if (
14897 (list_var = list_rule(p))
14898 )
14899 {
14900 res = list_var;
14901 goto done;
14902 }
14903 p->mark = mark;
14904 }
14905 { // listcomp
14906 expr_ty listcomp_var;
14907 if (
14908 (listcomp_var = listcomp_rule(p))
14909 )
14910 {
14911 res = listcomp_var;
14912 goto done;
14913 }
14914 p->mark = mark;
14915 }
14916 res = NULL;
14917 done:
14918 return res;
14919}
14920
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014921// _tmp_102: dict | set | dictcomp | setcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014922static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014923_tmp_102_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014924{
14925 if (p->error_indicator) {
14926 return NULL;
14927 }
14928 void * res = NULL;
14929 int mark = p->mark;
14930 { // dict
14931 expr_ty dict_var;
14932 if (
14933 (dict_var = dict_rule(p))
14934 )
14935 {
14936 res = dict_var;
14937 goto done;
14938 }
14939 p->mark = mark;
14940 }
14941 { // set
14942 expr_ty set_var;
14943 if (
14944 (set_var = set_rule(p))
14945 )
14946 {
14947 res = set_var;
14948 goto done;
14949 }
14950 p->mark = mark;
14951 }
14952 { // dictcomp
14953 expr_ty dictcomp_var;
14954 if (
14955 (dictcomp_var = dictcomp_rule(p))
14956 )
14957 {
14958 res = dictcomp_var;
14959 goto done;
14960 }
14961 p->mark = mark;
14962 }
14963 { // setcomp
14964 expr_ty setcomp_var;
14965 if (
14966 (setcomp_var = setcomp_rule(p))
14967 )
14968 {
14969 res = setcomp_var;
14970 goto done;
14971 }
14972 p->mark = mark;
14973 }
14974 res = NULL;
14975 done:
14976 return res;
14977}
14978
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014979// _loop1_103: STRING
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014980static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014981_loop1_103_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014982{
14983 if (p->error_indicator) {
14984 return NULL;
14985 }
14986 void *res = NULL;
14987 int mark = p->mark;
14988 int start_mark = p->mark;
14989 void **children = PyMem_Malloc(sizeof(void *));
14990 if (!children) {
14991 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14992 return NULL;
14993 }
14994 ssize_t children_capacity = 1;
14995 ssize_t n = 0;
14996 { // STRING
14997 expr_ty string_var;
14998 while (
14999 (string_var = _PyPegen_string_token(p))
15000 )
15001 {
15002 res = string_var;
15003 if (n == children_capacity) {
15004 children_capacity *= 2;
15005 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15006 if (!children) {
15007 PyErr_Format(PyExc_MemoryError, "realloc None");
15008 return NULL;
15009 }
15010 }
15011 children[n++] = res;
15012 mark = p->mark;
15013 }
15014 p->mark = mark;
15015 }
15016 if (n == 0) {
15017 PyMem_Free(children);
15018 return NULL;
15019 }
15020 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15021 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015022 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_103");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015023 PyMem_Free(children);
15024 return NULL;
15025 }
15026 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15027 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015028 _PyPegen_insert_memo(p, start_mark, _loop1_103_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015029 return seq;
15030}
15031
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015032// _tmp_104: star_named_expression ',' star_named_expressions?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015033static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015034_tmp_104_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015035{
15036 if (p->error_indicator) {
15037 return NULL;
15038 }
15039 void * res = NULL;
15040 int mark = p->mark;
15041 { // star_named_expression ',' star_named_expressions?
15042 void *literal;
15043 expr_ty y;
15044 void *z;
15045 if (
15046 (y = star_named_expression_rule(p))
15047 &&
15048 (literal = _PyPegen_expect_token(p, 12))
15049 &&
15050 (z = star_named_expressions_rule(p), 1)
15051 )
15052 {
15053 res = _PyPegen_seq_insert_in_front ( p , y , z );
15054 if (res == NULL && PyErr_Occurred()) {
15055 p->error_indicator = 1;
15056 return NULL;
15057 }
15058 goto done;
15059 }
15060 p->mark = mark;
15061 }
15062 res = NULL;
15063 done:
15064 return res;
15065}
15066
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015067// _tmp_105: yield_expr | named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015068static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015069_tmp_105_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015070{
15071 if (p->error_indicator) {
15072 return NULL;
15073 }
15074 void * res = NULL;
15075 int mark = p->mark;
15076 { // yield_expr
15077 expr_ty yield_expr_var;
15078 if (
15079 (yield_expr_var = yield_expr_rule(p))
15080 )
15081 {
15082 res = yield_expr_var;
15083 goto done;
15084 }
15085 p->mark = mark;
15086 }
15087 { // named_expression
15088 expr_ty named_expression_var;
15089 if (
15090 (named_expression_var = named_expression_rule(p))
15091 )
15092 {
15093 res = named_expression_var;
15094 goto done;
15095 }
15096 p->mark = mark;
15097 }
15098 res = NULL;
15099 done:
15100 return res;
15101}
15102
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015103// _loop0_107: ',' kvpair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015104static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015105_loop0_107_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015106{
15107 if (p->error_indicator) {
15108 return NULL;
15109 }
15110 void *res = NULL;
15111 int mark = p->mark;
15112 int start_mark = p->mark;
15113 void **children = PyMem_Malloc(sizeof(void *));
15114 if (!children) {
15115 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15116 return NULL;
15117 }
15118 ssize_t children_capacity = 1;
15119 ssize_t n = 0;
15120 { // ',' kvpair
15121 KeyValuePair* elem;
15122 void *literal;
15123 while (
15124 (literal = _PyPegen_expect_token(p, 12))
15125 &&
15126 (elem = kvpair_rule(p))
15127 )
15128 {
15129 res = elem;
15130 if (res == NULL && PyErr_Occurred()) {
15131 p->error_indicator = 1;
15132 PyMem_Free(children);
15133 return NULL;
15134 }
15135 if (n == children_capacity) {
15136 children_capacity *= 2;
15137 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15138 if (!children) {
15139 PyErr_Format(PyExc_MemoryError, "realloc None");
15140 return NULL;
15141 }
15142 }
15143 children[n++] = res;
15144 mark = p->mark;
15145 }
15146 p->mark = mark;
15147 }
15148 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15149 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015150 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_107");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015151 PyMem_Free(children);
15152 return NULL;
15153 }
15154 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15155 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015156 _PyPegen_insert_memo(p, start_mark, _loop0_107_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015157 return seq;
15158}
15159
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015160// _gather_106: kvpair _loop0_107
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015161static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015162_gather_106_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015163{
15164 if (p->error_indicator) {
15165 return NULL;
15166 }
15167 asdl_seq * res = NULL;
15168 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015169 { // kvpair _loop0_107
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015170 KeyValuePair* elem;
15171 asdl_seq * seq;
15172 if (
15173 (elem = kvpair_rule(p))
15174 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015175 (seq = _loop0_107_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015176 )
15177 {
15178 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15179 goto done;
15180 }
15181 p->mark = mark;
15182 }
15183 res = NULL;
15184 done:
15185 return res;
15186}
15187
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015188// _loop1_108: for_if_clause
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015189static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015190_loop1_108_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015191{
15192 if (p->error_indicator) {
15193 return NULL;
15194 }
15195 void *res = NULL;
15196 int mark = p->mark;
15197 int start_mark = p->mark;
15198 void **children = PyMem_Malloc(sizeof(void *));
15199 if (!children) {
15200 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15201 return NULL;
15202 }
15203 ssize_t children_capacity = 1;
15204 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015205 { // for_if_clause
15206 comprehension_ty for_if_clause_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015207 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015208 (for_if_clause_var = for_if_clause_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015209 )
15210 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015211 res = for_if_clause_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015212 if (n == children_capacity) {
15213 children_capacity *= 2;
15214 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15215 if (!children) {
15216 PyErr_Format(PyExc_MemoryError, "realloc None");
15217 return NULL;
15218 }
15219 }
15220 children[n++] = res;
15221 mark = p->mark;
15222 }
15223 p->mark = mark;
15224 }
15225 if (n == 0) {
15226 PyMem_Free(children);
15227 return NULL;
15228 }
15229 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15230 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015231 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_108");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015232 PyMem_Free(children);
15233 return NULL;
15234 }
15235 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15236 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015237 _PyPegen_insert_memo(p, start_mark, _loop1_108_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015238 return seq;
15239}
15240
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015241// _loop0_109: ('if' disjunction)
Pablo Galindo2b74c832020-04-27 18:02:07 +010015242static asdl_seq *
15243_loop0_109_rule(Parser *p)
15244{
15245 if (p->error_indicator) {
15246 return NULL;
15247 }
15248 void *res = NULL;
15249 int mark = p->mark;
15250 int start_mark = p->mark;
15251 void **children = PyMem_Malloc(sizeof(void *));
15252 if (!children) {
15253 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15254 return NULL;
15255 }
15256 ssize_t children_capacity = 1;
15257 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015258 { // ('if' disjunction)
15259 void *_tmp_145_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +010015260 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015261 (_tmp_145_var = _tmp_145_rule(p))
Pablo Galindo2b74c832020-04-27 18:02:07 +010015262 )
15263 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015264 res = _tmp_145_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +010015265 if (n == children_capacity) {
15266 children_capacity *= 2;
15267 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15268 if (!children) {
15269 PyErr_Format(PyExc_MemoryError, "realloc None");
15270 return NULL;
15271 }
15272 }
15273 children[n++] = res;
15274 mark = p->mark;
15275 }
15276 p->mark = mark;
15277 }
15278 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15279 if (!seq) {
15280 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_109");
15281 PyMem_Free(children);
15282 return NULL;
15283 }
15284 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15285 PyMem_Free(children);
15286 _PyPegen_insert_memo(p, start_mark, _loop0_109_type, seq);
15287 return seq;
15288}
15289
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015290// _loop0_110: ('if' disjunction)
Guido van Rossumc001c092020-04-30 12:12:19 -070015291static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015292_loop0_110_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015293{
15294 if (p->error_indicator) {
15295 return NULL;
15296 }
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015297 void *res = NULL;
Guido van Rossumc001c092020-04-30 12:12:19 -070015298 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015299 int start_mark = p->mark;
15300 void **children = PyMem_Malloc(sizeof(void *));
15301 if (!children) {
15302 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15303 return NULL;
15304 }
15305 ssize_t children_capacity = 1;
15306 ssize_t n = 0;
15307 { // ('if' disjunction)
15308 void *_tmp_146_var;
15309 while (
15310 (_tmp_146_var = _tmp_146_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070015311 )
15312 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015313 res = _tmp_146_var;
15314 if (n == children_capacity) {
15315 children_capacity *= 2;
15316 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15317 if (!children) {
15318 PyErr_Format(PyExc_MemoryError, "realloc None");
15319 return NULL;
15320 }
15321 }
15322 children[n++] = res;
15323 mark = p->mark;
15324 }
15325 p->mark = mark;
15326 }
15327 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15328 if (!seq) {
15329 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110");
15330 PyMem_Free(children);
15331 return NULL;
15332 }
15333 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15334 PyMem_Free(children);
15335 _PyPegen_insert_memo(p, start_mark, _loop0_110_type, seq);
15336 return seq;
15337}
15338
15339// _tmp_111: ',' args
15340static void *
15341_tmp_111_rule(Parser *p)
15342{
15343 if (p->error_indicator) {
15344 return NULL;
15345 }
15346 void * res = NULL;
15347 int mark = p->mark;
15348 { // ',' args
15349 expr_ty c;
15350 void *literal;
15351 if (
15352 (literal = _PyPegen_expect_token(p, 12))
15353 &&
15354 (c = args_rule(p))
15355 )
15356 {
15357 res = c;
15358 if (res == NULL && PyErr_Occurred()) {
15359 p->error_indicator = 1;
15360 return NULL;
15361 }
Guido van Rossumc001c092020-04-30 12:12:19 -070015362 goto done;
15363 }
15364 p->mark = mark;
15365 }
15366 res = NULL;
15367 done:
15368 return res;
15369}
15370
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015371// _tmp_112: ',' args
15372static void *
15373_tmp_112_rule(Parser *p)
15374{
15375 if (p->error_indicator) {
15376 return NULL;
15377 }
15378 void * res = NULL;
15379 int mark = p->mark;
15380 { // ',' args
15381 expr_ty c;
15382 void *literal;
15383 if (
15384 (literal = _PyPegen_expect_token(p, 12))
15385 &&
15386 (c = args_rule(p))
15387 )
15388 {
15389 res = c;
15390 if (res == NULL && PyErr_Occurred()) {
15391 p->error_indicator = 1;
15392 return NULL;
15393 }
15394 goto done;
15395 }
15396 p->mark = mark;
15397 }
15398 res = NULL;
15399 done:
15400 return res;
15401}
15402
15403// _loop0_114: ',' kwarg_or_starred
Pablo Galindo2b74c832020-04-27 18:02:07 +010015404static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015405_loop0_114_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015406{
15407 if (p->error_indicator) {
15408 return NULL;
15409 }
15410 void *res = NULL;
15411 int mark = p->mark;
15412 int start_mark = p->mark;
15413 void **children = PyMem_Malloc(sizeof(void *));
15414 if (!children) {
15415 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15416 return NULL;
15417 }
15418 ssize_t children_capacity = 1;
15419 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070015420 { // ',' kwarg_or_starred
15421 KeywordOrStarred* elem;
15422 void *literal;
15423 while (
15424 (literal = _PyPegen_expect_token(p, 12))
15425 &&
15426 (elem = kwarg_or_starred_rule(p))
15427 )
15428 {
15429 res = elem;
15430 if (res == NULL && PyErr_Occurred()) {
15431 p->error_indicator = 1;
15432 PyMem_Free(children);
15433 return NULL;
15434 }
15435 if (n == children_capacity) {
15436 children_capacity *= 2;
15437 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15438 if (!children) {
15439 PyErr_Format(PyExc_MemoryError, "realloc None");
15440 return NULL;
15441 }
15442 }
15443 children[n++] = res;
15444 mark = p->mark;
15445 }
15446 p->mark = mark;
15447 }
15448 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15449 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015450 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114");
Guido van Rossumc001c092020-04-30 12:12:19 -070015451 PyMem_Free(children);
15452 return NULL;
15453 }
15454 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15455 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015456 _PyPegen_insert_memo(p, start_mark, _loop0_114_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070015457 return seq;
15458}
15459
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015460// _gather_113: kwarg_or_starred _loop0_114
Guido van Rossumc001c092020-04-30 12:12:19 -070015461static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015462_gather_113_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015463{
15464 if (p->error_indicator) {
15465 return NULL;
15466 }
15467 asdl_seq * res = NULL;
15468 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015469 { // kwarg_or_starred _loop0_114
Guido van Rossumc001c092020-04-30 12:12:19 -070015470 KeywordOrStarred* elem;
15471 asdl_seq * seq;
15472 if (
15473 (elem = kwarg_or_starred_rule(p))
15474 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015475 (seq = _loop0_114_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070015476 )
15477 {
15478 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15479 goto done;
15480 }
15481 p->mark = mark;
15482 }
15483 res = NULL;
15484 done:
15485 return res;
15486}
15487
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015488// _loop0_116: ',' kwarg_or_double_starred
Guido van Rossumc001c092020-04-30 12:12:19 -070015489static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015490_loop0_116_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015491{
15492 if (p->error_indicator) {
15493 return NULL;
15494 }
15495 void *res = NULL;
15496 int mark = p->mark;
15497 int start_mark = p->mark;
15498 void **children = PyMem_Malloc(sizeof(void *));
15499 if (!children) {
15500 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15501 return NULL;
15502 }
15503 ssize_t children_capacity = 1;
15504 ssize_t n = 0;
15505 { // ',' kwarg_or_double_starred
15506 KeywordOrStarred* elem;
15507 void *literal;
15508 while (
15509 (literal = _PyPegen_expect_token(p, 12))
15510 &&
15511 (elem = kwarg_or_double_starred_rule(p))
15512 )
15513 {
15514 res = elem;
15515 if (res == NULL && PyErr_Occurred()) {
15516 p->error_indicator = 1;
15517 PyMem_Free(children);
15518 return NULL;
15519 }
15520 if (n == children_capacity) {
15521 children_capacity *= 2;
15522 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15523 if (!children) {
15524 PyErr_Format(PyExc_MemoryError, "realloc None");
15525 return NULL;
15526 }
15527 }
15528 children[n++] = res;
15529 mark = p->mark;
15530 }
15531 p->mark = mark;
15532 }
15533 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15534 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015535 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116");
Guido van Rossumc001c092020-04-30 12:12:19 -070015536 PyMem_Free(children);
15537 return NULL;
15538 }
15539 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15540 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015541 _PyPegen_insert_memo(p, start_mark, _loop0_116_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070015542 return seq;
15543}
15544
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015545// _gather_115: kwarg_or_double_starred _loop0_116
Guido van Rossumc001c092020-04-30 12:12:19 -070015546static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015547_gather_115_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015548{
15549 if (p->error_indicator) {
15550 return NULL;
15551 }
15552 asdl_seq * res = NULL;
15553 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015554 { // kwarg_or_double_starred _loop0_116
Guido van Rossumc001c092020-04-30 12:12:19 -070015555 KeywordOrStarred* elem;
15556 asdl_seq * seq;
15557 if (
15558 (elem = kwarg_or_double_starred_rule(p))
15559 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015560 (seq = _loop0_116_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070015561 )
15562 {
15563 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15564 goto done;
15565 }
15566 p->mark = mark;
15567 }
15568 res = NULL;
15569 done:
15570 return res;
15571}
15572
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015573// _loop0_118: ',' kwarg_or_starred
Guido van Rossumc001c092020-04-30 12:12:19 -070015574static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015575_loop0_118_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015576{
15577 if (p->error_indicator) {
15578 return NULL;
15579 }
15580 void *res = NULL;
15581 int mark = p->mark;
15582 int start_mark = p->mark;
15583 void **children = PyMem_Malloc(sizeof(void *));
15584 if (!children) {
15585 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15586 return NULL;
15587 }
15588 ssize_t children_capacity = 1;
15589 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015590 { // ',' kwarg_or_starred
15591 KeywordOrStarred* elem;
15592 void *literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070015593 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015594 (literal = _PyPegen_expect_token(p, 12))
15595 &&
15596 (elem = kwarg_or_starred_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070015597 )
15598 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015599 res = elem;
15600 if (res == NULL && PyErr_Occurred()) {
15601 p->error_indicator = 1;
15602 PyMem_Free(children);
15603 return NULL;
15604 }
Guido van Rossumc001c092020-04-30 12:12:19 -070015605 if (n == children_capacity) {
15606 children_capacity *= 2;
15607 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15608 if (!children) {
15609 PyErr_Format(PyExc_MemoryError, "realloc None");
15610 return NULL;
15611 }
15612 }
15613 children[n++] = res;
15614 mark = p->mark;
15615 }
15616 p->mark = mark;
15617 }
15618 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15619 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015620 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_118");
Guido van Rossumc001c092020-04-30 12:12:19 -070015621 PyMem_Free(children);
15622 return NULL;
15623 }
15624 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15625 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015626 _PyPegen_insert_memo(p, start_mark, _loop0_118_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070015627 return seq;
15628}
15629
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015630// _gather_117: kwarg_or_starred _loop0_118
Guido van Rossumc001c092020-04-30 12:12:19 -070015631static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015632_gather_117_rule(Parser *p)
15633{
15634 if (p->error_indicator) {
15635 return NULL;
15636 }
15637 asdl_seq * res = NULL;
15638 int mark = p->mark;
15639 { // kwarg_or_starred _loop0_118
15640 KeywordOrStarred* elem;
15641 asdl_seq * seq;
15642 if (
15643 (elem = kwarg_or_starred_rule(p))
15644 &&
15645 (seq = _loop0_118_rule(p))
15646 )
15647 {
15648 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15649 goto done;
15650 }
15651 p->mark = mark;
15652 }
15653 res = NULL;
15654 done:
15655 return res;
15656}
15657
15658// _loop0_120: ',' kwarg_or_double_starred
15659static asdl_seq *
15660_loop0_120_rule(Parser *p)
15661{
15662 if (p->error_indicator) {
15663 return NULL;
15664 }
15665 void *res = NULL;
15666 int mark = p->mark;
15667 int start_mark = p->mark;
15668 void **children = PyMem_Malloc(sizeof(void *));
15669 if (!children) {
15670 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15671 return NULL;
15672 }
15673 ssize_t children_capacity = 1;
15674 ssize_t n = 0;
15675 { // ',' kwarg_or_double_starred
15676 KeywordOrStarred* elem;
15677 void *literal;
15678 while (
15679 (literal = _PyPegen_expect_token(p, 12))
15680 &&
15681 (elem = kwarg_or_double_starred_rule(p))
15682 )
15683 {
15684 res = elem;
15685 if (res == NULL && PyErr_Occurred()) {
15686 p->error_indicator = 1;
15687 PyMem_Free(children);
15688 return NULL;
15689 }
15690 if (n == children_capacity) {
15691 children_capacity *= 2;
15692 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15693 if (!children) {
15694 PyErr_Format(PyExc_MemoryError, "realloc None");
15695 return NULL;
15696 }
15697 }
15698 children[n++] = res;
15699 mark = p->mark;
15700 }
15701 p->mark = mark;
15702 }
15703 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15704 if (!seq) {
15705 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_120");
15706 PyMem_Free(children);
15707 return NULL;
15708 }
15709 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15710 PyMem_Free(children);
15711 _PyPegen_insert_memo(p, start_mark, _loop0_120_type, seq);
15712 return seq;
15713}
15714
15715// _gather_119: kwarg_or_double_starred _loop0_120
15716static asdl_seq *
15717_gather_119_rule(Parser *p)
15718{
15719 if (p->error_indicator) {
15720 return NULL;
15721 }
15722 asdl_seq * res = NULL;
15723 int mark = p->mark;
15724 { // kwarg_or_double_starred _loop0_120
15725 KeywordOrStarred* elem;
15726 asdl_seq * seq;
15727 if (
15728 (elem = kwarg_or_double_starred_rule(p))
15729 &&
15730 (seq = _loop0_120_rule(p))
15731 )
15732 {
15733 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15734 goto done;
15735 }
15736 p->mark = mark;
15737 }
15738 res = NULL;
15739 done:
15740 return res;
15741}
15742
15743// _loop0_121: (',' star_target)
15744static asdl_seq *
15745_loop0_121_rule(Parser *p)
15746{
15747 if (p->error_indicator) {
15748 return NULL;
15749 }
15750 void *res = NULL;
15751 int mark = p->mark;
15752 int start_mark = p->mark;
15753 void **children = PyMem_Malloc(sizeof(void *));
15754 if (!children) {
15755 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15756 return NULL;
15757 }
15758 ssize_t children_capacity = 1;
15759 ssize_t n = 0;
15760 { // (',' star_target)
15761 void *_tmp_147_var;
15762 while (
15763 (_tmp_147_var = _tmp_147_rule(p))
15764 )
15765 {
15766 res = _tmp_147_var;
15767 if (n == children_capacity) {
15768 children_capacity *= 2;
15769 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15770 if (!children) {
15771 PyErr_Format(PyExc_MemoryError, "realloc None");
15772 return NULL;
15773 }
15774 }
15775 children[n++] = res;
15776 mark = p->mark;
15777 }
15778 p->mark = mark;
15779 }
15780 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15781 if (!seq) {
15782 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_121");
15783 PyMem_Free(children);
15784 return NULL;
15785 }
15786 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15787 PyMem_Free(children);
15788 _PyPegen_insert_memo(p, start_mark, _loop0_121_type, seq);
15789 return seq;
15790}
15791
15792// _loop0_123: ',' star_target
15793static asdl_seq *
15794_loop0_123_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015795{
15796 if (p->error_indicator) {
15797 return NULL;
15798 }
15799 void *res = NULL;
15800 int mark = p->mark;
15801 int start_mark = p->mark;
15802 void **children = PyMem_Malloc(sizeof(void *));
15803 if (!children) {
15804 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15805 return NULL;
15806 }
15807 ssize_t children_capacity = 1;
15808 ssize_t n = 0;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015809 { // ',' star_target
15810 expr_ty elem;
15811 void *literal;
15812 while (
15813 (literal = _PyPegen_expect_token(p, 12))
15814 &&
15815 (elem = star_target_rule(p))
15816 )
15817 {
15818 res = elem;
15819 if (res == NULL && PyErr_Occurred()) {
15820 p->error_indicator = 1;
15821 PyMem_Free(children);
15822 return NULL;
15823 }
15824 if (n == children_capacity) {
15825 children_capacity *= 2;
15826 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15827 if (!children) {
15828 PyErr_Format(PyExc_MemoryError, "realloc None");
15829 return NULL;
15830 }
15831 }
15832 children[n++] = res;
15833 mark = p->mark;
15834 }
15835 p->mark = mark;
15836 }
15837 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15838 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015839 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_123");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015840 PyMem_Free(children);
15841 return NULL;
15842 }
15843 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15844 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015845 _PyPegen_insert_memo(p, start_mark, _loop0_123_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015846 return seq;
15847}
15848
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015849// _gather_122: star_target _loop0_123
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015850static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015851_gather_122_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015852{
15853 if (p->error_indicator) {
15854 return NULL;
15855 }
15856 asdl_seq * res = NULL;
15857 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015858 { // star_target _loop0_123
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015859 expr_ty elem;
15860 asdl_seq * seq;
15861 if (
15862 (elem = star_target_rule(p))
15863 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015864 (seq = _loop0_123_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015865 )
15866 {
15867 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15868 goto done;
15869 }
15870 p->mark = mark;
15871 }
15872 res = NULL;
15873 done:
15874 return res;
15875}
15876
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015877// _tmp_124: !'*' star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015878static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015879_tmp_124_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015880{
15881 if (p->error_indicator) {
15882 return NULL;
15883 }
15884 void * res = NULL;
15885 int mark = p->mark;
15886 { // !'*' star_target
15887 expr_ty star_target_var;
15888 if (
15889 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16)
15890 &&
15891 (star_target_var = star_target_rule(p))
15892 )
15893 {
15894 res = star_target_var;
15895 goto done;
15896 }
15897 p->mark = mark;
15898 }
15899 res = NULL;
15900 done:
15901 return res;
15902}
15903
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015904// _loop0_126: ',' del_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015905static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015906_loop0_126_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015907{
15908 if (p->error_indicator) {
15909 return NULL;
15910 }
15911 void *res = NULL;
15912 int mark = p->mark;
15913 int start_mark = p->mark;
15914 void **children = PyMem_Malloc(sizeof(void *));
15915 if (!children) {
15916 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15917 return NULL;
15918 }
15919 ssize_t children_capacity = 1;
15920 ssize_t n = 0;
15921 { // ',' del_target
15922 expr_ty elem;
15923 void *literal;
15924 while (
15925 (literal = _PyPegen_expect_token(p, 12))
15926 &&
15927 (elem = del_target_rule(p))
15928 )
15929 {
15930 res = elem;
15931 if (res == NULL && PyErr_Occurred()) {
15932 p->error_indicator = 1;
15933 PyMem_Free(children);
15934 return NULL;
15935 }
15936 if (n == children_capacity) {
15937 children_capacity *= 2;
15938 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15939 if (!children) {
15940 PyErr_Format(PyExc_MemoryError, "realloc None");
15941 return NULL;
15942 }
15943 }
15944 children[n++] = res;
15945 mark = p->mark;
15946 }
15947 p->mark = mark;
15948 }
15949 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15950 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015951 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_126");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015952 PyMem_Free(children);
15953 return NULL;
15954 }
15955 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15956 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015957 _PyPegen_insert_memo(p, start_mark, _loop0_126_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015958 return seq;
15959}
15960
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015961// _gather_125: del_target _loop0_126
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015962static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015963_gather_125_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015964{
15965 if (p->error_indicator) {
15966 return NULL;
15967 }
15968 asdl_seq * res = NULL;
15969 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015970 { // del_target _loop0_126
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015971 expr_ty elem;
15972 asdl_seq * seq;
15973 if (
15974 (elem = del_target_rule(p))
15975 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015976 (seq = _loop0_126_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015977 )
15978 {
15979 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15980 goto done;
15981 }
15982 p->mark = mark;
15983 }
15984 res = NULL;
15985 done:
15986 return res;
15987}
15988
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015989// _loop0_128: ',' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015990static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015991_loop0_128_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015992{
15993 if (p->error_indicator) {
15994 return NULL;
15995 }
15996 void *res = NULL;
15997 int mark = p->mark;
15998 int start_mark = p->mark;
15999 void **children = PyMem_Malloc(sizeof(void *));
16000 if (!children) {
16001 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16002 return NULL;
16003 }
16004 ssize_t children_capacity = 1;
16005 ssize_t n = 0;
16006 { // ',' target
16007 expr_ty elem;
16008 void *literal;
16009 while (
16010 (literal = _PyPegen_expect_token(p, 12))
16011 &&
16012 (elem = target_rule(p))
16013 )
16014 {
16015 res = elem;
16016 if (res == NULL && PyErr_Occurred()) {
16017 p->error_indicator = 1;
16018 PyMem_Free(children);
16019 return NULL;
16020 }
16021 if (n == children_capacity) {
16022 children_capacity *= 2;
16023 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16024 if (!children) {
16025 PyErr_Format(PyExc_MemoryError, "realloc None");
16026 return NULL;
16027 }
16028 }
16029 children[n++] = res;
16030 mark = p->mark;
16031 }
16032 p->mark = mark;
16033 }
16034 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16035 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016036 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_128");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016037 PyMem_Free(children);
16038 return NULL;
16039 }
16040 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16041 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016042 _PyPegen_insert_memo(p, start_mark, _loop0_128_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016043 return seq;
16044}
16045
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016046// _gather_127: target _loop0_128
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016047static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016048_gather_127_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016049{
16050 if (p->error_indicator) {
16051 return NULL;
16052 }
16053 asdl_seq * res = NULL;
16054 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016055 { // target _loop0_128
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016056 expr_ty elem;
16057 asdl_seq * seq;
16058 if (
16059 (elem = target_rule(p))
16060 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016061 (seq = _loop0_128_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016062 )
16063 {
16064 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16065 goto done;
16066 }
16067 p->mark = mark;
16068 }
16069 res = NULL;
16070 done:
16071 return res;
16072}
16073
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016074// _tmp_129: args | expression for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016075static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016076_tmp_129_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016077{
16078 if (p->error_indicator) {
16079 return NULL;
16080 }
16081 void * res = NULL;
16082 int mark = p->mark;
16083 { // args
16084 expr_ty args_var;
16085 if (
16086 (args_var = args_rule(p))
16087 )
16088 {
16089 res = args_var;
16090 goto done;
16091 }
16092 p->mark = mark;
16093 }
16094 { // expression for_if_clauses
16095 expr_ty expression_var;
16096 asdl_seq* for_if_clauses_var;
16097 if (
16098 (expression_var = expression_rule(p))
16099 &&
16100 (for_if_clauses_var = for_if_clauses_rule(p))
16101 )
16102 {
16103 res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var);
16104 goto done;
16105 }
16106 p->mark = mark;
16107 }
16108 res = NULL;
16109 done:
16110 return res;
16111}
16112
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016113// _tmp_130: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016114static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016115_tmp_130_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016116{
16117 if (p->error_indicator) {
16118 return NULL;
16119 }
16120 void * res = NULL;
16121 int mark = p->mark;
16122 { // '=' annotated_rhs
16123 expr_ty annotated_rhs_var;
16124 void *literal;
16125 if (
16126 (literal = _PyPegen_expect_token(p, 22))
16127 &&
16128 (annotated_rhs_var = annotated_rhs_rule(p))
16129 )
16130 {
16131 res = _PyPegen_dummy_name(p, literal, annotated_rhs_var);
16132 goto done;
16133 }
16134 p->mark = mark;
16135 }
16136 res = NULL;
16137 done:
16138 return res;
16139}
16140
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016141// _tmp_131: '=' | augassign
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016142static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016143_tmp_131_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016144{
16145 if (p->error_indicator) {
16146 return NULL;
16147 }
16148 void * res = NULL;
16149 int mark = p->mark;
16150 { // '='
16151 void *literal;
16152 if (
16153 (literal = _PyPegen_expect_token(p, 22))
16154 )
16155 {
16156 res = literal;
16157 goto done;
16158 }
16159 p->mark = mark;
16160 }
16161 { // augassign
16162 AugOperator* augassign_var;
16163 if (
16164 (augassign_var = augassign_rule(p))
16165 )
16166 {
16167 res = augassign_var;
16168 goto done;
16169 }
16170 p->mark = mark;
16171 }
16172 res = NULL;
16173 done:
16174 return res;
16175}
16176
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016177// _tmp_132: yield_expr | star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016178static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016179_tmp_132_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016180{
16181 if (p->error_indicator) {
16182 return NULL;
16183 }
16184 void * res = NULL;
16185 int mark = p->mark;
16186 { // yield_expr
16187 expr_ty yield_expr_var;
16188 if (
16189 (yield_expr_var = yield_expr_rule(p))
16190 )
16191 {
16192 res = yield_expr_var;
16193 goto done;
16194 }
16195 p->mark = mark;
16196 }
16197 { // star_expressions
16198 expr_ty star_expressions_var;
16199 if (
16200 (star_expressions_var = star_expressions_rule(p))
16201 )
16202 {
16203 res = star_expressions_var;
16204 goto done;
16205 }
16206 p->mark = mark;
16207 }
16208 res = NULL;
16209 done:
16210 return res;
16211}
16212
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016213// _tmp_133: '[' | '(' | '{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016214static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016215_tmp_133_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016216{
16217 if (p->error_indicator) {
16218 return NULL;
16219 }
16220 void * res = NULL;
16221 int mark = p->mark;
16222 { // '['
16223 void *literal;
16224 if (
16225 (literal = _PyPegen_expect_token(p, 9))
16226 )
16227 {
16228 res = literal;
16229 goto done;
16230 }
16231 p->mark = mark;
16232 }
16233 { // '('
16234 void *literal;
16235 if (
16236 (literal = _PyPegen_expect_token(p, 7))
16237 )
16238 {
16239 res = literal;
16240 goto done;
16241 }
16242 p->mark = mark;
16243 }
16244 { // '{'
16245 void *literal;
16246 if (
16247 (literal = _PyPegen_expect_token(p, 25))
16248 )
16249 {
16250 res = literal;
16251 goto done;
16252 }
16253 p->mark = mark;
16254 }
16255 res = NULL;
16256 done:
16257 return res;
16258}
16259
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016260// _loop0_134: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070016261static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016262_loop0_134_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016263{
16264 if (p->error_indicator) {
16265 return NULL;
16266 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016267 void *res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016268 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070016269 int start_mark = p->mark;
16270 void **children = PyMem_Malloc(sizeof(void *));
16271 if (!children) {
16272 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16273 return NULL;
16274 }
16275 ssize_t children_capacity = 1;
16276 ssize_t n = 0;
16277 { // param_no_default
16278 arg_ty param_no_default_var;
16279 while (
16280 (param_no_default_var = param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016281 )
16282 {
Guido van Rossumc001c092020-04-30 12:12:19 -070016283 res = param_no_default_var;
16284 if (n == children_capacity) {
16285 children_capacity *= 2;
16286 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16287 if (!children) {
16288 PyErr_Format(PyExc_MemoryError, "realloc None");
16289 return NULL;
16290 }
16291 }
16292 children[n++] = res;
16293 mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016294 }
16295 p->mark = mark;
16296 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016297 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16298 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016299 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_134");
Guido van Rossumc001c092020-04-30 12:12:19 -070016300 PyMem_Free(children);
16301 return NULL;
16302 }
16303 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16304 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016305 _PyPegen_insert_memo(p, start_mark, _loop0_134_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070016306 return seq;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016307}
16308
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016309// _tmp_135: slash_with_default | param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016310static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016311_tmp_135_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016312{
16313 if (p->error_indicator) {
16314 return NULL;
16315 }
16316 void * res = NULL;
16317 int mark = p->mark;
16318 { // slash_with_default
16319 SlashWithDefault* slash_with_default_var;
16320 if (
16321 (slash_with_default_var = slash_with_default_rule(p))
16322 )
16323 {
16324 res = slash_with_default_var;
16325 goto done;
16326 }
16327 p->mark = mark;
16328 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016329 { // param_with_default+
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016330 asdl_seq * _loop1_148_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016331 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016332 (_loop1_148_var = _loop1_148_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016333 )
16334 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016335 res = _loop1_148_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016336 goto done;
16337 }
16338 p->mark = mark;
16339 }
16340 res = NULL;
16341 done:
16342 return res;
16343}
16344
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016345// _tmp_136: star_targets '='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016346static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016347_tmp_136_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016348{
16349 if (p->error_indicator) {
16350 return NULL;
16351 }
16352 void * res = NULL;
16353 int mark = p->mark;
16354 { // star_targets '='
16355 void *literal;
16356 expr_ty z;
16357 if (
16358 (z = star_targets_rule(p))
16359 &&
16360 (literal = _PyPegen_expect_token(p, 22))
16361 )
16362 {
16363 res = z;
16364 if (res == NULL && PyErr_Occurred()) {
16365 p->error_indicator = 1;
16366 return NULL;
16367 }
16368 goto done;
16369 }
16370 p->mark = mark;
16371 }
16372 res = NULL;
16373 done:
16374 return res;
16375}
16376
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016377// _tmp_137: '.' | '...'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016378static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016379_tmp_137_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016380{
16381 if (p->error_indicator) {
16382 return NULL;
16383 }
16384 void * res = NULL;
16385 int mark = p->mark;
16386 { // '.'
16387 void *literal;
16388 if (
16389 (literal = _PyPegen_expect_token(p, 23))
16390 )
16391 {
16392 res = literal;
16393 goto done;
16394 }
16395 p->mark = mark;
16396 }
16397 { // '...'
16398 void *literal;
16399 if (
16400 (literal = _PyPegen_expect_token(p, 52))
16401 )
16402 {
16403 res = literal;
16404 goto done;
16405 }
16406 p->mark = mark;
16407 }
16408 res = NULL;
16409 done:
16410 return res;
16411}
16412
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016413// _tmp_138: '.' | '...'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016414static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016415_tmp_138_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016416{
16417 if (p->error_indicator) {
16418 return NULL;
16419 }
16420 void * res = NULL;
16421 int mark = p->mark;
Pablo Galindo2b74c832020-04-27 18:02:07 +010016422 { // '.'
16423 void *literal;
16424 if (
16425 (literal = _PyPegen_expect_token(p, 23))
16426 )
16427 {
16428 res = literal;
16429 goto done;
16430 }
16431 p->mark = mark;
16432 }
16433 { // '...'
16434 void *literal;
16435 if (
16436 (literal = _PyPegen_expect_token(p, 52))
16437 )
16438 {
16439 res = literal;
16440 goto done;
16441 }
16442 p->mark = mark;
16443 }
16444 res = NULL;
16445 done:
16446 return res;
16447}
16448
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016449// _tmp_139: '@' named_expression NEWLINE
Pablo Galindo2b74c832020-04-27 18:02:07 +010016450static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016451_tmp_139_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016452{
16453 if (p->error_indicator) {
16454 return NULL;
16455 }
16456 void * res = NULL;
16457 int mark = p->mark;
16458 { // '@' named_expression NEWLINE
16459 expr_ty f;
16460 void *literal;
16461 void *newline_var;
16462 if (
16463 (literal = _PyPegen_expect_token(p, 49))
16464 &&
16465 (f = named_expression_rule(p))
16466 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +010016467 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016468 )
16469 {
16470 res = f;
16471 if (res == NULL && PyErr_Occurred()) {
16472 p->error_indicator = 1;
16473 return NULL;
16474 }
16475 goto done;
16476 }
16477 p->mark = mark;
16478 }
16479 res = NULL;
16480 done:
16481 return res;
16482}
16483
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016484// _tmp_140: ',' star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016485static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016486_tmp_140_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016487{
16488 if (p->error_indicator) {
16489 return NULL;
16490 }
16491 void * res = NULL;
16492 int mark = p->mark;
16493 { // ',' star_expression
16494 expr_ty c;
16495 void *literal;
16496 if (
16497 (literal = _PyPegen_expect_token(p, 12))
16498 &&
16499 (c = star_expression_rule(p))
16500 )
16501 {
16502 res = c;
16503 if (res == NULL && PyErr_Occurred()) {
16504 p->error_indicator = 1;
16505 return NULL;
16506 }
16507 goto done;
16508 }
16509 p->mark = mark;
16510 }
16511 res = NULL;
16512 done:
16513 return res;
16514}
16515
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016516// _tmp_141: ',' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016517static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016518_tmp_141_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016519{
16520 if (p->error_indicator) {
16521 return NULL;
16522 }
16523 void * res = NULL;
16524 int mark = p->mark;
16525 { // ',' expression
16526 expr_ty c;
16527 void *literal;
16528 if (
16529 (literal = _PyPegen_expect_token(p, 12))
16530 &&
16531 (c = expression_rule(p))
16532 )
16533 {
16534 res = c;
16535 if (res == NULL && PyErr_Occurred()) {
16536 p->error_indicator = 1;
16537 return NULL;
16538 }
16539 goto done;
16540 }
16541 p->mark = mark;
16542 }
16543 res = NULL;
16544 done:
16545 return res;
16546}
16547
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016548// _tmp_142: lambda_plain_name !'='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016549static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016550_tmp_142_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016551{
16552 if (p->error_indicator) {
16553 return NULL;
16554 }
16555 void * res = NULL;
16556 int mark = p->mark;
16557 { // lambda_plain_name !'='
16558 arg_ty lambda_plain_name_var;
16559 if (
16560 (lambda_plain_name_var = lambda_plain_name_rule(p))
16561 &&
16562 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22)
16563 )
16564 {
16565 res = lambda_plain_name_var;
16566 goto done;
16567 }
16568 p->mark = mark;
16569 }
16570 res = NULL;
16571 done:
16572 return res;
16573}
16574
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016575// _tmp_143: 'or' conjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016576static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016577_tmp_143_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016578{
16579 if (p->error_indicator) {
16580 return NULL;
16581 }
16582 void * res = NULL;
16583 int mark = p->mark;
16584 { // 'or' conjunction
16585 expr_ty c;
16586 void *keyword;
16587 if (
16588 (keyword = _PyPegen_expect_token(p, 532))
16589 &&
16590 (c = conjunction_rule(p))
16591 )
16592 {
16593 res = c;
16594 if (res == NULL && PyErr_Occurred()) {
16595 p->error_indicator = 1;
16596 return NULL;
16597 }
16598 goto done;
16599 }
16600 p->mark = mark;
16601 }
16602 res = NULL;
16603 done:
16604 return res;
16605}
16606
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016607// _tmp_144: 'and' inversion
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016608static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016609_tmp_144_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016610{
16611 if (p->error_indicator) {
16612 return NULL;
16613 }
16614 void * res = NULL;
16615 int mark = p->mark;
16616 { // 'and' inversion
16617 expr_ty c;
16618 void *keyword;
16619 if (
16620 (keyword = _PyPegen_expect_token(p, 533))
16621 &&
16622 (c = inversion_rule(p))
16623 )
16624 {
16625 res = c;
16626 if (res == NULL && PyErr_Occurred()) {
16627 p->error_indicator = 1;
16628 return NULL;
16629 }
16630 goto done;
16631 }
16632 p->mark = mark;
16633 }
16634 res = NULL;
16635 done:
16636 return res;
16637}
16638
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016639// _tmp_145: 'if' disjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016640static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016641_tmp_145_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016642{
16643 if (p->error_indicator) {
16644 return NULL;
16645 }
16646 void * res = NULL;
16647 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016648 { // 'if' disjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016649 void *keyword;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016650 expr_ty z;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016651 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016652 (keyword = _PyPegen_expect_token(p, 510))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016653 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016654 (z = disjunction_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016655 )
16656 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016657 res = z;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016658 if (res == NULL && PyErr_Occurred()) {
16659 p->error_indicator = 1;
16660 return NULL;
16661 }
16662 goto done;
16663 }
16664 p->mark = mark;
16665 }
16666 res = NULL;
16667 done:
16668 return res;
16669}
16670
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016671// _tmp_146: 'if' disjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016672static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016673_tmp_146_rule(Parser *p)
16674{
16675 if (p->error_indicator) {
16676 return NULL;
16677 }
16678 void * res = NULL;
16679 int mark = p->mark;
16680 { // 'if' disjunction
16681 void *keyword;
16682 expr_ty z;
16683 if (
16684 (keyword = _PyPegen_expect_token(p, 510))
16685 &&
16686 (z = disjunction_rule(p))
16687 )
16688 {
16689 res = z;
16690 if (res == NULL && PyErr_Occurred()) {
16691 p->error_indicator = 1;
16692 return NULL;
16693 }
16694 goto done;
16695 }
16696 p->mark = mark;
16697 }
16698 res = NULL;
16699 done:
16700 return res;
16701}
16702
16703// _tmp_147: ',' star_target
16704static void *
16705_tmp_147_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016706{
16707 if (p->error_indicator) {
16708 return NULL;
16709 }
16710 void * res = NULL;
16711 int mark = p->mark;
16712 { // ',' star_target
16713 expr_ty c;
16714 void *literal;
16715 if (
16716 (literal = _PyPegen_expect_token(p, 12))
16717 &&
16718 (c = star_target_rule(p))
16719 )
16720 {
16721 res = c;
16722 if (res == NULL && PyErr_Occurred()) {
16723 p->error_indicator = 1;
16724 return NULL;
16725 }
16726 goto done;
16727 }
16728 p->mark = mark;
16729 }
16730 res = NULL;
16731 done:
16732 return res;
16733}
16734
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016735// _loop1_148: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016736static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016737_loop1_148_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070016738{
16739 if (p->error_indicator) {
16740 return NULL;
16741 }
16742 void *res = NULL;
16743 int mark = p->mark;
16744 int start_mark = p->mark;
16745 void **children = PyMem_Malloc(sizeof(void *));
16746 if (!children) {
16747 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16748 return NULL;
16749 }
16750 ssize_t children_capacity = 1;
16751 ssize_t n = 0;
16752 { // param_with_default
16753 NameDefaultPair* param_with_default_var;
16754 while (
16755 (param_with_default_var = param_with_default_rule(p))
16756 )
16757 {
16758 res = param_with_default_var;
16759 if (n == children_capacity) {
16760 children_capacity *= 2;
16761 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16762 if (!children) {
16763 PyErr_Format(PyExc_MemoryError, "realloc None");
16764 return NULL;
16765 }
16766 }
16767 children[n++] = res;
16768 mark = p->mark;
16769 }
16770 p->mark = mark;
16771 }
16772 if (n == 0) {
16773 PyMem_Free(children);
16774 return NULL;
16775 }
16776 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16777 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016778 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_148");
Guido van Rossumc001c092020-04-30 12:12:19 -070016779 PyMem_Free(children);
16780 return NULL;
16781 }
16782 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16783 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016784 _PyPegen_insert_memo(p, start_mark, _loop1_148_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070016785 return seq;
16786}
16787
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016788void *
16789_PyPegen_parse(Parser *p)
16790{
16791 // Initialize keywords
16792 p->keywords = reserved_keywords;
16793 p->n_keyword_lists = n_keyword_lists;
16794
16795 // Run parser
16796 void *result = NULL;
16797 if (p->start_rule == Py_file_input) {
16798 result = file_rule(p);
16799 } else if (p->start_rule == Py_single_input) {
16800 result = interactive_rule(p);
16801 } else if (p->start_rule == Py_eval_input) {
16802 result = eval_rule(p);
Guido van Rossumc001c092020-04-30 12:12:19 -070016803 } else if (p->start_rule == Py_func_type_input) {
16804 result = func_type_rule(p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016805 } else if (p->start_rule == Py_fstring_input) {
16806 result = fstring_rule(p);
16807 }
16808
16809 return result;
16810}
16811
16812// The end