blob: d86390839d528efdf946c587ab3d19c680884f4d [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
Guido van Rossum3941d972020-05-01 09:42:03 -0700141#define lambda_slash_no_default_type 1070
Guido van Rossumc001c092020-04-30 12:12:19 -0700142#define lambda_slash_with_default_type 1071
143#define lambda_star_etc_type 1072
Guido van Rossum3941d972020-05-01 09:42:03 -0700144#define lambda_kwds_type 1073
145#define lambda_param_no_default_type 1074
146#define lambda_param_with_default_type 1075
147#define lambda_param_maybe_default_type 1076
148#define lambda_param_type 1077
149#define disjunction_type 1078
150#define conjunction_type 1079
151#define inversion_type 1080
152#define comparison_type 1081
153#define compare_op_bitwise_or_pair_type 1082
154#define eq_bitwise_or_type 1083
155#define noteq_bitwise_or_type 1084
156#define lte_bitwise_or_type 1085
157#define lt_bitwise_or_type 1086
158#define gte_bitwise_or_type 1087
159#define gt_bitwise_or_type 1088
160#define notin_bitwise_or_type 1089
161#define in_bitwise_or_type 1090
162#define isnot_bitwise_or_type 1091
163#define is_bitwise_or_type 1092
164#define bitwise_or_type 1093 // Left-recursive
165#define bitwise_xor_type 1094 // Left-recursive
166#define bitwise_and_type 1095 // Left-recursive
167#define shift_expr_type 1096 // Left-recursive
168#define sum_type 1097 // Left-recursive
169#define term_type 1098 // Left-recursive
170#define factor_type 1099
171#define power_type 1100
172#define await_primary_type 1101
173#define primary_type 1102 // Left-recursive
174#define slices_type 1103
175#define slice_type 1104
176#define atom_type 1105
177#define strings_type 1106
178#define list_type 1107
179#define listcomp_type 1108
180#define tuple_type 1109
181#define group_type 1110
182#define genexp_type 1111
183#define set_type 1112
184#define setcomp_type 1113
185#define dict_type 1114
186#define dictcomp_type 1115
187#define kvpairs_type 1116
188#define kvpair_type 1117
189#define for_if_clauses_type 1118
190#define for_if_clause_type 1119
191#define yield_expr_type 1120
192#define arguments_type 1121
193#define args_type 1122
194#define kwargs_type 1123
195#define starred_expression_type 1124
196#define kwarg_or_starred_type 1125
197#define kwarg_or_double_starred_type 1126
198#define star_targets_type 1127
199#define star_targets_seq_type 1128
200#define star_target_type 1129
201#define star_atom_type 1130
202#define inside_paren_ann_assign_target_type 1131
203#define ann_assign_subscript_attribute_target_type 1132
204#define del_targets_type 1133
205#define del_target_type 1134
206#define del_t_atom_type 1135
207#define targets_type 1136
208#define target_type 1137
209#define t_primary_type 1138 // Left-recursive
210#define t_lookahead_type 1139
211#define t_atom_type 1140
212#define incorrect_arguments_type 1141
213#define invalid_named_expression_type 1142
214#define invalid_assignment_type 1143
215#define invalid_block_type 1144
216#define invalid_comprehension_type 1145
217#define invalid_parameters_type 1146
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +0300218#define invalid_star_etc_type 1147
219#define invalid_lambda_star_etc_type 1148
220#define invalid_double_type_comments_type 1149
221#define _loop0_1_type 1150
222#define _loop0_2_type 1151
223#define _loop0_4_type 1152
224#define _gather_3_type 1153
225#define _loop0_6_type 1154
226#define _gather_5_type 1155
227#define _loop0_8_type 1156
228#define _gather_7_type 1157
229#define _loop0_10_type 1158
230#define _gather_9_type 1159
231#define _loop1_11_type 1160
232#define _loop0_13_type 1161
233#define _gather_12_type 1162
234#define _tmp_14_type 1163
235#define _tmp_15_type 1164
236#define _tmp_16_type 1165
237#define _tmp_17_type 1166
238#define _tmp_18_type 1167
239#define _tmp_19_type 1168
240#define _tmp_20_type 1169
241#define _tmp_21_type 1170
242#define _loop1_22_type 1171
243#define _tmp_23_type 1172
244#define _tmp_24_type 1173
245#define _loop0_26_type 1174
246#define _gather_25_type 1175
247#define _loop0_28_type 1176
248#define _gather_27_type 1177
249#define _tmp_29_type 1178
250#define _loop0_30_type 1179
251#define _loop1_31_type 1180
252#define _loop0_33_type 1181
253#define _gather_32_type 1182
254#define _tmp_34_type 1183
255#define _loop0_36_type 1184
256#define _gather_35_type 1185
257#define _tmp_37_type 1186
258#define _loop0_39_type 1187
259#define _gather_38_type 1188
260#define _loop0_41_type 1189
261#define _gather_40_type 1190
262#define _loop0_43_type 1191
263#define _gather_42_type 1192
264#define _loop0_45_type 1193
265#define _gather_44_type 1194
266#define _tmp_46_type 1195
267#define _loop1_47_type 1196
268#define _tmp_48_type 1197
269#define _tmp_49_type 1198
270#define _tmp_50_type 1199
271#define _tmp_51_type 1200
272#define _tmp_52_type 1201
273#define _loop0_53_type 1202
274#define _loop0_54_type 1203
275#define _loop0_55_type 1204
276#define _loop1_56_type 1205
277#define _loop0_57_type 1206
278#define _loop1_58_type 1207
279#define _loop1_59_type 1208
280#define _loop1_60_type 1209
281#define _loop0_61_type 1210
282#define _loop1_62_type 1211
283#define _loop0_63_type 1212
284#define _loop1_64_type 1213
285#define _loop0_65_type 1214
286#define _loop1_66_type 1215
287#define _loop1_67_type 1216
288#define _tmp_68_type 1217
289#define _loop0_70_type 1218
290#define _gather_69_type 1219
291#define _loop1_71_type 1220
292#define _loop0_73_type 1221
293#define _gather_72_type 1222
294#define _loop1_74_type 1223
295#define _loop0_75_type 1224
296#define _loop0_76_type 1225
297#define _loop0_77_type 1226
298#define _loop1_78_type 1227
299#define _loop0_79_type 1228
300#define _loop1_80_type 1229
301#define _loop1_81_type 1230
302#define _loop1_82_type 1231
303#define _loop0_83_type 1232
304#define _loop1_84_type 1233
305#define _loop0_85_type 1234
306#define _loop1_86_type 1235
307#define _loop0_87_type 1236
308#define _loop1_88_type 1237
309#define _loop1_89_type 1238
310#define _loop1_90_type 1239
311#define _loop1_91_type 1240
312#define _tmp_92_type 1241
313#define _loop0_94_type 1242
314#define _gather_93_type 1243
315#define _tmp_95_type 1244
316#define _tmp_96_type 1245
317#define _tmp_97_type 1246
318#define _tmp_98_type 1247
319#define _loop1_99_type 1248
320#define _tmp_100_type 1249
321#define _tmp_101_type 1250
322#define _loop0_103_type 1251
323#define _gather_102_type 1252
324#define _loop1_104_type 1253
325#define _loop0_105_type 1254
326#define _loop0_106_type 1255
327#define _tmp_107_type 1256
328#define _tmp_108_type 1257
329#define _loop0_110_type 1258
330#define _gather_109_type 1259
331#define _loop0_112_type 1260
332#define _gather_111_type 1261
333#define _loop0_114_type 1262
334#define _gather_113_type 1263
335#define _loop0_116_type 1264
336#define _gather_115_type 1265
337#define _loop0_117_type 1266
338#define _loop0_119_type 1267
339#define _gather_118_type 1268
340#define _tmp_120_type 1269
341#define _loop0_122_type 1270
342#define _gather_121_type 1271
343#define _loop0_124_type 1272
344#define _gather_123_type 1273
345#define _tmp_125_type 1274
346#define _tmp_126_type 1275
347#define _tmp_127_type 1276
348#define _tmp_128_type 1277
349#define _tmp_129_type 1278
350#define _loop0_130_type 1279
351#define _tmp_131_type 1280
352#define _tmp_132_type 1281
353#define _tmp_133_type 1282
354#define _tmp_134_type 1283
355#define _tmp_135_type 1284
356#define _tmp_136_type 1285
357#define _tmp_137_type 1286
358#define _tmp_138_type 1287
359#define _tmp_139_type 1288
360#define _tmp_140_type 1289
361#define _tmp_141_type 1290
362#define _tmp_142_type 1291
363#define _tmp_143_type 1292
364#define _tmp_144_type 1293
365#define _loop1_145_type 1294
366#define _tmp_146_type 1295
367#define _tmp_147_type 1296
Pablo 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);
Lysandros Nikolaou999ec9a2020-05-06 21:11:04 +0300381static stmt_ty assignment_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100382static 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);
Pablo Galindod9552412020-05-01 16:32:09 +0100411static Token* 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);
Guido van Rossum3941d972020-05-01 09:42:03 -0700439static asdl_seq* lambda_slash_no_default_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100440static SlashWithDefault* lambda_slash_with_default_rule(Parser *p);
441static StarEtc* lambda_star_etc_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100442static arg_ty lambda_kwds_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700443static arg_ty lambda_param_no_default_rule(Parser *p);
444static NameDefaultPair* lambda_param_with_default_rule(Parser *p);
445static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p);
446static arg_ty lambda_param_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100447static expr_ty disjunction_rule(Parser *p);
448static expr_ty conjunction_rule(Parser *p);
449static expr_ty inversion_rule(Parser *p);
450static expr_ty comparison_rule(Parser *p);
451static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p);
452static CmpopExprPair* eq_bitwise_or_rule(Parser *p);
453static CmpopExprPair* noteq_bitwise_or_rule(Parser *p);
454static CmpopExprPair* lte_bitwise_or_rule(Parser *p);
455static CmpopExprPair* lt_bitwise_or_rule(Parser *p);
456static CmpopExprPair* gte_bitwise_or_rule(Parser *p);
457static CmpopExprPair* gt_bitwise_or_rule(Parser *p);
458static CmpopExprPair* notin_bitwise_or_rule(Parser *p);
459static CmpopExprPair* in_bitwise_or_rule(Parser *p);
460static CmpopExprPair* isnot_bitwise_or_rule(Parser *p);
461static CmpopExprPair* is_bitwise_or_rule(Parser *p);
462static expr_ty bitwise_or_rule(Parser *p);
463static expr_ty bitwise_xor_rule(Parser *p);
464static expr_ty bitwise_and_rule(Parser *p);
465static expr_ty shift_expr_rule(Parser *p);
466static expr_ty sum_rule(Parser *p);
467static expr_ty term_rule(Parser *p);
468static expr_ty factor_rule(Parser *p);
469static expr_ty power_rule(Parser *p);
470static expr_ty await_primary_rule(Parser *p);
471static expr_ty primary_rule(Parser *p);
472static expr_ty slices_rule(Parser *p);
473static expr_ty slice_rule(Parser *p);
474static expr_ty atom_rule(Parser *p);
475static expr_ty strings_rule(Parser *p);
476static expr_ty list_rule(Parser *p);
477static expr_ty listcomp_rule(Parser *p);
478static expr_ty tuple_rule(Parser *p);
479static expr_ty group_rule(Parser *p);
480static expr_ty genexp_rule(Parser *p);
481static expr_ty set_rule(Parser *p);
482static expr_ty setcomp_rule(Parser *p);
483static expr_ty dict_rule(Parser *p);
484static expr_ty dictcomp_rule(Parser *p);
485static asdl_seq* kvpairs_rule(Parser *p);
486static KeyValuePair* kvpair_rule(Parser *p);
487static asdl_seq* for_if_clauses_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300488static comprehension_ty for_if_clause_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100489static expr_ty yield_expr_rule(Parser *p);
490static expr_ty arguments_rule(Parser *p);
491static expr_ty args_rule(Parser *p);
492static asdl_seq* kwargs_rule(Parser *p);
493static expr_ty starred_expression_rule(Parser *p);
494static KeywordOrStarred* kwarg_or_starred_rule(Parser *p);
495static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p);
496static expr_ty star_targets_rule(Parser *p);
497static asdl_seq* star_targets_seq_rule(Parser *p);
498static expr_ty star_target_rule(Parser *p);
499static expr_ty star_atom_rule(Parser *p);
500static expr_ty inside_paren_ann_assign_target_rule(Parser *p);
501static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p);
502static asdl_seq* del_targets_rule(Parser *p);
503static expr_ty del_target_rule(Parser *p);
504static expr_ty del_t_atom_rule(Parser *p);
505static asdl_seq* targets_rule(Parser *p);
506static expr_ty target_rule(Parser *p);
507static expr_ty t_primary_rule(Parser *p);
508static void *t_lookahead_rule(Parser *p);
509static expr_ty t_atom_rule(Parser *p);
510static void *incorrect_arguments_rule(Parser *p);
511static void *invalid_named_expression_rule(Parser *p);
512static void *invalid_assignment_rule(Parser *p);
513static void *invalid_block_rule(Parser *p);
514static void *invalid_comprehension_rule(Parser *p);
515static void *invalid_parameters_rule(Parser *p);
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +0300516static void *invalid_star_etc_rule(Parser *p);
517static void *invalid_lambda_star_etc_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700518static void *invalid_double_type_comments_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100519static asdl_seq *_loop0_1_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700520static asdl_seq *_loop0_2_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100521static asdl_seq *_loop0_4_rule(Parser *p);
522static asdl_seq *_gather_3_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700523static asdl_seq *_loop0_6_rule(Parser *p);
524static asdl_seq *_gather_5_rule(Parser *p);
525static asdl_seq *_loop0_8_rule(Parser *p);
526static asdl_seq *_gather_7_rule(Parser *p);
527static asdl_seq *_loop0_10_rule(Parser *p);
528static asdl_seq *_gather_9_rule(Parser *p);
529static asdl_seq *_loop1_11_rule(Parser *p);
530static asdl_seq *_loop0_13_rule(Parser *p);
531static asdl_seq *_gather_12_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100532static void *_tmp_14_rule(Parser *p);
533static void *_tmp_15_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700534static void *_tmp_16_rule(Parser *p);
535static void *_tmp_17_rule(Parser *p);
536static void *_tmp_18_rule(Parser *p);
537static void *_tmp_19_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100538static void *_tmp_20_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700539static void *_tmp_21_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100540static asdl_seq *_loop1_22_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700541static void *_tmp_23_rule(Parser *p);
542static void *_tmp_24_rule(Parser *p);
543static asdl_seq *_loop0_26_rule(Parser *p);
544static asdl_seq *_gather_25_rule(Parser *p);
545static asdl_seq *_loop0_28_rule(Parser *p);
546static asdl_seq *_gather_27_rule(Parser *p);
547static void *_tmp_29_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100548static asdl_seq *_loop0_30_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700549static asdl_seq *_loop1_31_rule(Parser *p);
550static asdl_seq *_loop0_33_rule(Parser *p);
551static asdl_seq *_gather_32_rule(Parser *p);
552static void *_tmp_34_rule(Parser *p);
553static asdl_seq *_loop0_36_rule(Parser *p);
554static asdl_seq *_gather_35_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100555static void *_tmp_37_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700556static asdl_seq *_loop0_39_rule(Parser *p);
557static asdl_seq *_gather_38_rule(Parser *p);
558static asdl_seq *_loop0_41_rule(Parser *p);
559static asdl_seq *_gather_40_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300560static asdl_seq *_loop0_43_rule(Parser *p);
561static asdl_seq *_gather_42_rule(Parser *p);
562static asdl_seq *_loop0_45_rule(Parser *p);
563static asdl_seq *_gather_44_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100564static void *_tmp_46_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300565static asdl_seq *_loop1_47_rule(Parser *p);
566static void *_tmp_48_rule(Parser *p);
567static void *_tmp_49_rule(Parser *p);
568static void *_tmp_50_rule(Parser *p);
569static void *_tmp_51_rule(Parser *p);
570static void *_tmp_52_rule(Parser *p);
571static asdl_seq *_loop0_53_rule(Parser *p);
572static asdl_seq *_loop0_54_rule(Parser *p);
573static asdl_seq *_loop0_55_rule(Parser *p);
574static asdl_seq *_loop1_56_rule(Parser *p);
575static asdl_seq *_loop0_57_rule(Parser *p);
576static asdl_seq *_loop1_58_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700577static asdl_seq *_loop1_59_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300578static asdl_seq *_loop1_60_rule(Parser *p);
579static asdl_seq *_loop0_61_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700580static asdl_seq *_loop1_62_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300581static asdl_seq *_loop0_63_rule(Parser *p);
582static asdl_seq *_loop1_64_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700583static asdl_seq *_loop0_65_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700584static asdl_seq *_loop1_66_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300585static asdl_seq *_loop1_67_rule(Parser *p);
586static void *_tmp_68_rule(Parser *p);
587static asdl_seq *_loop0_70_rule(Parser *p);
588static asdl_seq *_gather_69_rule(Parser *p);
589static asdl_seq *_loop1_71_rule(Parser *p);
590static asdl_seq *_loop0_73_rule(Parser *p);
591static asdl_seq *_gather_72_rule(Parser *p);
592static asdl_seq *_loop1_74_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700593static asdl_seq *_loop0_75_rule(Parser *p);
594static asdl_seq *_loop0_76_rule(Parser *p);
595static asdl_seq *_loop0_77_rule(Parser *p);
596static asdl_seq *_loop1_78_rule(Parser *p);
597static asdl_seq *_loop0_79_rule(Parser *p);
598static asdl_seq *_loop1_80_rule(Parser *p);
599static asdl_seq *_loop1_81_rule(Parser *p);
600static asdl_seq *_loop1_82_rule(Parser *p);
601static asdl_seq *_loop0_83_rule(Parser *p);
602static asdl_seq *_loop1_84_rule(Parser *p);
603static asdl_seq *_loop0_85_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300604static asdl_seq *_loop1_86_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700605static asdl_seq *_loop0_87_rule(Parser *p);
606static asdl_seq *_loop1_88_rule(Parser *p);
607static asdl_seq *_loop1_89_rule(Parser *p);
608static asdl_seq *_loop1_90_rule(Parser *p);
609static asdl_seq *_loop1_91_rule(Parser *p);
610static void *_tmp_92_rule(Parser *p);
611static asdl_seq *_loop0_94_rule(Parser *p);
612static asdl_seq *_gather_93_rule(Parser *p);
613static void *_tmp_95_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700614static void *_tmp_96_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700615static void *_tmp_97_rule(Parser *p);
616static void *_tmp_98_rule(Parser *p);
617static asdl_seq *_loop1_99_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100618static void *_tmp_100_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300619static void *_tmp_101_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700620static asdl_seq *_loop0_103_rule(Parser *p);
621static asdl_seq *_gather_102_rule(Parser *p);
622static asdl_seq *_loop1_104_rule(Parser *p);
623static asdl_seq *_loop0_105_rule(Parser *p);
624static asdl_seq *_loop0_106_rule(Parser *p);
625static void *_tmp_107_rule(Parser *p);
626static void *_tmp_108_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300627static asdl_seq *_loop0_110_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700628static asdl_seq *_gather_109_rule(Parser *p);
629static asdl_seq *_loop0_112_rule(Parser *p);
630static asdl_seq *_gather_111_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100631static asdl_seq *_loop0_114_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300632static asdl_seq *_gather_113_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100633static asdl_seq *_loop0_116_rule(Parser *p);
634static asdl_seq *_gather_115_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700635static asdl_seq *_loop0_117_rule(Parser *p);
636static asdl_seq *_loop0_119_rule(Parser *p);
637static asdl_seq *_gather_118_rule(Parser *p);
638static void *_tmp_120_rule(Parser *p);
639static asdl_seq *_loop0_122_rule(Parser *p);
640static asdl_seq *_gather_121_rule(Parser *p);
641static asdl_seq *_loop0_124_rule(Parser *p);
642static asdl_seq *_gather_123_rule(Parser *p);
643static void *_tmp_125_rule(Parser *p);
644static void *_tmp_126_rule(Parser *p);
645static void *_tmp_127_rule(Parser *p);
646static void *_tmp_128_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100647static void *_tmp_129_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700648static asdl_seq *_loop0_130_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100649static void *_tmp_131_rule(Parser *p);
650static void *_tmp_132_rule(Parser *p);
651static void *_tmp_133_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700652static void *_tmp_134_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100653static void *_tmp_135_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700654static void *_tmp_136_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100655static void *_tmp_137_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700656static void *_tmp_138_rule(Parser *p);
657static void *_tmp_139_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300658static void *_tmp_140_rule(Parser *p);
659static void *_tmp_141_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700660static void *_tmp_142_rule(Parser *p);
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +0300661static void *_tmp_143_rule(Parser *p);
662static void *_tmp_144_rule(Parser *p);
663static asdl_seq *_loop1_145_rule(Parser *p);
664static void *_tmp_146_rule(Parser *p);
665static void *_tmp_147_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;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100679 Token * endmarker_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100680 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;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100741 Token * endmarker_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100742 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;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100777 Token * endmarker_var;
778 Token * literal;
779 Token * literal_1;
780 Token * literal_2;
Guido van Rossumc001c092020-04-30 12:12:19 -0700781 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
Shantanu603d3542020-05-03 22:08:14 -0700840// | '*' expression ',' '**' expression
841// | '*' expression
842// | '**' expression
Guido van Rossumc001c092020-04-30 12:12:19 -0700843// | ','.expression+
844static asdl_seq*
845type_expressions_rule(Parser *p)
846{
847 if (p->error_indicator) {
848 return NULL;
849 }
850 asdl_seq* res = NULL;
851 int mark = p->mark;
852 { // ','.expression+ ',' '*' expression ',' '**' expression
853 asdl_seq * a;
854 expr_ty b;
855 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100856 Token * literal;
857 Token * literal_1;
858 Token * literal_2;
859 Token * literal_3;
Guido van Rossumc001c092020-04-30 12:12:19 -0700860 if (
861 (a = _gather_3_rule(p))
862 &&
863 (literal = _PyPegen_expect_token(p, 12))
864 &&
865 (literal_1 = _PyPegen_expect_token(p, 16))
866 &&
867 (b = expression_rule(p))
868 &&
869 (literal_2 = _PyPegen_expect_token(p, 12))
870 &&
871 (literal_3 = _PyPegen_expect_token(p, 35))
872 &&
873 (c = expression_rule(p))
874 )
875 {
876 res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c );
877 if (res == NULL && PyErr_Occurred()) {
878 p->error_indicator = 1;
879 return NULL;
880 }
881 goto done;
882 }
883 p->mark = mark;
884 }
885 { // ','.expression+ ',' '*' expression
886 asdl_seq * a;
887 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100888 Token * literal;
889 Token * literal_1;
Guido van Rossumc001c092020-04-30 12:12:19 -0700890 if (
891 (a = _gather_5_rule(p))
892 &&
893 (literal = _PyPegen_expect_token(p, 12))
894 &&
895 (literal_1 = _PyPegen_expect_token(p, 16))
896 &&
897 (b = expression_rule(p))
898 )
899 {
900 res = _PyPegen_seq_append_to_end ( p , a , b );
901 if (res == NULL && PyErr_Occurred()) {
902 p->error_indicator = 1;
903 return NULL;
904 }
905 goto done;
906 }
907 p->mark = mark;
908 }
909 { // ','.expression+ ',' '**' expression
910 asdl_seq * a;
911 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100912 Token * literal;
913 Token * literal_1;
Guido van Rossumc001c092020-04-30 12:12:19 -0700914 if (
915 (a = _gather_7_rule(p))
916 &&
917 (literal = _PyPegen_expect_token(p, 12))
918 &&
919 (literal_1 = _PyPegen_expect_token(p, 35))
920 &&
921 (b = expression_rule(p))
922 )
923 {
924 res = _PyPegen_seq_append_to_end ( p , a , b );
925 if (res == NULL && PyErr_Occurred()) {
926 p->error_indicator = 1;
927 return NULL;
928 }
929 goto done;
930 }
931 p->mark = mark;
932 }
Shantanu603d3542020-05-03 22:08:14 -0700933 { // '*' expression ',' '**' expression
934 expr_ty a;
935 expr_ty b;
936 Token * literal;
937 Token * literal_1;
938 Token * literal_2;
939 if (
940 (literal = _PyPegen_expect_token(p, 16))
941 &&
942 (a = expression_rule(p))
943 &&
944 (literal_1 = _PyPegen_expect_token(p, 12))
945 &&
946 (literal_2 = _PyPegen_expect_token(p, 35))
947 &&
948 (b = expression_rule(p))
949 )
950 {
951 res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b );
952 if (res == NULL && PyErr_Occurred()) {
953 p->error_indicator = 1;
954 return NULL;
955 }
956 goto done;
957 }
958 p->mark = mark;
959 }
960 { // '*' expression
961 expr_ty a;
962 Token * literal;
963 if (
964 (literal = _PyPegen_expect_token(p, 16))
965 &&
966 (a = expression_rule(p))
967 )
968 {
969 res = _PyPegen_singleton_seq ( p , a );
970 if (res == NULL && PyErr_Occurred()) {
971 p->error_indicator = 1;
972 return NULL;
973 }
974 goto done;
975 }
976 p->mark = mark;
977 }
978 { // '**' expression
979 expr_ty a;
980 Token * literal;
981 if (
982 (literal = _PyPegen_expect_token(p, 35))
983 &&
984 (a = expression_rule(p))
985 )
986 {
987 res = _PyPegen_singleton_seq ( p , a );
988 if (res == NULL && PyErr_Occurred()) {
989 p->error_indicator = 1;
990 return NULL;
991 }
992 goto done;
993 }
994 p->mark = mark;
995 }
Guido van Rossumc001c092020-04-30 12:12:19 -0700996 { // ','.expression+
997 asdl_seq * _gather_9_var;
998 if (
999 (_gather_9_var = _gather_9_rule(p))
1000 )
1001 {
1002 res = _gather_9_var;
1003 goto done;
1004 }
1005 p->mark = mark;
1006 }
1007 res = NULL;
1008 done:
1009 return res;
1010}
1011
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001012// statements: statement+
1013static asdl_seq*
1014statements_rule(Parser *p)
1015{
1016 if (p->error_indicator) {
1017 return NULL;
1018 }
1019 asdl_seq* res = NULL;
1020 int mark = p->mark;
1021 { // statement+
1022 asdl_seq * a;
1023 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001024 (a = _loop1_11_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001025 )
1026 {
1027 res = _PyPegen_seq_flatten ( p , a );
1028 if (res == NULL && PyErr_Occurred()) {
1029 p->error_indicator = 1;
1030 return NULL;
1031 }
1032 goto done;
1033 }
1034 p->mark = mark;
1035 }
1036 res = NULL;
1037 done:
1038 return res;
1039}
1040
1041// statement: compound_stmt | simple_stmt
1042static asdl_seq*
1043statement_rule(Parser *p)
1044{
1045 if (p->error_indicator) {
1046 return NULL;
1047 }
1048 asdl_seq* res = NULL;
1049 int mark = p->mark;
1050 { // compound_stmt
1051 stmt_ty a;
1052 if (
1053 (a = compound_stmt_rule(p))
1054 )
1055 {
1056 res = _PyPegen_singleton_seq ( p , a );
1057 if (res == NULL && PyErr_Occurred()) {
1058 p->error_indicator = 1;
1059 return NULL;
1060 }
1061 goto done;
1062 }
1063 p->mark = mark;
1064 }
1065 { // simple_stmt
1066 asdl_seq* simple_stmt_var;
1067 if (
1068 (simple_stmt_var = simple_stmt_rule(p))
1069 )
1070 {
1071 res = simple_stmt_var;
1072 goto done;
1073 }
1074 p->mark = mark;
1075 }
1076 res = NULL;
1077 done:
1078 return res;
1079}
1080
1081// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
1082static asdl_seq*
1083statement_newline_rule(Parser *p)
1084{
1085 if (p->error_indicator) {
1086 return NULL;
1087 }
1088 asdl_seq* res = NULL;
1089 int mark = p->mark;
1090 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1091 p->error_indicator = 1;
1092 return NULL;
1093 }
1094 int start_lineno = p->tokens[mark]->lineno;
1095 UNUSED(start_lineno); // Only used by EXTRA macro
1096 int start_col_offset = p->tokens[mark]->col_offset;
1097 UNUSED(start_col_offset); // Only used by EXTRA macro
1098 { // compound_stmt NEWLINE
1099 stmt_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001100 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001101 if (
1102 (a = compound_stmt_rule(p))
1103 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01001104 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001105 )
1106 {
1107 res = _PyPegen_singleton_seq ( p , a );
1108 if (res == NULL && PyErr_Occurred()) {
1109 p->error_indicator = 1;
1110 return NULL;
1111 }
1112 goto done;
1113 }
1114 p->mark = mark;
1115 }
1116 { // simple_stmt
1117 asdl_seq* simple_stmt_var;
1118 if (
1119 (simple_stmt_var = simple_stmt_rule(p))
1120 )
1121 {
1122 res = simple_stmt_var;
1123 goto done;
1124 }
1125 p->mark = mark;
1126 }
1127 { // NEWLINE
Pablo Galindob796b3f2020-05-01 12:32:26 +01001128 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001129 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +01001130 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001131 )
1132 {
1133 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1134 if (token == NULL) {
1135 return NULL;
1136 }
1137 int end_lineno = token->end_lineno;
1138 UNUSED(end_lineno); // Only used by EXTRA macro
1139 int end_col_offset = token->end_col_offset;
1140 UNUSED(end_col_offset); // Only used by EXTRA macro
1141 res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) );
1142 if (res == NULL && PyErr_Occurred()) {
1143 p->error_indicator = 1;
1144 return NULL;
1145 }
1146 goto done;
1147 }
1148 p->mark = mark;
1149 }
1150 { // $
Pablo Galindob796b3f2020-05-01 12:32:26 +01001151 Token * endmarker_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001152 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +01001153 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001154 )
1155 {
1156 res = _PyPegen_interactive_exit ( p );
1157 if (res == NULL && PyErr_Occurred()) {
1158 p->error_indicator = 1;
1159 return NULL;
1160 }
1161 goto done;
1162 }
1163 p->mark = mark;
1164 }
1165 res = NULL;
1166 done:
1167 return res;
1168}
1169
1170// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
1171static asdl_seq*
1172simple_stmt_rule(Parser *p)
1173{
1174 if (p->error_indicator) {
1175 return NULL;
1176 }
1177 asdl_seq* res = NULL;
1178 int mark = p->mark;
1179 { // small_stmt !';' NEWLINE
1180 stmt_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001181 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001182 if (
1183 (a = small_stmt_rule(p))
1184 &&
1185 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13)
1186 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01001187 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001188 )
1189 {
1190 res = _PyPegen_singleton_seq ( p , a );
1191 if (res == NULL && PyErr_Occurred()) {
1192 p->error_indicator = 1;
1193 return NULL;
1194 }
1195 goto done;
1196 }
1197 p->mark = mark;
1198 }
1199 { // ';'.small_stmt+ ';'? NEWLINE
1200 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001201 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001202 void *opt_var;
1203 UNUSED(opt_var); // Silence compiler warnings
1204 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001205 (a = _gather_12_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001206 &&
1207 (opt_var = _PyPegen_expect_token(p, 13), 1)
1208 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01001209 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001210 )
1211 {
1212 res = a;
1213 if (res == NULL && PyErr_Occurred()) {
1214 p->error_indicator = 1;
1215 return NULL;
1216 }
1217 goto done;
1218 }
1219 p->mark = mark;
1220 }
1221 res = NULL;
1222 done:
1223 return res;
1224}
1225
1226// small_stmt:
1227// | assignment
1228// | star_expressions
1229// | &'return' return_stmt
1230// | &('import' | 'from') import_stmt
1231// | &'raise' raise_stmt
1232// | 'pass'
1233// | &'del' del_stmt
1234// | &'yield' yield_stmt
1235// | &'assert' assert_stmt
1236// | 'break'
1237// | 'continue'
1238// | &'global' global_stmt
1239// | &'nonlocal' nonlocal_stmt
1240static stmt_ty
1241small_stmt_rule(Parser *p)
1242{
1243 if (p->error_indicator) {
1244 return NULL;
1245 }
1246 stmt_ty res = NULL;
1247 if (_PyPegen_is_memoized(p, small_stmt_type, &res))
1248 return res;
1249 int mark = p->mark;
1250 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1251 p->error_indicator = 1;
1252 return NULL;
1253 }
1254 int start_lineno = p->tokens[mark]->lineno;
1255 UNUSED(start_lineno); // Only used by EXTRA macro
1256 int start_col_offset = p->tokens[mark]->col_offset;
1257 UNUSED(start_col_offset); // Only used by EXTRA macro
1258 { // assignment
Lysandros Nikolaou999ec9a2020-05-06 21:11:04 +03001259 stmt_ty assignment_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001260 if (
1261 (assignment_var = assignment_rule(p))
1262 )
1263 {
1264 res = assignment_var;
1265 goto done;
1266 }
1267 p->mark = mark;
1268 }
1269 { // star_expressions
1270 expr_ty e;
1271 if (
1272 (e = star_expressions_rule(p))
1273 )
1274 {
1275 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1276 if (token == NULL) {
1277 return NULL;
1278 }
1279 int end_lineno = token->end_lineno;
1280 UNUSED(end_lineno); // Only used by EXTRA macro
1281 int end_col_offset = token->end_col_offset;
1282 UNUSED(end_col_offset); // Only used by EXTRA macro
1283 res = _Py_Expr ( e , EXTRA );
1284 if (res == NULL && PyErr_Occurred()) {
1285 p->error_indicator = 1;
1286 return NULL;
1287 }
1288 goto done;
1289 }
1290 p->mark = mark;
1291 }
1292 { // &'return' return_stmt
1293 stmt_ty return_stmt_var;
1294 if (
1295 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500)
1296 &&
1297 (return_stmt_var = return_stmt_rule(p))
1298 )
1299 {
1300 res = return_stmt_var;
1301 goto done;
1302 }
1303 p->mark = mark;
1304 }
1305 { // &('import' | 'from') import_stmt
1306 stmt_ty import_stmt_var;
1307 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001308 _PyPegen_lookahead(1, _tmp_14_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001309 &&
1310 (import_stmt_var = import_stmt_rule(p))
1311 )
1312 {
1313 res = import_stmt_var;
1314 goto done;
1315 }
1316 p->mark = mark;
1317 }
1318 { // &'raise' raise_stmt
1319 stmt_ty raise_stmt_var;
1320 if (
1321 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501)
1322 &&
1323 (raise_stmt_var = raise_stmt_rule(p))
1324 )
1325 {
1326 res = raise_stmt_var;
1327 goto done;
1328 }
1329 p->mark = mark;
1330 }
1331 { // 'pass'
Pablo Galindob796b3f2020-05-01 12:32:26 +01001332 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001333 if (
1334 (keyword = _PyPegen_expect_token(p, 502))
1335 )
1336 {
1337 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1338 if (token == NULL) {
1339 return NULL;
1340 }
1341 int end_lineno = token->end_lineno;
1342 UNUSED(end_lineno); // Only used by EXTRA macro
1343 int end_col_offset = token->end_col_offset;
1344 UNUSED(end_col_offset); // Only used by EXTRA macro
1345 res = _Py_Pass ( EXTRA );
1346 if (res == NULL && PyErr_Occurred()) {
1347 p->error_indicator = 1;
1348 return NULL;
1349 }
1350 goto done;
1351 }
1352 p->mark = mark;
1353 }
1354 { // &'del' del_stmt
1355 stmt_ty del_stmt_var;
1356 if (
1357 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503)
1358 &&
1359 (del_stmt_var = del_stmt_rule(p))
1360 )
1361 {
1362 res = del_stmt_var;
1363 goto done;
1364 }
1365 p->mark = mark;
1366 }
1367 { // &'yield' yield_stmt
1368 stmt_ty yield_stmt_var;
1369 if (
1370 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504)
1371 &&
1372 (yield_stmt_var = yield_stmt_rule(p))
1373 )
1374 {
1375 res = yield_stmt_var;
1376 goto done;
1377 }
1378 p->mark = mark;
1379 }
1380 { // &'assert' assert_stmt
1381 stmt_ty assert_stmt_var;
1382 if (
1383 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505)
1384 &&
1385 (assert_stmt_var = assert_stmt_rule(p))
1386 )
1387 {
1388 res = assert_stmt_var;
1389 goto done;
1390 }
1391 p->mark = mark;
1392 }
1393 { // 'break'
Pablo Galindob796b3f2020-05-01 12:32:26 +01001394 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001395 if (
1396 (keyword = _PyPegen_expect_token(p, 506))
1397 )
1398 {
1399 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1400 if (token == NULL) {
1401 return NULL;
1402 }
1403 int end_lineno = token->end_lineno;
1404 UNUSED(end_lineno); // Only used by EXTRA macro
1405 int end_col_offset = token->end_col_offset;
1406 UNUSED(end_col_offset); // Only used by EXTRA macro
1407 res = _Py_Break ( EXTRA );
1408 if (res == NULL && PyErr_Occurred()) {
1409 p->error_indicator = 1;
1410 return NULL;
1411 }
1412 goto done;
1413 }
1414 p->mark = mark;
1415 }
1416 { // 'continue'
Pablo Galindob796b3f2020-05-01 12:32:26 +01001417 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001418 if (
1419 (keyword = _PyPegen_expect_token(p, 507))
1420 )
1421 {
1422 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1423 if (token == NULL) {
1424 return NULL;
1425 }
1426 int end_lineno = token->end_lineno;
1427 UNUSED(end_lineno); // Only used by EXTRA macro
1428 int end_col_offset = token->end_col_offset;
1429 UNUSED(end_col_offset); // Only used by EXTRA macro
1430 res = _Py_Continue ( EXTRA );
1431 if (res == NULL && PyErr_Occurred()) {
1432 p->error_indicator = 1;
1433 return NULL;
1434 }
1435 goto done;
1436 }
1437 p->mark = mark;
1438 }
1439 { // &'global' global_stmt
1440 stmt_ty global_stmt_var;
1441 if (
1442 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508)
1443 &&
1444 (global_stmt_var = global_stmt_rule(p))
1445 )
1446 {
1447 res = global_stmt_var;
1448 goto done;
1449 }
1450 p->mark = mark;
1451 }
1452 { // &'nonlocal' nonlocal_stmt
1453 stmt_ty nonlocal_stmt_var;
1454 if (
1455 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509)
1456 &&
1457 (nonlocal_stmt_var = nonlocal_stmt_rule(p))
1458 )
1459 {
1460 res = nonlocal_stmt_var;
1461 goto done;
1462 }
1463 p->mark = mark;
1464 }
1465 res = NULL;
1466 done:
1467 _PyPegen_insert_memo(p, mark, small_stmt_type, res);
1468 return res;
1469}
1470
1471// compound_stmt:
1472// | &('def' | '@' | ASYNC) function_def
1473// | &'if' if_stmt
1474// | &('class' | '@') class_def
1475// | &('with' | ASYNC) with_stmt
1476// | &('for' | ASYNC) for_stmt
1477// | &'try' try_stmt
1478// | &'while' while_stmt
1479static stmt_ty
1480compound_stmt_rule(Parser *p)
1481{
1482 if (p->error_indicator) {
1483 return NULL;
1484 }
1485 stmt_ty res = NULL;
1486 int mark = p->mark;
1487 { // &('def' | '@' | ASYNC) function_def
1488 stmt_ty function_def_var;
1489 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001490 _PyPegen_lookahead(1, _tmp_15_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001491 &&
1492 (function_def_var = function_def_rule(p))
1493 )
1494 {
1495 res = function_def_var;
1496 goto done;
1497 }
1498 p->mark = mark;
1499 }
1500 { // &'if' if_stmt
1501 stmt_ty if_stmt_var;
1502 if (
1503 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510)
1504 &&
1505 (if_stmt_var = if_stmt_rule(p))
1506 )
1507 {
1508 res = if_stmt_var;
1509 goto done;
1510 }
1511 p->mark = mark;
1512 }
1513 { // &('class' | '@') class_def
1514 stmt_ty class_def_var;
1515 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001516 _PyPegen_lookahead(1, _tmp_16_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001517 &&
1518 (class_def_var = class_def_rule(p))
1519 )
1520 {
1521 res = class_def_var;
1522 goto done;
1523 }
1524 p->mark = mark;
1525 }
1526 { // &('with' | ASYNC) with_stmt
1527 stmt_ty with_stmt_var;
1528 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001529 _PyPegen_lookahead(1, _tmp_17_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001530 &&
1531 (with_stmt_var = with_stmt_rule(p))
1532 )
1533 {
1534 res = with_stmt_var;
1535 goto done;
1536 }
1537 p->mark = mark;
1538 }
1539 { // &('for' | ASYNC) for_stmt
1540 stmt_ty for_stmt_var;
1541 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001542 _PyPegen_lookahead(1, _tmp_18_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001543 &&
1544 (for_stmt_var = for_stmt_rule(p))
1545 )
1546 {
1547 res = for_stmt_var;
1548 goto done;
1549 }
1550 p->mark = mark;
1551 }
1552 { // &'try' try_stmt
1553 stmt_ty try_stmt_var;
1554 if (
1555 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511)
1556 &&
1557 (try_stmt_var = try_stmt_rule(p))
1558 )
1559 {
1560 res = try_stmt_var;
1561 goto done;
1562 }
1563 p->mark = mark;
1564 }
1565 { // &'while' while_stmt
1566 stmt_ty while_stmt_var;
1567 if (
1568 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512)
1569 &&
1570 (while_stmt_var = while_stmt_rule(p))
1571 )
1572 {
1573 res = while_stmt_var;
1574 goto done;
1575 }
1576 p->mark = mark;
1577 }
1578 res = NULL;
1579 done:
1580 return res;
1581}
1582
1583// assignment:
1584// | NAME ':' expression ['=' annotated_rhs]
1585// | ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs]
Guido van Rossumc001c092020-04-30 12:12:19 -07001586// | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001587// | target augassign (yield_expr | star_expressions)
1588// | invalid_assignment
Lysandros Nikolaou999ec9a2020-05-06 21:11:04 +03001589static stmt_ty
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001590assignment_rule(Parser *p)
1591{
1592 if (p->error_indicator) {
1593 return NULL;
1594 }
Lysandros Nikolaou999ec9a2020-05-06 21:11:04 +03001595 stmt_ty res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001596 int mark = p->mark;
1597 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1598 p->error_indicator = 1;
1599 return NULL;
1600 }
1601 int start_lineno = p->tokens[mark]->lineno;
1602 UNUSED(start_lineno); // Only used by EXTRA macro
1603 int start_col_offset = p->tokens[mark]->col_offset;
1604 UNUSED(start_col_offset); // Only used by EXTRA macro
1605 { // NAME ':' expression ['=' annotated_rhs]
1606 expr_ty a;
1607 expr_ty b;
1608 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001609 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001610 if (
1611 (a = _PyPegen_name_token(p))
1612 &&
1613 (literal = _PyPegen_expect_token(p, 11))
1614 &&
1615 (b = expression_rule(p))
1616 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001617 (c = _tmp_19_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001618 )
1619 {
1620 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1621 if (token == NULL) {
1622 return NULL;
1623 }
1624 int end_lineno = token->end_lineno;
1625 UNUSED(end_lineno); // Only used by EXTRA macro
1626 int end_col_offset = token->end_col_offset;
1627 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001628 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 +01001629 if (res == NULL && PyErr_Occurred()) {
1630 p->error_indicator = 1;
1631 return NULL;
1632 }
1633 goto done;
1634 }
1635 p->mark = mark;
1636 }
1637 { // ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs]
1638 void *a;
1639 expr_ty b;
1640 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001641 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001642 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001643 (a = _tmp_20_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001644 &&
1645 (literal = _PyPegen_expect_token(p, 11))
1646 &&
1647 (b = expression_rule(p))
1648 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001649 (c = _tmp_21_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001650 )
1651 {
1652 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1653 if (token == NULL) {
1654 return NULL;
1655 }
1656 int end_lineno = token->end_lineno;
1657 UNUSED(end_lineno); // Only used by EXTRA macro
1658 int end_col_offset = token->end_col_offset;
1659 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001660 res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001661 if (res == NULL && PyErr_Occurred()) {
1662 p->error_indicator = 1;
1663 return NULL;
1664 }
1665 goto done;
1666 }
1667 p->mark = mark;
1668 }
Guido van Rossumc001c092020-04-30 12:12:19 -07001669 { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001670 asdl_seq * a;
1671 void *b;
Guido van Rossumc001c092020-04-30 12:12:19 -07001672 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001673 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001674 (a = _loop1_22_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001675 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001676 (b = _tmp_23_rule(p))
1677 &&
1678 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001679 )
1680 {
1681 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1682 if (token == NULL) {
1683 return NULL;
1684 }
1685 int end_lineno = token->end_lineno;
1686 UNUSED(end_lineno); // Only used by EXTRA macro
1687 int end_col_offset = token->end_col_offset;
1688 UNUSED(end_col_offset); // Only used by EXTRA macro
Guido van Rossumc001c092020-04-30 12:12:19 -07001689 res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001690 if (res == NULL && PyErr_Occurred()) {
1691 p->error_indicator = 1;
1692 return NULL;
1693 }
1694 goto done;
1695 }
1696 p->mark = mark;
1697 }
1698 { // target augassign (yield_expr | star_expressions)
1699 expr_ty a;
1700 AugOperator* b;
1701 void *c;
1702 if (
1703 (a = target_rule(p))
1704 &&
1705 (b = augassign_rule(p))
1706 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001707 (c = _tmp_24_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001708 )
1709 {
1710 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1711 if (token == NULL) {
1712 return NULL;
1713 }
1714 int end_lineno = token->end_lineno;
1715 UNUSED(end_lineno); // Only used by EXTRA macro
1716 int end_col_offset = token->end_col_offset;
1717 UNUSED(end_col_offset); // Only used by EXTRA macro
1718 res = _Py_AugAssign ( a , b -> kind , c , EXTRA );
1719 if (res == NULL && PyErr_Occurred()) {
1720 p->error_indicator = 1;
1721 return NULL;
1722 }
1723 goto done;
1724 }
1725 p->mark = mark;
1726 }
1727 { // invalid_assignment
1728 void *invalid_assignment_var;
1729 if (
1730 (invalid_assignment_var = invalid_assignment_rule(p))
1731 )
1732 {
1733 res = invalid_assignment_var;
1734 goto done;
1735 }
1736 p->mark = mark;
1737 }
1738 res = NULL;
1739 done:
1740 return res;
1741}
1742
1743// augassign:
1744// | '+='
1745// | '-='
1746// | '*='
1747// | '@='
1748// | '/='
1749// | '%='
1750// | '&='
1751// | '|='
1752// | '^='
1753// | '<<='
1754// | '>>='
1755// | '**='
1756// | '//='
1757static AugOperator*
1758augassign_rule(Parser *p)
1759{
1760 if (p->error_indicator) {
1761 return NULL;
1762 }
1763 AugOperator* res = NULL;
1764 int mark = p->mark;
1765 { // '+='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001766 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001767 if (
1768 (literal = _PyPegen_expect_token(p, 36))
1769 )
1770 {
1771 res = _PyPegen_augoperator ( p , Add );
1772 if (res == NULL && PyErr_Occurred()) {
1773 p->error_indicator = 1;
1774 return NULL;
1775 }
1776 goto done;
1777 }
1778 p->mark = mark;
1779 }
1780 { // '-='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001781 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001782 if (
1783 (literal = _PyPegen_expect_token(p, 37))
1784 )
1785 {
1786 res = _PyPegen_augoperator ( p , Sub );
1787 if (res == NULL && PyErr_Occurred()) {
1788 p->error_indicator = 1;
1789 return NULL;
1790 }
1791 goto done;
1792 }
1793 p->mark = mark;
1794 }
1795 { // '*='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001796 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001797 if (
1798 (literal = _PyPegen_expect_token(p, 38))
1799 )
1800 {
1801 res = _PyPegen_augoperator ( p , Mult );
1802 if (res == NULL && PyErr_Occurred()) {
1803 p->error_indicator = 1;
1804 return NULL;
1805 }
1806 goto done;
1807 }
1808 p->mark = mark;
1809 }
1810 { // '@='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001811 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001812 if (
1813 (literal = _PyPegen_expect_token(p, 50))
1814 )
1815 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001816 res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001817 if (res == NULL && PyErr_Occurred()) {
1818 p->error_indicator = 1;
1819 return NULL;
1820 }
1821 goto done;
1822 }
1823 p->mark = mark;
1824 }
1825 { // '/='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001826 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001827 if (
1828 (literal = _PyPegen_expect_token(p, 39))
1829 )
1830 {
1831 res = _PyPegen_augoperator ( p , Div );
1832 if (res == NULL && PyErr_Occurred()) {
1833 p->error_indicator = 1;
1834 return NULL;
1835 }
1836 goto done;
1837 }
1838 p->mark = mark;
1839 }
1840 { // '%='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001841 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001842 if (
1843 (literal = _PyPegen_expect_token(p, 40))
1844 )
1845 {
1846 res = _PyPegen_augoperator ( p , Mod );
1847 if (res == NULL && PyErr_Occurred()) {
1848 p->error_indicator = 1;
1849 return NULL;
1850 }
1851 goto done;
1852 }
1853 p->mark = mark;
1854 }
1855 { // '&='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001856 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001857 if (
1858 (literal = _PyPegen_expect_token(p, 41))
1859 )
1860 {
1861 res = _PyPegen_augoperator ( p , BitAnd );
1862 if (res == NULL && PyErr_Occurred()) {
1863 p->error_indicator = 1;
1864 return NULL;
1865 }
1866 goto done;
1867 }
1868 p->mark = mark;
1869 }
1870 { // '|='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001871 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001872 if (
1873 (literal = _PyPegen_expect_token(p, 42))
1874 )
1875 {
1876 res = _PyPegen_augoperator ( p , BitOr );
1877 if (res == NULL && PyErr_Occurred()) {
1878 p->error_indicator = 1;
1879 return NULL;
1880 }
1881 goto done;
1882 }
1883 p->mark = mark;
1884 }
1885 { // '^='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001886 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001887 if (
1888 (literal = _PyPegen_expect_token(p, 43))
1889 )
1890 {
1891 res = _PyPegen_augoperator ( p , BitXor );
1892 if (res == NULL && PyErr_Occurred()) {
1893 p->error_indicator = 1;
1894 return NULL;
1895 }
1896 goto done;
1897 }
1898 p->mark = mark;
1899 }
1900 { // '<<='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001901 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001902 if (
1903 (literal = _PyPegen_expect_token(p, 44))
1904 )
1905 {
1906 res = _PyPegen_augoperator ( p , LShift );
1907 if (res == NULL && PyErr_Occurred()) {
1908 p->error_indicator = 1;
1909 return NULL;
1910 }
1911 goto done;
1912 }
1913 p->mark = mark;
1914 }
1915 { // '>>='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001916 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001917 if (
1918 (literal = _PyPegen_expect_token(p, 45))
1919 )
1920 {
1921 res = _PyPegen_augoperator ( p , RShift );
1922 if (res == NULL && PyErr_Occurred()) {
1923 p->error_indicator = 1;
1924 return NULL;
1925 }
1926 goto done;
1927 }
1928 p->mark = mark;
1929 }
1930 { // '**='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001931 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001932 if (
1933 (literal = _PyPegen_expect_token(p, 46))
1934 )
1935 {
1936 res = _PyPegen_augoperator ( p , Pow );
1937 if (res == NULL && PyErr_Occurred()) {
1938 p->error_indicator = 1;
1939 return NULL;
1940 }
1941 goto done;
1942 }
1943 p->mark = mark;
1944 }
1945 { // '//='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001946 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001947 if (
1948 (literal = _PyPegen_expect_token(p, 48))
1949 )
1950 {
1951 res = _PyPegen_augoperator ( p , FloorDiv );
1952 if (res == NULL && PyErr_Occurred()) {
1953 p->error_indicator = 1;
1954 return NULL;
1955 }
1956 goto done;
1957 }
1958 p->mark = mark;
1959 }
1960 res = NULL;
1961 done:
1962 return res;
1963}
1964
1965// global_stmt: 'global' ','.NAME+
1966static stmt_ty
1967global_stmt_rule(Parser *p)
1968{
1969 if (p->error_indicator) {
1970 return NULL;
1971 }
1972 stmt_ty res = NULL;
1973 int mark = p->mark;
1974 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1975 p->error_indicator = 1;
1976 return NULL;
1977 }
1978 int start_lineno = p->tokens[mark]->lineno;
1979 UNUSED(start_lineno); // Only used by EXTRA macro
1980 int start_col_offset = p->tokens[mark]->col_offset;
1981 UNUSED(start_col_offset); // Only used by EXTRA macro
1982 { // 'global' ','.NAME+
1983 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001984 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001985 if (
1986 (keyword = _PyPegen_expect_token(p, 508))
1987 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07001988 (a = _gather_25_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001989 )
1990 {
1991 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1992 if (token == NULL) {
1993 return NULL;
1994 }
1995 int end_lineno = token->end_lineno;
1996 UNUSED(end_lineno); // Only used by EXTRA macro
1997 int end_col_offset = token->end_col_offset;
1998 UNUSED(end_col_offset); // Only used by EXTRA macro
1999 res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
2000 if (res == NULL && PyErr_Occurred()) {
2001 p->error_indicator = 1;
2002 return NULL;
2003 }
2004 goto done;
2005 }
2006 p->mark = mark;
2007 }
2008 res = NULL;
2009 done:
2010 return res;
2011}
2012
2013// nonlocal_stmt: 'nonlocal' ','.NAME+
2014static stmt_ty
2015nonlocal_stmt_rule(Parser *p)
2016{
2017 if (p->error_indicator) {
2018 return NULL;
2019 }
2020 stmt_ty res = NULL;
2021 int mark = p->mark;
2022 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2023 p->error_indicator = 1;
2024 return NULL;
2025 }
2026 int start_lineno = p->tokens[mark]->lineno;
2027 UNUSED(start_lineno); // Only used by EXTRA macro
2028 int start_col_offset = p->tokens[mark]->col_offset;
2029 UNUSED(start_col_offset); // Only used by EXTRA macro
2030 { // 'nonlocal' ','.NAME+
2031 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002032 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002033 if (
2034 (keyword = _PyPegen_expect_token(p, 509))
2035 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002036 (a = _gather_27_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002037 )
2038 {
2039 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2040 if (token == NULL) {
2041 return NULL;
2042 }
2043 int end_lineno = token->end_lineno;
2044 UNUSED(end_lineno); // Only used by EXTRA macro
2045 int end_col_offset = token->end_col_offset;
2046 UNUSED(end_col_offset); // Only used by EXTRA macro
2047 res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
2048 if (res == NULL && PyErr_Occurred()) {
2049 p->error_indicator = 1;
2050 return NULL;
2051 }
2052 goto done;
2053 }
2054 p->mark = mark;
2055 }
2056 res = NULL;
2057 done:
2058 return res;
2059}
2060
2061// yield_stmt: yield_expr
2062static stmt_ty
2063yield_stmt_rule(Parser *p)
2064{
2065 if (p->error_indicator) {
2066 return NULL;
2067 }
2068 stmt_ty res = NULL;
2069 int mark = p->mark;
2070 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2071 p->error_indicator = 1;
2072 return NULL;
2073 }
2074 int start_lineno = p->tokens[mark]->lineno;
2075 UNUSED(start_lineno); // Only used by EXTRA macro
2076 int start_col_offset = p->tokens[mark]->col_offset;
2077 UNUSED(start_col_offset); // Only used by EXTRA macro
2078 { // yield_expr
2079 expr_ty y;
2080 if (
2081 (y = yield_expr_rule(p))
2082 )
2083 {
2084 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2085 if (token == NULL) {
2086 return NULL;
2087 }
2088 int end_lineno = token->end_lineno;
2089 UNUSED(end_lineno); // Only used by EXTRA macro
2090 int end_col_offset = token->end_col_offset;
2091 UNUSED(end_col_offset); // Only used by EXTRA macro
2092 res = _Py_Expr ( y , EXTRA );
2093 if (res == NULL && PyErr_Occurred()) {
2094 p->error_indicator = 1;
2095 return NULL;
2096 }
2097 goto done;
2098 }
2099 p->mark = mark;
2100 }
2101 res = NULL;
2102 done:
2103 return res;
2104}
2105
2106// assert_stmt: 'assert' expression [',' expression]
2107static stmt_ty
2108assert_stmt_rule(Parser *p)
2109{
2110 if (p->error_indicator) {
2111 return NULL;
2112 }
2113 stmt_ty res = NULL;
2114 int mark = p->mark;
2115 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2116 p->error_indicator = 1;
2117 return NULL;
2118 }
2119 int start_lineno = p->tokens[mark]->lineno;
2120 UNUSED(start_lineno); // Only used by EXTRA macro
2121 int start_col_offset = p->tokens[mark]->col_offset;
2122 UNUSED(start_col_offset); // Only used by EXTRA macro
2123 { // 'assert' expression [',' expression]
2124 expr_ty a;
2125 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002126 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002127 if (
2128 (keyword = _PyPegen_expect_token(p, 505))
2129 &&
2130 (a = expression_rule(p))
2131 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002132 (b = _tmp_29_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002133 )
2134 {
2135 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2136 if (token == NULL) {
2137 return NULL;
2138 }
2139 int end_lineno = token->end_lineno;
2140 UNUSED(end_lineno); // Only used by EXTRA macro
2141 int end_col_offset = token->end_col_offset;
2142 UNUSED(end_col_offset); // Only used by EXTRA macro
2143 res = _Py_Assert ( a , b , EXTRA );
2144 if (res == NULL && PyErr_Occurred()) {
2145 p->error_indicator = 1;
2146 return NULL;
2147 }
2148 goto done;
2149 }
2150 p->mark = mark;
2151 }
2152 res = NULL;
2153 done:
2154 return res;
2155}
2156
2157// del_stmt: 'del' del_targets
2158static stmt_ty
2159del_stmt_rule(Parser *p)
2160{
2161 if (p->error_indicator) {
2162 return NULL;
2163 }
2164 stmt_ty res = NULL;
2165 int mark = p->mark;
2166 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2167 p->error_indicator = 1;
2168 return NULL;
2169 }
2170 int start_lineno = p->tokens[mark]->lineno;
2171 UNUSED(start_lineno); // Only used by EXTRA macro
2172 int start_col_offset = p->tokens[mark]->col_offset;
2173 UNUSED(start_col_offset); // Only used by EXTRA macro
2174 { // 'del' del_targets
2175 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002176 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002177 if (
2178 (keyword = _PyPegen_expect_token(p, 503))
2179 &&
2180 (a = del_targets_rule(p))
2181 )
2182 {
2183 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2184 if (token == NULL) {
2185 return NULL;
2186 }
2187 int end_lineno = token->end_lineno;
2188 UNUSED(end_lineno); // Only used by EXTRA macro
2189 int end_col_offset = token->end_col_offset;
2190 UNUSED(end_col_offset); // Only used by EXTRA macro
2191 res = _Py_Delete ( a , EXTRA );
2192 if (res == NULL && PyErr_Occurred()) {
2193 p->error_indicator = 1;
2194 return NULL;
2195 }
2196 goto done;
2197 }
2198 p->mark = mark;
2199 }
2200 res = NULL;
2201 done:
2202 return res;
2203}
2204
2205// import_stmt: import_name | import_from
2206static stmt_ty
2207import_stmt_rule(Parser *p)
2208{
2209 if (p->error_indicator) {
2210 return NULL;
2211 }
2212 stmt_ty res = NULL;
2213 int mark = p->mark;
2214 { // import_name
2215 stmt_ty import_name_var;
2216 if (
2217 (import_name_var = import_name_rule(p))
2218 )
2219 {
2220 res = import_name_var;
2221 goto done;
2222 }
2223 p->mark = mark;
2224 }
2225 { // import_from
2226 stmt_ty import_from_var;
2227 if (
2228 (import_from_var = import_from_rule(p))
2229 )
2230 {
2231 res = import_from_var;
2232 goto done;
2233 }
2234 p->mark = mark;
2235 }
2236 res = NULL;
2237 done:
2238 return res;
2239}
2240
2241// import_name: 'import' dotted_as_names
2242static stmt_ty
2243import_name_rule(Parser *p)
2244{
2245 if (p->error_indicator) {
2246 return NULL;
2247 }
2248 stmt_ty res = NULL;
2249 int mark = p->mark;
2250 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2251 p->error_indicator = 1;
2252 return NULL;
2253 }
2254 int start_lineno = p->tokens[mark]->lineno;
2255 UNUSED(start_lineno); // Only used by EXTRA macro
2256 int start_col_offset = p->tokens[mark]->col_offset;
2257 UNUSED(start_col_offset); // Only used by EXTRA macro
2258 { // 'import' dotted_as_names
2259 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002260 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002261 if (
2262 (keyword = _PyPegen_expect_token(p, 513))
2263 &&
2264 (a = dotted_as_names_rule(p))
2265 )
2266 {
2267 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2268 if (token == NULL) {
2269 return NULL;
2270 }
2271 int end_lineno = token->end_lineno;
2272 UNUSED(end_lineno); // Only used by EXTRA macro
2273 int end_col_offset = token->end_col_offset;
2274 UNUSED(end_col_offset); // Only used by EXTRA macro
2275 res = _Py_Import ( a , EXTRA );
2276 if (res == NULL && PyErr_Occurred()) {
2277 p->error_indicator = 1;
2278 return NULL;
2279 }
2280 goto done;
2281 }
2282 p->mark = mark;
2283 }
2284 res = NULL;
2285 done:
2286 return res;
2287}
2288
2289// import_from:
2290// | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
2291// | 'from' (('.' | '...'))+ 'import' import_from_targets
2292static stmt_ty
2293import_from_rule(Parser *p)
2294{
2295 if (p->error_indicator) {
2296 return NULL;
2297 }
2298 stmt_ty res = NULL;
2299 int mark = p->mark;
2300 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2301 p->error_indicator = 1;
2302 return NULL;
2303 }
2304 int start_lineno = p->tokens[mark]->lineno;
2305 UNUSED(start_lineno); // Only used by EXTRA macro
2306 int start_col_offset = p->tokens[mark]->col_offset;
2307 UNUSED(start_col_offset); // Only used by EXTRA macro
2308 { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
2309 asdl_seq * a;
2310 expr_ty b;
2311 asdl_seq* c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002312 Token * keyword;
2313 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002314 if (
2315 (keyword = _PyPegen_expect_token(p, 514))
2316 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002317 (a = _loop0_30_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002318 &&
2319 (b = dotted_name_rule(p))
2320 &&
2321 (keyword_1 = _PyPegen_expect_token(p, 513))
2322 &&
2323 (c = import_from_targets_rule(p))
2324 )
2325 {
2326 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2327 if (token == NULL) {
2328 return NULL;
2329 }
2330 int end_lineno = token->end_lineno;
2331 UNUSED(end_lineno); // Only used by EXTRA macro
2332 int end_col_offset = token->end_col_offset;
2333 UNUSED(end_col_offset); // Only used by EXTRA macro
2334 res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA );
2335 if (res == NULL && PyErr_Occurred()) {
2336 p->error_indicator = 1;
2337 return NULL;
2338 }
2339 goto done;
2340 }
2341 p->mark = mark;
2342 }
2343 { // 'from' (('.' | '...'))+ 'import' import_from_targets
2344 asdl_seq * a;
2345 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002346 Token * keyword;
2347 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002348 if (
2349 (keyword = _PyPegen_expect_token(p, 514))
2350 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002351 (a = _loop1_31_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002352 &&
2353 (keyword_1 = _PyPegen_expect_token(p, 513))
2354 &&
2355 (b = import_from_targets_rule(p))
2356 )
2357 {
2358 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2359 if (token == NULL) {
2360 return NULL;
2361 }
2362 int end_lineno = token->end_lineno;
2363 UNUSED(end_lineno); // Only used by EXTRA macro
2364 int end_col_offset = token->end_col_offset;
2365 UNUSED(end_col_offset); // Only used by EXTRA macro
2366 res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA );
2367 if (res == NULL && PyErr_Occurred()) {
2368 p->error_indicator = 1;
2369 return NULL;
2370 }
2371 goto done;
2372 }
2373 p->mark = mark;
2374 }
2375 res = NULL;
2376 done:
2377 return res;
2378}
2379
2380// import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*'
2381static asdl_seq*
2382import_from_targets_rule(Parser *p)
2383{
2384 if (p->error_indicator) {
2385 return NULL;
2386 }
2387 asdl_seq* res = NULL;
2388 int mark = p->mark;
2389 { // '(' import_from_as_names ','? ')'
2390 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002391 Token * literal;
2392 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002393 void *opt_var;
2394 UNUSED(opt_var); // Silence compiler warnings
2395 if (
2396 (literal = _PyPegen_expect_token(p, 7))
2397 &&
2398 (a = import_from_as_names_rule(p))
2399 &&
2400 (opt_var = _PyPegen_expect_token(p, 12), 1)
2401 &&
2402 (literal_1 = _PyPegen_expect_token(p, 8))
2403 )
2404 {
2405 res = a;
2406 if (res == NULL && PyErr_Occurred()) {
2407 p->error_indicator = 1;
2408 return NULL;
2409 }
2410 goto done;
2411 }
2412 p->mark = mark;
2413 }
2414 { // import_from_as_names
2415 asdl_seq* import_from_as_names_var;
2416 if (
2417 (import_from_as_names_var = import_from_as_names_rule(p))
2418 )
2419 {
2420 res = import_from_as_names_var;
2421 goto done;
2422 }
2423 p->mark = mark;
2424 }
2425 { // '*'
Pablo Galindob796b3f2020-05-01 12:32:26 +01002426 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002427 if (
2428 (literal = _PyPegen_expect_token(p, 16))
2429 )
2430 {
2431 res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) );
2432 if (res == NULL && PyErr_Occurred()) {
2433 p->error_indicator = 1;
2434 return NULL;
2435 }
2436 goto done;
2437 }
2438 p->mark = mark;
2439 }
2440 res = NULL;
2441 done:
2442 return res;
2443}
2444
2445// import_from_as_names: ','.import_from_as_name+
2446static asdl_seq*
2447import_from_as_names_rule(Parser *p)
2448{
2449 if (p->error_indicator) {
2450 return NULL;
2451 }
2452 asdl_seq* res = NULL;
2453 int mark = p->mark;
2454 { // ','.import_from_as_name+
2455 asdl_seq * a;
2456 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07002457 (a = _gather_32_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002458 )
2459 {
2460 res = a;
2461 if (res == NULL && PyErr_Occurred()) {
2462 p->error_indicator = 1;
2463 return NULL;
2464 }
2465 goto done;
2466 }
2467 p->mark = mark;
2468 }
2469 res = NULL;
2470 done:
2471 return res;
2472}
2473
2474// import_from_as_name: NAME ['as' NAME]
2475static alias_ty
2476import_from_as_name_rule(Parser *p)
2477{
2478 if (p->error_indicator) {
2479 return NULL;
2480 }
2481 alias_ty res = NULL;
2482 int mark = p->mark;
2483 { // NAME ['as' NAME]
2484 expr_ty a;
2485 void *b;
2486 if (
2487 (a = _PyPegen_name_token(p))
2488 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002489 (b = _tmp_34_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002490 )
2491 {
2492 res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
2493 if (res == NULL && PyErr_Occurred()) {
2494 p->error_indicator = 1;
2495 return NULL;
2496 }
2497 goto done;
2498 }
2499 p->mark = mark;
2500 }
2501 res = NULL;
2502 done:
2503 return res;
2504}
2505
2506// dotted_as_names: ','.dotted_as_name+
2507static asdl_seq*
2508dotted_as_names_rule(Parser *p)
2509{
2510 if (p->error_indicator) {
2511 return NULL;
2512 }
2513 asdl_seq* res = NULL;
2514 int mark = p->mark;
2515 { // ','.dotted_as_name+
2516 asdl_seq * a;
2517 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07002518 (a = _gather_35_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002519 )
2520 {
2521 res = a;
2522 if (res == NULL && PyErr_Occurred()) {
2523 p->error_indicator = 1;
2524 return NULL;
2525 }
2526 goto done;
2527 }
2528 p->mark = mark;
2529 }
2530 res = NULL;
2531 done:
2532 return res;
2533}
2534
2535// dotted_as_name: dotted_name ['as' NAME]
2536static alias_ty
2537dotted_as_name_rule(Parser *p)
2538{
2539 if (p->error_indicator) {
2540 return NULL;
2541 }
2542 alias_ty res = NULL;
2543 int mark = p->mark;
2544 { // dotted_name ['as' NAME]
2545 expr_ty a;
2546 void *b;
2547 if (
2548 (a = dotted_name_rule(p))
2549 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07002550 (b = _tmp_37_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002551 )
2552 {
2553 res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
2554 if (res == NULL && PyErr_Occurred()) {
2555 p->error_indicator = 1;
2556 return NULL;
2557 }
2558 goto done;
2559 }
2560 p->mark = mark;
2561 }
2562 res = NULL;
2563 done:
2564 return res;
2565}
2566
2567// Left-recursive
2568// dotted_name: dotted_name '.' NAME | NAME
2569static expr_ty dotted_name_raw(Parser *);
2570static expr_ty
2571dotted_name_rule(Parser *p)
2572{
2573 expr_ty res = NULL;
2574 if (_PyPegen_is_memoized(p, dotted_name_type, &res))
2575 return res;
2576 int mark = p->mark;
2577 int resmark = p->mark;
2578 while (1) {
2579 int tmpvar_0 = _PyPegen_update_memo(p, mark, dotted_name_type, res);
2580 if (tmpvar_0) {
2581 return res;
2582 }
2583 p->mark = mark;
2584 void *raw = dotted_name_raw(p);
2585 if (raw == NULL || p->mark <= resmark)
2586 break;
2587 resmark = p->mark;
2588 res = raw;
2589 }
2590 p->mark = resmark;
2591 return res;
2592}
2593static expr_ty
2594dotted_name_raw(Parser *p)
2595{
2596 if (p->error_indicator) {
2597 return NULL;
2598 }
2599 expr_ty res = NULL;
2600 int mark = p->mark;
2601 { // dotted_name '.' NAME
2602 expr_ty a;
2603 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002604 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002605 if (
2606 (a = dotted_name_rule(p))
2607 &&
2608 (literal = _PyPegen_expect_token(p, 23))
2609 &&
2610 (b = _PyPegen_name_token(p))
2611 )
2612 {
2613 res = _PyPegen_join_names_with_dot ( p , a , b );
2614 if (res == NULL && PyErr_Occurred()) {
2615 p->error_indicator = 1;
2616 return NULL;
2617 }
2618 goto done;
2619 }
2620 p->mark = mark;
2621 }
2622 { // NAME
2623 expr_ty name_var;
2624 if (
2625 (name_var = _PyPegen_name_token(p))
2626 )
2627 {
2628 res = name_var;
2629 goto done;
2630 }
2631 p->mark = mark;
2632 }
2633 res = NULL;
2634 done:
2635 return res;
2636}
2637
2638// if_stmt:
2639// | 'if' named_expression ':' block elif_stmt
2640// | 'if' named_expression ':' block else_block?
2641static stmt_ty
2642if_stmt_rule(Parser *p)
2643{
2644 if (p->error_indicator) {
2645 return NULL;
2646 }
2647 stmt_ty res = NULL;
2648 int mark = p->mark;
2649 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2650 p->error_indicator = 1;
2651 return NULL;
2652 }
2653 int start_lineno = p->tokens[mark]->lineno;
2654 UNUSED(start_lineno); // Only used by EXTRA macro
2655 int start_col_offset = p->tokens[mark]->col_offset;
2656 UNUSED(start_col_offset); // Only used by EXTRA macro
2657 { // 'if' named_expression ':' block elif_stmt
2658 expr_ty a;
2659 asdl_seq* b;
2660 stmt_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002661 Token * keyword;
2662 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002663 if (
2664 (keyword = _PyPegen_expect_token(p, 510))
2665 &&
2666 (a = named_expression_rule(p))
2667 &&
2668 (literal = _PyPegen_expect_token(p, 11))
2669 &&
2670 (b = block_rule(p))
2671 &&
2672 (c = elif_stmt_rule(p))
2673 )
2674 {
2675 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2676 if (token == NULL) {
2677 return NULL;
2678 }
2679 int end_lineno = token->end_lineno;
2680 UNUSED(end_lineno); // Only used by EXTRA macro
2681 int end_col_offset = token->end_col_offset;
2682 UNUSED(end_col_offset); // Only used by EXTRA macro
2683 res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
2684 if (res == NULL && PyErr_Occurred()) {
2685 p->error_indicator = 1;
2686 return NULL;
2687 }
2688 goto done;
2689 }
2690 p->mark = mark;
2691 }
2692 { // 'if' named_expression ':' block else_block?
2693 expr_ty a;
2694 asdl_seq* b;
2695 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002696 Token * keyword;
2697 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002698 if (
2699 (keyword = _PyPegen_expect_token(p, 510))
2700 &&
2701 (a = named_expression_rule(p))
2702 &&
2703 (literal = _PyPegen_expect_token(p, 11))
2704 &&
2705 (b = block_rule(p))
2706 &&
2707 (c = else_block_rule(p), 1)
2708 )
2709 {
2710 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2711 if (token == NULL) {
2712 return NULL;
2713 }
2714 int end_lineno = token->end_lineno;
2715 UNUSED(end_lineno); // Only used by EXTRA macro
2716 int end_col_offset = token->end_col_offset;
2717 UNUSED(end_col_offset); // Only used by EXTRA macro
2718 res = _Py_If ( a , b , c , EXTRA );
2719 if (res == NULL && PyErr_Occurred()) {
2720 p->error_indicator = 1;
2721 return NULL;
2722 }
2723 goto done;
2724 }
2725 p->mark = mark;
2726 }
2727 res = NULL;
2728 done:
2729 return res;
2730}
2731
2732// elif_stmt:
2733// | 'elif' named_expression ':' block elif_stmt
2734// | 'elif' named_expression ':' block else_block?
2735static stmt_ty
2736elif_stmt_rule(Parser *p)
2737{
2738 if (p->error_indicator) {
2739 return NULL;
2740 }
2741 stmt_ty res = NULL;
2742 int mark = p->mark;
2743 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2744 p->error_indicator = 1;
2745 return NULL;
2746 }
2747 int start_lineno = p->tokens[mark]->lineno;
2748 UNUSED(start_lineno); // Only used by EXTRA macro
2749 int start_col_offset = p->tokens[mark]->col_offset;
2750 UNUSED(start_col_offset); // Only used by EXTRA macro
2751 { // 'elif' named_expression ':' block elif_stmt
2752 expr_ty a;
2753 asdl_seq* b;
2754 stmt_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002755 Token * keyword;
2756 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002757 if (
2758 (keyword = _PyPegen_expect_token(p, 515))
2759 &&
2760 (a = named_expression_rule(p))
2761 &&
2762 (literal = _PyPegen_expect_token(p, 11))
2763 &&
2764 (b = block_rule(p))
2765 &&
2766 (c = elif_stmt_rule(p))
2767 )
2768 {
2769 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2770 if (token == NULL) {
2771 return NULL;
2772 }
2773 int end_lineno = token->end_lineno;
2774 UNUSED(end_lineno); // Only used by EXTRA macro
2775 int end_col_offset = token->end_col_offset;
2776 UNUSED(end_col_offset); // Only used by EXTRA macro
2777 res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
2778 if (res == NULL && PyErr_Occurred()) {
2779 p->error_indicator = 1;
2780 return NULL;
2781 }
2782 goto done;
2783 }
2784 p->mark = mark;
2785 }
2786 { // 'elif' named_expression ':' block else_block?
2787 expr_ty a;
2788 asdl_seq* b;
2789 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002790 Token * keyword;
2791 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002792 if (
2793 (keyword = _PyPegen_expect_token(p, 515))
2794 &&
2795 (a = named_expression_rule(p))
2796 &&
2797 (literal = _PyPegen_expect_token(p, 11))
2798 &&
2799 (b = block_rule(p))
2800 &&
2801 (c = else_block_rule(p), 1)
2802 )
2803 {
2804 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2805 if (token == NULL) {
2806 return NULL;
2807 }
2808 int end_lineno = token->end_lineno;
2809 UNUSED(end_lineno); // Only used by EXTRA macro
2810 int end_col_offset = token->end_col_offset;
2811 UNUSED(end_col_offset); // Only used by EXTRA macro
2812 res = _Py_If ( a , b , c , EXTRA );
2813 if (res == NULL && PyErr_Occurred()) {
2814 p->error_indicator = 1;
2815 return NULL;
2816 }
2817 goto done;
2818 }
2819 p->mark = mark;
2820 }
2821 res = NULL;
2822 done:
2823 return res;
2824}
2825
2826// else_block: 'else' ':' block
2827static asdl_seq*
2828else_block_rule(Parser *p)
2829{
2830 if (p->error_indicator) {
2831 return NULL;
2832 }
2833 asdl_seq* res = NULL;
2834 int mark = p->mark;
2835 { // 'else' ':' block
2836 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002837 Token * keyword;
2838 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002839 if (
2840 (keyword = _PyPegen_expect_token(p, 516))
2841 &&
2842 (literal = _PyPegen_expect_token(p, 11))
2843 &&
2844 (b = block_rule(p))
2845 )
2846 {
2847 res = b;
2848 if (res == NULL && PyErr_Occurred()) {
2849 p->error_indicator = 1;
2850 return NULL;
2851 }
2852 goto done;
2853 }
2854 p->mark = mark;
2855 }
2856 res = NULL;
2857 done:
2858 return res;
2859}
2860
2861// while_stmt: 'while' named_expression ':' block else_block?
2862static stmt_ty
2863while_stmt_rule(Parser *p)
2864{
2865 if (p->error_indicator) {
2866 return NULL;
2867 }
2868 stmt_ty res = NULL;
2869 int mark = p->mark;
2870 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2871 p->error_indicator = 1;
2872 return NULL;
2873 }
2874 int start_lineno = p->tokens[mark]->lineno;
2875 UNUSED(start_lineno); // Only used by EXTRA macro
2876 int start_col_offset = p->tokens[mark]->col_offset;
2877 UNUSED(start_col_offset); // Only used by EXTRA macro
2878 { // 'while' named_expression ':' block else_block?
2879 expr_ty a;
2880 asdl_seq* b;
2881 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002882 Token * keyword;
2883 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002884 if (
2885 (keyword = _PyPegen_expect_token(p, 512))
2886 &&
2887 (a = named_expression_rule(p))
2888 &&
2889 (literal = _PyPegen_expect_token(p, 11))
2890 &&
2891 (b = block_rule(p))
2892 &&
2893 (c = else_block_rule(p), 1)
2894 )
2895 {
2896 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2897 if (token == NULL) {
2898 return NULL;
2899 }
2900 int end_lineno = token->end_lineno;
2901 UNUSED(end_lineno); // Only used by EXTRA macro
2902 int end_col_offset = token->end_col_offset;
2903 UNUSED(end_col_offset); // Only used by EXTRA macro
2904 res = _Py_While ( a , b , c , EXTRA );
2905 if (res == NULL && PyErr_Occurred()) {
2906 p->error_indicator = 1;
2907 return NULL;
2908 }
2909 goto done;
2910 }
2911 p->mark = mark;
2912 }
2913 res = NULL;
2914 done:
2915 return res;
2916}
2917
Guido van Rossumc001c092020-04-30 12:12:19 -07002918// for_stmt:
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002919// | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
2920// | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002921static stmt_ty
2922for_stmt_rule(Parser *p)
2923{
2924 if (p->error_indicator) {
2925 return NULL;
2926 }
2927 stmt_ty res = NULL;
2928 int mark = p->mark;
2929 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2930 p->error_indicator = 1;
2931 return NULL;
2932 }
2933 int start_lineno = p->tokens[mark]->lineno;
2934 UNUSED(start_lineno); // Only used by EXTRA macro
2935 int start_col_offset = p->tokens[mark]->col_offset;
2936 UNUSED(start_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002937 { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002938 asdl_seq* b;
2939 void *el;
2940 expr_ty ex;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002941 Token * keyword;
2942 Token * keyword_1;
2943 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002944 expr_ty t;
Guido van Rossumc001c092020-04-30 12:12:19 -07002945 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002946 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002947 (keyword = _PyPegen_expect_token(p, 517))
2948 &&
2949 (t = star_targets_rule(p))
2950 &&
2951 (keyword_1 = _PyPegen_expect_token(p, 518))
2952 &&
2953 (ex = star_expressions_rule(p))
2954 &&
2955 (literal = _PyPegen_expect_token(p, 11))
2956 &&
2957 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
2958 &&
2959 (b = block_rule(p))
2960 &&
2961 (el = else_block_rule(p), 1)
2962 )
2963 {
2964 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2965 if (token == NULL) {
2966 return NULL;
2967 }
2968 int end_lineno = token->end_lineno;
2969 UNUSED(end_lineno); // Only used by EXTRA macro
2970 int end_col_offset = token->end_col_offset;
2971 UNUSED(end_col_offset); // Only used by EXTRA macro
2972 res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
2973 if (res == NULL && PyErr_Occurred()) {
2974 p->error_indicator = 1;
2975 return NULL;
2976 }
2977 goto done;
2978 }
2979 p->mark = mark;
2980 }
2981 { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
Pablo Galindob796b3f2020-05-01 12:32:26 +01002982 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002983 asdl_seq* b;
2984 void *el;
2985 expr_ty ex;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002986 Token * keyword;
2987 Token * keyword_1;
2988 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002989 expr_ty t;
2990 void *tc;
2991 if (
2992 (async_var = _PyPegen_expect_token(p, ASYNC))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002993 &&
2994 (keyword = _PyPegen_expect_token(p, 517))
2995 &&
2996 (t = star_targets_rule(p))
2997 &&
2998 (keyword_1 = _PyPegen_expect_token(p, 518))
2999 &&
3000 (ex = star_expressions_rule(p))
3001 &&
3002 (literal = _PyPegen_expect_token(p, 11))
3003 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003004 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
3005 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003006 (b = block_rule(p))
3007 &&
3008 (el = else_block_rule(p), 1)
3009 )
3010 {
3011 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3012 if (token == NULL) {
3013 return NULL;
3014 }
3015 int end_lineno = token->end_lineno;
3016 UNUSED(end_lineno); // Only used by EXTRA macro
3017 int end_col_offset = token->end_col_offset;
3018 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003019 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 +01003020 if (res == NULL && PyErr_Occurred()) {
3021 p->error_indicator = 1;
3022 return NULL;
3023 }
3024 goto done;
3025 }
3026 p->mark = mark;
3027 }
3028 res = NULL;
3029 done:
3030 return res;
3031}
3032
3033// with_stmt:
Pablo Galindo99db2a12020-05-06 22:54:34 +01003034// | 'with' '(' ','.with_item+ ','? ')' ':' block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003035// | 'with' ','.with_item+ ':' TYPE_COMMENT? block
Pablo Galindo99db2a12020-05-06 22:54:34 +01003036// | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003037// | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003038static stmt_ty
3039with_stmt_rule(Parser *p)
3040{
3041 if (p->error_indicator) {
3042 return NULL;
3043 }
3044 stmt_ty res = NULL;
3045 int mark = p->mark;
3046 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3047 p->error_indicator = 1;
3048 return NULL;
3049 }
3050 int start_lineno = p->tokens[mark]->lineno;
3051 UNUSED(start_lineno); // Only used by EXTRA macro
3052 int start_col_offset = p->tokens[mark]->col_offset;
3053 UNUSED(start_col_offset); // Only used by EXTRA macro
Pablo Galindo99db2a12020-05-06 22:54:34 +01003054 { // 'with' '(' ','.with_item+ ','? ')' ':' block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003055 asdl_seq * a;
3056 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003057 Token * keyword;
3058 Token * literal;
3059 Token * literal_1;
3060 Token * literal_2;
Pablo Galindo99db2a12020-05-06 22:54:34 +01003061 void *opt_var;
3062 UNUSED(opt_var); // Silence compiler warnings
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003063 if (
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003064 (keyword = _PyPegen_expect_token(p, 519))
3065 &&
3066 (literal = _PyPegen_expect_token(p, 7))
3067 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003068 (a = _gather_38_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003069 &&
Pablo Galindo99db2a12020-05-06 22:54:34 +01003070 (opt_var = _PyPegen_expect_token(p, 12), 1)
3071 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003072 (literal_1 = _PyPegen_expect_token(p, 8))
3073 &&
3074 (literal_2 = _PyPegen_expect_token(p, 11))
3075 &&
3076 (b = block_rule(p))
3077 )
3078 {
3079 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3080 if (token == NULL) {
3081 return NULL;
3082 }
3083 int end_lineno = token->end_lineno;
3084 UNUSED(end_lineno); // Only used by EXTRA macro
3085 int end_col_offset = token->end_col_offset;
3086 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003087 res = _Py_With ( a , b , NULL , EXTRA );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003088 if (res == NULL && PyErr_Occurred()) {
3089 p->error_indicator = 1;
3090 return NULL;
3091 }
3092 goto done;
3093 }
3094 p->mark = mark;
3095 }
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003096 { // 'with' ','.with_item+ ':' TYPE_COMMENT? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003097 asdl_seq * a;
3098 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003099 Token * keyword;
3100 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07003101 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003102 if (
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003103 (keyword = _PyPegen_expect_token(p, 519))
3104 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003105 (a = _gather_40_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003106 &&
3107 (literal = _PyPegen_expect_token(p, 11))
3108 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003109 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
3110 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003111 (b = block_rule(p))
3112 )
3113 {
3114 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3115 if (token == NULL) {
3116 return NULL;
3117 }
3118 int end_lineno = token->end_lineno;
3119 UNUSED(end_lineno); // Only used by EXTRA macro
3120 int end_col_offset = token->end_col_offset;
3121 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003122 res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
3123 if (res == NULL && PyErr_Occurred()) {
3124 p->error_indicator = 1;
3125 return NULL;
3126 }
3127 goto done;
3128 }
3129 p->mark = mark;
3130 }
Pablo Galindo99db2a12020-05-06 22:54:34 +01003131 { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003132 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003133 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003134 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003135 Token * keyword;
3136 Token * literal;
3137 Token * literal_1;
3138 Token * literal_2;
Pablo Galindo99db2a12020-05-06 22:54:34 +01003139 void *opt_var;
3140 UNUSED(opt_var); // Silence compiler warnings
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003141 if (
3142 (async_var = _PyPegen_expect_token(p, ASYNC))
3143 &&
3144 (keyword = _PyPegen_expect_token(p, 519))
3145 &&
3146 (literal = _PyPegen_expect_token(p, 7))
3147 &&
3148 (a = _gather_42_rule(p))
3149 &&
Pablo Galindo99db2a12020-05-06 22:54:34 +01003150 (opt_var = _PyPegen_expect_token(p, 12), 1)
3151 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003152 (literal_1 = _PyPegen_expect_token(p, 8))
3153 &&
3154 (literal_2 = _PyPegen_expect_token(p, 11))
3155 &&
3156 (b = block_rule(p))
3157 )
3158 {
3159 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3160 if (token == NULL) {
3161 return NULL;
3162 }
3163 int end_lineno = token->end_lineno;
3164 UNUSED(end_lineno); // Only used by EXTRA macro
3165 int end_col_offset = token->end_col_offset;
3166 UNUSED(end_col_offset); // Only used by EXTRA macro
3167 res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) );
3168 if (res == NULL && PyErr_Occurred()) {
3169 p->error_indicator = 1;
3170 return NULL;
3171 }
3172 goto done;
3173 }
3174 p->mark = mark;
3175 }
3176 { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
3177 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003178 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003179 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003180 Token * keyword;
3181 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003182 void *tc;
3183 if (
3184 (async_var = _PyPegen_expect_token(p, ASYNC))
3185 &&
3186 (keyword = _PyPegen_expect_token(p, 519))
3187 &&
3188 (a = _gather_44_rule(p))
3189 &&
3190 (literal = _PyPegen_expect_token(p, 11))
3191 &&
3192 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
3193 &&
3194 (b = block_rule(p))
3195 )
3196 {
3197 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3198 if (token == NULL) {
3199 return NULL;
3200 }
3201 int end_lineno = token->end_lineno;
3202 UNUSED(end_lineno); // Only used by EXTRA macro
3203 int end_col_offset = token->end_col_offset;
3204 UNUSED(end_col_offset); // Only used by EXTRA macro
3205 res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003206 if (res == NULL && PyErr_Occurred()) {
3207 p->error_indicator = 1;
3208 return NULL;
3209 }
3210 goto done;
3211 }
3212 p->mark = mark;
3213 }
3214 res = NULL;
3215 done:
3216 return res;
3217}
3218
3219// with_item: expression ['as' target]
3220static withitem_ty
3221with_item_rule(Parser *p)
3222{
3223 if (p->error_indicator) {
3224 return NULL;
3225 }
3226 withitem_ty res = NULL;
3227 int mark = p->mark;
3228 { // expression ['as' target]
3229 expr_ty e;
3230 void *o;
3231 if (
3232 (e = expression_rule(p))
3233 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003234 (o = _tmp_46_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003235 )
3236 {
3237 res = _Py_withitem ( e , o , p -> arena );
3238 if (res == NULL && PyErr_Occurred()) {
3239 p->error_indicator = 1;
3240 return NULL;
3241 }
3242 goto done;
3243 }
3244 p->mark = mark;
3245 }
3246 res = NULL;
3247 done:
3248 return res;
3249}
3250
3251// try_stmt:
3252// | 'try' ':' block finally_block
3253// | 'try' ':' block except_block+ else_block? finally_block?
3254static stmt_ty
3255try_stmt_rule(Parser *p)
3256{
3257 if (p->error_indicator) {
3258 return NULL;
3259 }
3260 stmt_ty res = NULL;
3261 int mark = p->mark;
3262 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3263 p->error_indicator = 1;
3264 return NULL;
3265 }
3266 int start_lineno = p->tokens[mark]->lineno;
3267 UNUSED(start_lineno); // Only used by EXTRA macro
3268 int start_col_offset = p->tokens[mark]->col_offset;
3269 UNUSED(start_col_offset); // Only used by EXTRA macro
3270 { // 'try' ':' block finally_block
3271 asdl_seq* b;
3272 asdl_seq* f;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003273 Token * keyword;
3274 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003275 if (
3276 (keyword = _PyPegen_expect_token(p, 511))
3277 &&
3278 (literal = _PyPegen_expect_token(p, 11))
3279 &&
3280 (b = block_rule(p))
3281 &&
3282 (f = finally_block_rule(p))
3283 )
3284 {
3285 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3286 if (token == NULL) {
3287 return NULL;
3288 }
3289 int end_lineno = token->end_lineno;
3290 UNUSED(end_lineno); // Only used by EXTRA macro
3291 int end_col_offset = token->end_col_offset;
3292 UNUSED(end_col_offset); // Only used by EXTRA macro
3293 res = _Py_Try ( b , NULL , NULL , f , EXTRA );
3294 if (res == NULL && PyErr_Occurred()) {
3295 p->error_indicator = 1;
3296 return NULL;
3297 }
3298 goto done;
3299 }
3300 p->mark = mark;
3301 }
3302 { // 'try' ':' block except_block+ else_block? finally_block?
3303 asdl_seq* b;
3304 void *el;
3305 asdl_seq * ex;
3306 void *f;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003307 Token * keyword;
3308 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003309 if (
3310 (keyword = _PyPegen_expect_token(p, 511))
3311 &&
3312 (literal = _PyPegen_expect_token(p, 11))
3313 &&
3314 (b = block_rule(p))
3315 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003316 (ex = _loop1_47_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003317 &&
3318 (el = else_block_rule(p), 1)
3319 &&
3320 (f = finally_block_rule(p), 1)
3321 )
3322 {
3323 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3324 if (token == NULL) {
3325 return NULL;
3326 }
3327 int end_lineno = token->end_lineno;
3328 UNUSED(end_lineno); // Only used by EXTRA macro
3329 int end_col_offset = token->end_col_offset;
3330 UNUSED(end_col_offset); // Only used by EXTRA macro
3331 res = _Py_Try ( b , ex , el , f , EXTRA );
3332 if (res == NULL && PyErr_Occurred()) {
3333 p->error_indicator = 1;
3334 return NULL;
3335 }
3336 goto done;
3337 }
3338 p->mark = mark;
3339 }
3340 res = NULL;
3341 done:
3342 return res;
3343}
3344
3345// except_block: 'except' expression ['as' target] ':' block | 'except' ':' block
3346static excepthandler_ty
3347except_block_rule(Parser *p)
3348{
3349 if (p->error_indicator) {
3350 return NULL;
3351 }
3352 excepthandler_ty res = NULL;
3353 int mark = p->mark;
3354 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3355 p->error_indicator = 1;
3356 return NULL;
3357 }
3358 int start_lineno = p->tokens[mark]->lineno;
3359 UNUSED(start_lineno); // Only used by EXTRA macro
3360 int start_col_offset = p->tokens[mark]->col_offset;
3361 UNUSED(start_col_offset); // Only used by EXTRA macro
3362 { // 'except' expression ['as' target] ':' block
3363 asdl_seq* b;
3364 expr_ty e;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003365 Token * keyword;
3366 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003367 void *t;
3368 if (
3369 (keyword = _PyPegen_expect_token(p, 520))
3370 &&
3371 (e = expression_rule(p))
3372 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003373 (t = _tmp_48_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003374 &&
3375 (literal = _PyPegen_expect_token(p, 11))
3376 &&
3377 (b = block_rule(p))
3378 )
3379 {
3380 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3381 if (token == NULL) {
3382 return NULL;
3383 }
3384 int end_lineno = token->end_lineno;
3385 UNUSED(end_lineno); // Only used by EXTRA macro
3386 int end_col_offset = token->end_col_offset;
3387 UNUSED(end_col_offset); // Only used by EXTRA macro
3388 res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA );
3389 if (res == NULL && PyErr_Occurred()) {
3390 p->error_indicator = 1;
3391 return NULL;
3392 }
3393 goto done;
3394 }
3395 p->mark = mark;
3396 }
3397 { // 'except' ':' block
3398 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003399 Token * keyword;
3400 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003401 if (
3402 (keyword = _PyPegen_expect_token(p, 520))
3403 &&
3404 (literal = _PyPegen_expect_token(p, 11))
3405 &&
3406 (b = block_rule(p))
3407 )
3408 {
3409 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3410 if (token == NULL) {
3411 return NULL;
3412 }
3413 int end_lineno = token->end_lineno;
3414 UNUSED(end_lineno); // Only used by EXTRA macro
3415 int end_col_offset = token->end_col_offset;
3416 UNUSED(end_col_offset); // Only used by EXTRA macro
3417 res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA );
3418 if (res == NULL && PyErr_Occurred()) {
3419 p->error_indicator = 1;
3420 return NULL;
3421 }
3422 goto done;
3423 }
3424 p->mark = mark;
3425 }
3426 res = NULL;
3427 done:
3428 return res;
3429}
3430
3431// finally_block: 'finally' ':' block
3432static asdl_seq*
3433finally_block_rule(Parser *p)
3434{
3435 if (p->error_indicator) {
3436 return NULL;
3437 }
3438 asdl_seq* res = NULL;
3439 int mark = p->mark;
3440 { // 'finally' ':' block
3441 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003442 Token * keyword;
3443 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003444 if (
3445 (keyword = _PyPegen_expect_token(p, 521))
3446 &&
3447 (literal = _PyPegen_expect_token(p, 11))
3448 &&
3449 (a = block_rule(p))
3450 )
3451 {
3452 res = a;
3453 if (res == NULL && PyErr_Occurred()) {
3454 p->error_indicator = 1;
3455 return NULL;
3456 }
3457 goto done;
3458 }
3459 p->mark = mark;
3460 }
3461 res = NULL;
3462 done:
3463 return res;
3464}
3465
3466// return_stmt: 'return' star_expressions?
3467static stmt_ty
3468return_stmt_rule(Parser *p)
3469{
3470 if (p->error_indicator) {
3471 return NULL;
3472 }
3473 stmt_ty res = NULL;
3474 int mark = p->mark;
3475 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3476 p->error_indicator = 1;
3477 return NULL;
3478 }
3479 int start_lineno = p->tokens[mark]->lineno;
3480 UNUSED(start_lineno); // Only used by EXTRA macro
3481 int start_col_offset = p->tokens[mark]->col_offset;
3482 UNUSED(start_col_offset); // Only used by EXTRA macro
3483 { // 'return' star_expressions?
3484 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003485 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003486 if (
3487 (keyword = _PyPegen_expect_token(p, 500))
3488 &&
3489 (a = star_expressions_rule(p), 1)
3490 )
3491 {
3492 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3493 if (token == NULL) {
3494 return NULL;
3495 }
3496 int end_lineno = token->end_lineno;
3497 UNUSED(end_lineno); // Only used by EXTRA macro
3498 int end_col_offset = token->end_col_offset;
3499 UNUSED(end_col_offset); // Only used by EXTRA macro
3500 res = _Py_Return ( a , EXTRA );
3501 if (res == NULL && PyErr_Occurred()) {
3502 p->error_indicator = 1;
3503 return NULL;
3504 }
3505 goto done;
3506 }
3507 p->mark = mark;
3508 }
3509 res = NULL;
3510 done:
3511 return res;
3512}
3513
3514// raise_stmt: 'raise' expression ['from' expression] | 'raise'
3515static stmt_ty
3516raise_stmt_rule(Parser *p)
3517{
3518 if (p->error_indicator) {
3519 return NULL;
3520 }
3521 stmt_ty res = NULL;
3522 int mark = p->mark;
3523 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3524 p->error_indicator = 1;
3525 return NULL;
3526 }
3527 int start_lineno = p->tokens[mark]->lineno;
3528 UNUSED(start_lineno); // Only used by EXTRA macro
3529 int start_col_offset = p->tokens[mark]->col_offset;
3530 UNUSED(start_col_offset); // Only used by EXTRA macro
3531 { // 'raise' expression ['from' expression]
3532 expr_ty a;
3533 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003534 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003535 if (
3536 (keyword = _PyPegen_expect_token(p, 501))
3537 &&
3538 (a = expression_rule(p))
3539 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003540 (b = _tmp_49_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003541 )
3542 {
3543 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3544 if (token == NULL) {
3545 return NULL;
3546 }
3547 int end_lineno = token->end_lineno;
3548 UNUSED(end_lineno); // Only used by EXTRA macro
3549 int end_col_offset = token->end_col_offset;
3550 UNUSED(end_col_offset); // Only used by EXTRA macro
3551 res = _Py_Raise ( a , b , EXTRA );
3552 if (res == NULL && PyErr_Occurred()) {
3553 p->error_indicator = 1;
3554 return NULL;
3555 }
3556 goto done;
3557 }
3558 p->mark = mark;
3559 }
3560 { // 'raise'
Pablo Galindob796b3f2020-05-01 12:32:26 +01003561 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003562 if (
3563 (keyword = _PyPegen_expect_token(p, 501))
3564 )
3565 {
3566 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3567 if (token == NULL) {
3568 return NULL;
3569 }
3570 int end_lineno = token->end_lineno;
3571 UNUSED(end_lineno); // Only used by EXTRA macro
3572 int end_col_offset = token->end_col_offset;
3573 UNUSED(end_col_offset); // Only used by EXTRA macro
3574 res = _Py_Raise ( NULL , NULL , EXTRA );
3575 if (res == NULL && PyErr_Occurred()) {
3576 p->error_indicator = 1;
3577 return NULL;
3578 }
3579 goto done;
3580 }
3581 p->mark = mark;
3582 }
3583 res = NULL;
3584 done:
3585 return res;
3586}
3587
3588// function_def: decorators function_def_raw | function_def_raw
3589static stmt_ty
3590function_def_rule(Parser *p)
3591{
3592 if (p->error_indicator) {
3593 return NULL;
3594 }
3595 stmt_ty res = NULL;
3596 int mark = p->mark;
3597 { // decorators function_def_raw
3598 asdl_seq* d;
3599 stmt_ty f;
3600 if (
3601 (d = decorators_rule(p))
3602 &&
3603 (f = function_def_raw_rule(p))
3604 )
3605 {
3606 res = _PyPegen_function_def_decorators ( p , d , f );
3607 if (res == NULL && PyErr_Occurred()) {
3608 p->error_indicator = 1;
3609 return NULL;
3610 }
3611 goto done;
3612 }
3613 p->mark = mark;
3614 }
3615 { // function_def_raw
3616 stmt_ty function_def_raw_var;
3617 if (
3618 (function_def_raw_var = function_def_raw_rule(p))
3619 )
3620 {
3621 res = function_def_raw_var;
3622 goto done;
3623 }
3624 p->mark = mark;
3625 }
3626 res = NULL;
3627 done:
3628 return res;
3629}
3630
Guido van Rossumc001c092020-04-30 12:12:19 -07003631// function_def_raw:
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003632// | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
3633// | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003634static stmt_ty
3635function_def_raw_rule(Parser *p)
3636{
3637 if (p->error_indicator) {
3638 return NULL;
3639 }
3640 stmt_ty res = NULL;
3641 int mark = p->mark;
3642 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3643 p->error_indicator = 1;
3644 return NULL;
3645 }
3646 int start_lineno = p->tokens[mark]->lineno;
3647 UNUSED(start_lineno); // Only used by EXTRA macro
3648 int start_col_offset = p->tokens[mark]->col_offset;
3649 UNUSED(start_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003650 { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003651 void *a;
3652 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003653 Token * keyword;
3654 Token * literal;
3655 Token * literal_1;
3656 Token * literal_2;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003657 expr_ty n;
3658 void *params;
Guido van Rossumc001c092020-04-30 12:12:19 -07003659 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003660 if (
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003661 (keyword = _PyPegen_expect_token(p, 522))
3662 &&
3663 (n = _PyPegen_name_token(p))
3664 &&
3665 (literal = _PyPegen_expect_token(p, 7))
3666 &&
3667 (params = params_rule(p), 1)
3668 &&
3669 (literal_1 = _PyPegen_expect_token(p, 8))
3670 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003671 (a = _tmp_50_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003672 &&
3673 (literal_2 = _PyPegen_expect_token(p, 11))
3674 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003675 (tc = func_type_comment_rule(p), 1)
3676 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003677 (b = block_rule(p))
3678 )
3679 {
3680 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3681 if (token == NULL) {
3682 return NULL;
3683 }
3684 int end_lineno = token->end_lineno;
3685 UNUSED(end_lineno); // Only used by EXTRA macro
3686 int end_col_offset = token->end_col_offset;
3687 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003688 res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
3689 if (res == NULL && PyErr_Occurred()) {
3690 p->error_indicator = 1;
3691 return NULL;
3692 }
3693 goto done;
3694 }
3695 p->mark = mark;
3696 }
3697 { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
3698 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003699 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003700 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003701 Token * keyword;
3702 Token * literal;
3703 Token * literal_1;
3704 Token * literal_2;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003705 expr_ty n;
3706 void *params;
3707 void *tc;
3708 if (
3709 (async_var = _PyPegen_expect_token(p, ASYNC))
3710 &&
3711 (keyword = _PyPegen_expect_token(p, 522))
3712 &&
3713 (n = _PyPegen_name_token(p))
3714 &&
3715 (literal = _PyPegen_expect_token(p, 7))
3716 &&
3717 (params = params_rule(p), 1)
3718 &&
3719 (literal_1 = _PyPegen_expect_token(p, 8))
3720 &&
3721 (a = _tmp_51_rule(p), 1)
3722 &&
3723 (literal_2 = _PyPegen_expect_token(p, 11))
3724 &&
3725 (tc = func_type_comment_rule(p), 1)
3726 &&
3727 (b = block_rule(p))
3728 )
3729 {
3730 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3731 if (token == NULL) {
3732 return NULL;
3733 }
3734 int end_lineno = token->end_lineno;
3735 UNUSED(end_lineno); // Only used by EXTRA macro
3736 int end_col_offset = token->end_col_offset;
3737 UNUSED(end_col_offset); // Only used by EXTRA macro
3738 res = CHECK_VERSION ( 5 , "Async functions are" , _Py_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003739 if (res == NULL && PyErr_Occurred()) {
3740 p->error_indicator = 1;
3741 return NULL;
3742 }
3743 goto done;
3744 }
3745 p->mark = mark;
3746 }
3747 res = NULL;
3748 done:
3749 return res;
3750}
3751
Guido van Rossumc001c092020-04-30 12:12:19 -07003752// func_type_comment:
3753// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
3754// | invalid_double_type_comments
3755// | TYPE_COMMENT
Pablo Galindod9552412020-05-01 16:32:09 +01003756static Token*
Guido van Rossumc001c092020-04-30 12:12:19 -07003757func_type_comment_rule(Parser *p)
3758{
3759 if (p->error_indicator) {
3760 return NULL;
3761 }
Pablo Galindod9552412020-05-01 16:32:09 +01003762 Token* res = NULL;
Guido van Rossumc001c092020-04-30 12:12:19 -07003763 int mark = p->mark;
3764 { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
Pablo Galindob796b3f2020-05-01 12:32:26 +01003765 Token * newline_var;
3766 Token * t;
Guido van Rossumc001c092020-04-30 12:12:19 -07003767 if (
3768 (newline_var = _PyPegen_expect_token(p, NEWLINE))
3769 &&
3770 (t = _PyPegen_expect_token(p, TYPE_COMMENT))
3771 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003772 _PyPegen_lookahead(1, _tmp_52_rule, p)
Guido van Rossumc001c092020-04-30 12:12:19 -07003773 )
3774 {
3775 res = t;
3776 if (res == NULL && PyErr_Occurred()) {
3777 p->error_indicator = 1;
3778 return NULL;
3779 }
3780 goto done;
3781 }
3782 p->mark = mark;
3783 }
3784 { // invalid_double_type_comments
3785 void *invalid_double_type_comments_var;
3786 if (
3787 (invalid_double_type_comments_var = invalid_double_type_comments_rule(p))
3788 )
3789 {
3790 res = invalid_double_type_comments_var;
3791 goto done;
3792 }
3793 p->mark = mark;
3794 }
3795 { // TYPE_COMMENT
Pablo Galindob796b3f2020-05-01 12:32:26 +01003796 Token * type_comment_var;
Guido van Rossumc001c092020-04-30 12:12:19 -07003797 if (
3798 (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT))
3799 )
3800 {
3801 res = type_comment_var;
3802 goto done;
3803 }
3804 p->mark = mark;
3805 }
3806 res = NULL;
3807 done:
3808 return res;
3809}
3810
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003811// params: invalid_parameters | parameters
3812static arguments_ty
3813params_rule(Parser *p)
3814{
3815 if (p->error_indicator) {
3816 return NULL;
3817 }
3818 arguments_ty res = NULL;
3819 int mark = p->mark;
3820 { // invalid_parameters
3821 void *invalid_parameters_var;
3822 if (
3823 (invalid_parameters_var = invalid_parameters_rule(p))
3824 )
3825 {
3826 res = invalid_parameters_var;
3827 goto done;
3828 }
3829 p->mark = mark;
3830 }
3831 { // parameters
3832 arguments_ty parameters_var;
3833 if (
3834 (parameters_var = parameters_rule(p))
3835 )
3836 {
3837 res = parameters_var;
3838 goto done;
3839 }
3840 p->mark = mark;
3841 }
3842 res = NULL;
3843 done:
3844 return res;
3845}
3846
3847// parameters:
Guido van Rossumc001c092020-04-30 12:12:19 -07003848// | slash_no_default param_no_default* param_with_default* star_etc?
3849// | slash_with_default param_with_default* star_etc?
3850// | param_no_default+ param_with_default* star_etc?
3851// | param_with_default+ star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003852// | star_etc
3853static arguments_ty
3854parameters_rule(Parser *p)
3855{
3856 if (p->error_indicator) {
3857 return NULL;
3858 }
3859 arguments_ty res = NULL;
3860 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07003861 { // slash_no_default param_no_default* param_with_default* star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003862 asdl_seq* a;
Guido van Rossumc001c092020-04-30 12:12:19 -07003863 asdl_seq * b;
3864 asdl_seq * c;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003865 void *d;
3866 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07003867 (a = slash_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003868 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003869 (b = _loop0_53_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003870 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003871 (c = _loop0_54_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003872 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003873 (d = star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003874 )
3875 {
3876 res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
3877 if (res == NULL && PyErr_Occurred()) {
3878 p->error_indicator = 1;
3879 return NULL;
3880 }
3881 goto done;
3882 }
3883 p->mark = mark;
3884 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003885 { // slash_with_default param_with_default* star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003886 SlashWithDefault* a;
Guido van Rossumc001c092020-04-30 12:12:19 -07003887 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003888 void *c;
3889 if (
3890 (a = slash_with_default_rule(p))
3891 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003892 (b = _loop0_55_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003893 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003894 (c = star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003895 )
3896 {
3897 res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
3898 if (res == NULL && PyErr_Occurred()) {
3899 p->error_indicator = 1;
3900 return NULL;
3901 }
3902 goto done;
3903 }
3904 p->mark = mark;
3905 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003906 { // param_no_default+ param_with_default* star_etc?
3907 asdl_seq * a;
3908 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003909 void *c;
3910 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003911 (a = _loop1_56_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003912 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003913 (b = _loop0_57_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003914 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003915 (c = star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003916 )
3917 {
3918 res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
3919 if (res == NULL && PyErr_Occurred()) {
3920 p->error_indicator = 1;
3921 return NULL;
3922 }
3923 goto done;
3924 }
3925 p->mark = mark;
3926 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003927 { // param_with_default+ star_etc?
3928 asdl_seq * a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003929 void *b;
3930 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003931 (a = _loop1_58_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003932 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003933 (b = star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003934 )
3935 {
3936 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
3937 if (res == NULL && PyErr_Occurred()) {
3938 p->error_indicator = 1;
3939 return NULL;
3940 }
3941 goto done;
3942 }
3943 p->mark = mark;
3944 }
3945 { // star_etc
3946 StarEtc* a;
3947 if (
3948 (a = star_etc_rule(p))
3949 )
3950 {
3951 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
3952 if (res == NULL && PyErr_Occurred()) {
3953 p->error_indicator = 1;
3954 return NULL;
3955 }
3956 goto done;
3957 }
3958 p->mark = mark;
3959 }
3960 res = NULL;
3961 done:
3962 return res;
3963}
3964
Guido van Rossumc001c092020-04-30 12:12:19 -07003965// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003966static asdl_seq*
Guido van Rossumc001c092020-04-30 12:12:19 -07003967slash_no_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003968{
3969 if (p->error_indicator) {
3970 return NULL;
3971 }
3972 asdl_seq* res = NULL;
3973 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07003974 { // param_no_default+ '/' ','
3975 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003976 Token * literal;
3977 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003978 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003979 (a = _loop1_59_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003980 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003981 (literal = _PyPegen_expect_token(p, 17))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003982 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07003983 (literal_1 = _PyPegen_expect_token(p, 12))
3984 )
3985 {
3986 res = a;
3987 if (res == NULL && PyErr_Occurred()) {
3988 p->error_indicator = 1;
3989 return NULL;
3990 }
3991 goto done;
3992 }
3993 p->mark = mark;
3994 }
3995 { // param_no_default+ '/' &')'
3996 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003997 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07003998 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003999 (a = _loop1_60_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -07004000 &&
4001 (literal = _PyPegen_expect_token(p, 17))
4002 &&
4003 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004004 )
4005 {
4006 res = a;
4007 if (res == NULL && PyErr_Occurred()) {
4008 p->error_indicator = 1;
4009 return NULL;
4010 }
4011 goto done;
4012 }
4013 p->mark = mark;
4014 }
4015 res = NULL;
4016 done:
4017 return res;
4018}
4019
Guido van Rossumc001c092020-04-30 12:12:19 -07004020// slash_with_default:
4021// | param_no_default* param_with_default+ '/' ','
4022// | param_no_default* param_with_default+ '/' &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004023static SlashWithDefault*
4024slash_with_default_rule(Parser *p)
4025{
4026 if (p->error_indicator) {
4027 return NULL;
4028 }
4029 SlashWithDefault* res = NULL;
4030 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004031 { // param_no_default* param_with_default+ '/' ','
4032 asdl_seq * a;
4033 asdl_seq * b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004034 Token * literal;
4035 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004036 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004037 (a = _loop0_61_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004038 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004039 (b = _loop1_62_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004040 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004041 (literal = _PyPegen_expect_token(p, 17))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004042 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004043 (literal_1 = _PyPegen_expect_token(p, 12))
4044 )
4045 {
4046 res = _PyPegen_slash_with_default ( p , a , b );
4047 if (res == NULL && PyErr_Occurred()) {
4048 p->error_indicator = 1;
4049 return NULL;
4050 }
4051 goto done;
4052 }
4053 p->mark = mark;
4054 }
4055 { // param_no_default* param_with_default+ '/' &')'
4056 asdl_seq * a;
4057 asdl_seq * b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004058 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004059 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004060 (a = _loop0_63_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -07004061 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004062 (b = _loop1_64_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -07004063 &&
4064 (literal = _PyPegen_expect_token(p, 17))
4065 &&
4066 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004067 )
4068 {
4069 res = _PyPegen_slash_with_default ( p , a , b );
4070 if (res == NULL && PyErr_Occurred()) {
4071 p->error_indicator = 1;
4072 return NULL;
4073 }
4074 goto done;
4075 }
4076 p->mark = mark;
4077 }
4078 res = NULL;
4079 done:
4080 return res;
4081}
4082
4083// star_etc:
Guido van Rossumc001c092020-04-30 12:12:19 -07004084// | '*' param_no_default param_maybe_default* kwds?
4085// | '*' ',' param_maybe_default+ kwds?
4086// | kwds
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03004087// | invalid_star_etc
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004088static StarEtc*
4089star_etc_rule(Parser *p)
4090{
4091 if (p->error_indicator) {
4092 return NULL;
4093 }
4094 StarEtc* res = NULL;
4095 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004096 { // '*' param_no_default param_maybe_default* kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004097 arg_ty a;
4098 asdl_seq * b;
4099 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004100 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004101 if (
4102 (literal = _PyPegen_expect_token(p, 16))
4103 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004104 (a = param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004105 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004106 (b = _loop0_65_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004107 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004108 (c = kwds_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004109 )
4110 {
4111 res = _PyPegen_star_etc ( p , a , b , c );
4112 if (res == NULL && PyErr_Occurred()) {
4113 p->error_indicator = 1;
4114 return NULL;
4115 }
4116 goto done;
4117 }
4118 p->mark = mark;
4119 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004120 { // '*' ',' param_maybe_default+ kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004121 asdl_seq * b;
4122 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004123 Token * literal;
4124 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004125 if (
4126 (literal = _PyPegen_expect_token(p, 16))
4127 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004128 (literal_1 = _PyPegen_expect_token(p, 12))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004129 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004130 (b = _loop1_66_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004131 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004132 (c = kwds_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004133 )
4134 {
4135 res = _PyPegen_star_etc ( p , NULL , b , c );
4136 if (res == NULL && PyErr_Occurred()) {
4137 p->error_indicator = 1;
4138 return NULL;
4139 }
4140 goto done;
4141 }
4142 p->mark = mark;
4143 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004144 { // kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004145 arg_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004146 if (
4147 (a = kwds_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004148 )
4149 {
4150 res = _PyPegen_star_etc ( p , NULL , NULL , a );
4151 if (res == NULL && PyErr_Occurred()) {
4152 p->error_indicator = 1;
4153 return NULL;
4154 }
4155 goto done;
4156 }
4157 p->mark = mark;
4158 }
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03004159 { // invalid_star_etc
4160 void *invalid_star_etc_var;
4161 if (
4162 (invalid_star_etc_var = invalid_star_etc_rule(p))
4163 )
4164 {
4165 res = invalid_star_etc_var;
4166 goto done;
4167 }
4168 p->mark = mark;
4169 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004170 res = NULL;
4171 done:
4172 return res;
4173}
4174
Guido van Rossumc001c092020-04-30 12:12:19 -07004175// kwds: '**' param_no_default
4176static arg_ty
4177kwds_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004178{
4179 if (p->error_indicator) {
4180 return NULL;
4181 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004182 arg_ty res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004183 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004184 { // '**' param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004185 arg_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004186 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004187 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004188 (literal = _PyPegen_expect_token(p, 35))
4189 &&
4190 (a = param_no_default_rule(p))
4191 )
4192 {
4193 res = a;
4194 if (res == NULL && PyErr_Occurred()) {
4195 p->error_indicator = 1;
4196 return NULL;
4197 }
4198 goto done;
4199 }
4200 p->mark = mark;
4201 }
4202 res = NULL;
4203 done:
4204 return res;
4205}
4206
4207// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')'
4208static arg_ty
4209param_no_default_rule(Parser *p)
4210{
4211 if (p->error_indicator) {
4212 return NULL;
4213 }
4214 arg_ty res = NULL;
4215 int mark = p->mark;
4216 { // param ',' TYPE_COMMENT?
4217 arg_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004218 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004219 void *tc;
4220 if (
4221 (a = param_rule(p))
4222 &&
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004223 (literal = _PyPegen_expect_token(p, 12))
4224 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004225 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004226 )
4227 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004228 res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004229 if (res == NULL && PyErr_Occurred()) {
4230 p->error_indicator = 1;
4231 return NULL;
4232 }
4233 goto done;
4234 }
4235 p->mark = mark;
4236 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004237 { // param TYPE_COMMENT? &')'
4238 arg_ty a;
4239 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004240 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004241 (a = param_rule(p))
4242 &&
4243 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
4244 &&
4245 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004246 )
4247 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004248 res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004249 if (res == NULL && PyErr_Occurred()) {
4250 p->error_indicator = 1;
4251 return NULL;
4252 }
4253 goto done;
4254 }
4255 p->mark = mark;
4256 }
4257 res = NULL;
4258 done:
4259 return res;
4260}
4261
Guido van Rossumc001c092020-04-30 12:12:19 -07004262// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004263static NameDefaultPair*
Guido van Rossumc001c092020-04-30 12:12:19 -07004264param_with_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004265{
4266 if (p->error_indicator) {
4267 return NULL;
4268 }
4269 NameDefaultPair* res = NULL;
4270 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004271 { // param default ',' TYPE_COMMENT?
4272 arg_ty a;
4273 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004274 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004275 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004276 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004277 (a = param_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004278 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004279 (c = default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004280 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004281 (literal = _PyPegen_expect_token(p, 12))
4282 &&
4283 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004284 )
4285 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004286 res = _PyPegen_name_default_pair ( p , a , c , tc );
4287 if (res == NULL && PyErr_Occurred()) {
4288 p->error_indicator = 1;
4289 return NULL;
4290 }
4291 goto done;
4292 }
4293 p->mark = mark;
4294 }
4295 { // param default TYPE_COMMENT? &')'
4296 arg_ty a;
4297 expr_ty c;
4298 void *tc;
4299 if (
4300 (a = param_rule(p))
4301 &&
4302 (c = default_rule(p))
4303 &&
4304 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
4305 &&
4306 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
4307 )
4308 {
4309 res = _PyPegen_name_default_pair ( p , a , c , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004310 if (res == NULL && PyErr_Occurred()) {
4311 p->error_indicator = 1;
4312 return NULL;
4313 }
4314 goto done;
4315 }
4316 p->mark = mark;
4317 }
4318 res = NULL;
4319 done:
4320 return res;
4321}
4322
Guido van Rossumc001c092020-04-30 12:12:19 -07004323// param_maybe_default:
4324// | param default? ',' TYPE_COMMENT?
4325// | param default? TYPE_COMMENT? &')'
4326static NameDefaultPair*
4327param_maybe_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004328{
4329 if (p->error_indicator) {
4330 return NULL;
4331 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004332 NameDefaultPair* res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004333 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004334 { // param default? ',' TYPE_COMMENT?
4335 arg_ty a;
4336 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004337 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004338 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004339 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004340 (a = param_rule(p))
4341 &&
4342 (c = default_rule(p), 1)
4343 &&
4344 (literal = _PyPegen_expect_token(p, 12))
4345 &&
4346 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004347 )
4348 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004349 res = _PyPegen_name_default_pair ( p , a , c , tc );
4350 if (res == NULL && PyErr_Occurred()) {
4351 p->error_indicator = 1;
4352 return NULL;
4353 }
4354 goto done;
4355 }
4356 p->mark = mark;
4357 }
4358 { // param default? TYPE_COMMENT? &')'
4359 arg_ty a;
4360 void *c;
4361 void *tc;
4362 if (
4363 (a = param_rule(p))
4364 &&
4365 (c = default_rule(p), 1)
4366 &&
4367 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1)
4368 &&
4369 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
4370 )
4371 {
4372 res = _PyPegen_name_default_pair ( p , a , c , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004373 if (res == NULL && PyErr_Occurred()) {
4374 p->error_indicator = 1;
4375 return NULL;
4376 }
4377 goto done;
4378 }
4379 p->mark = mark;
4380 }
4381 res = NULL;
4382 done:
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004383 return res;
4384}
4385
Guido van Rossumc001c092020-04-30 12:12:19 -07004386// param: NAME annotation?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004387static arg_ty
Guido van Rossumc001c092020-04-30 12:12:19 -07004388param_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004389{
4390 if (p->error_indicator) {
4391 return NULL;
4392 }
4393 arg_ty res = NULL;
4394 int mark = p->mark;
4395 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4396 p->error_indicator = 1;
4397 return NULL;
4398 }
4399 int start_lineno = p->tokens[mark]->lineno;
4400 UNUSED(start_lineno); // Only used by EXTRA macro
4401 int start_col_offset = p->tokens[mark]->col_offset;
4402 UNUSED(start_col_offset); // Only used by EXTRA macro
Guido van Rossumc001c092020-04-30 12:12:19 -07004403 { // NAME annotation?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004404 expr_ty a;
4405 void *b;
4406 if (
4407 (a = _PyPegen_name_token(p))
4408 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004409 (b = annotation_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004410 )
4411 {
4412 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4413 if (token == NULL) {
4414 return NULL;
4415 }
4416 int end_lineno = token->end_lineno;
4417 UNUSED(end_lineno); // Only used by EXTRA macro
4418 int end_col_offset = token->end_col_offset;
4419 UNUSED(end_col_offset); // Only used by EXTRA macro
4420 res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA );
4421 if (res == NULL && PyErr_Occurred()) {
4422 p->error_indicator = 1;
4423 return NULL;
4424 }
4425 goto done;
4426 }
4427 p->mark = mark;
4428 }
4429 res = NULL;
4430 done:
4431 return res;
4432}
4433
Guido van Rossumc001c092020-04-30 12:12:19 -07004434// annotation: ':' expression
4435static expr_ty
4436annotation_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004437{
4438 if (p->error_indicator) {
4439 return NULL;
4440 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004441 expr_ty res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004442 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004443 { // ':' expression
4444 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004445 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004446 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004447 (literal = _PyPegen_expect_token(p, 11))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004448 &&
Guido van Rossumc001c092020-04-30 12:12:19 -07004449 (a = expression_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004450 )
4451 {
4452 res = a;
4453 if (res == NULL && PyErr_Occurred()) {
4454 p->error_indicator = 1;
4455 return NULL;
4456 }
4457 goto done;
4458 }
4459 p->mark = mark;
4460 }
4461 res = NULL;
4462 done:
4463 return res;
4464}
4465
Guido van Rossumc001c092020-04-30 12:12:19 -07004466// default: '=' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004467static expr_ty
Guido van Rossumc001c092020-04-30 12:12:19 -07004468default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004469{
4470 if (p->error_indicator) {
4471 return NULL;
4472 }
4473 expr_ty res = NULL;
4474 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004475 { // '=' expression
4476 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004477 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004478 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07004479 (literal = _PyPegen_expect_token(p, 22))
4480 &&
4481 (a = expression_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004482 )
4483 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004484 res = a;
4485 if (res == NULL && PyErr_Occurred()) {
4486 p->error_indicator = 1;
4487 return NULL;
4488 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004489 goto done;
4490 }
4491 p->mark = mark;
4492 }
4493 res = NULL;
4494 done:
4495 return res;
4496}
4497
4498// decorators: (('@' named_expression NEWLINE))+
4499static asdl_seq*
4500decorators_rule(Parser *p)
4501{
4502 if (p->error_indicator) {
4503 return NULL;
4504 }
4505 asdl_seq* res = NULL;
4506 int mark = p->mark;
4507 { // (('@' named_expression NEWLINE))+
4508 asdl_seq * a;
4509 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004510 (a = _loop1_67_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004511 )
4512 {
4513 res = a;
4514 if (res == NULL && PyErr_Occurred()) {
4515 p->error_indicator = 1;
4516 return NULL;
4517 }
4518 goto done;
4519 }
4520 p->mark = mark;
4521 }
4522 res = NULL;
4523 done:
4524 return res;
4525}
4526
4527// class_def: decorators class_def_raw | class_def_raw
4528static stmt_ty
4529class_def_rule(Parser *p)
4530{
4531 if (p->error_indicator) {
4532 return NULL;
4533 }
4534 stmt_ty res = NULL;
4535 int mark = p->mark;
4536 { // decorators class_def_raw
4537 asdl_seq* a;
4538 stmt_ty b;
4539 if (
4540 (a = decorators_rule(p))
4541 &&
4542 (b = class_def_raw_rule(p))
4543 )
4544 {
4545 res = _PyPegen_class_def_decorators ( p , a , b );
4546 if (res == NULL && PyErr_Occurred()) {
4547 p->error_indicator = 1;
4548 return NULL;
4549 }
4550 goto done;
4551 }
4552 p->mark = mark;
4553 }
4554 { // class_def_raw
4555 stmt_ty class_def_raw_var;
4556 if (
4557 (class_def_raw_var = class_def_raw_rule(p))
4558 )
4559 {
4560 res = class_def_raw_var;
4561 goto done;
4562 }
4563 p->mark = mark;
4564 }
4565 res = NULL;
4566 done:
4567 return res;
4568}
4569
4570// class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block
4571static stmt_ty
4572class_def_raw_rule(Parser *p)
4573{
4574 if (p->error_indicator) {
4575 return NULL;
4576 }
4577 stmt_ty res = NULL;
4578 int mark = p->mark;
4579 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4580 p->error_indicator = 1;
4581 return NULL;
4582 }
4583 int start_lineno = p->tokens[mark]->lineno;
4584 UNUSED(start_lineno); // Only used by EXTRA macro
4585 int start_col_offset = p->tokens[mark]->col_offset;
4586 UNUSED(start_col_offset); // Only used by EXTRA macro
4587 { // 'class' NAME ['(' arguments? ')'] ':' block
4588 expr_ty a;
4589 void *b;
4590 asdl_seq* c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004591 Token * keyword;
4592 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004593 if (
4594 (keyword = _PyPegen_expect_token(p, 523))
4595 &&
4596 (a = _PyPegen_name_token(p))
4597 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004598 (b = _tmp_68_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004599 &&
4600 (literal = _PyPegen_expect_token(p, 11))
4601 &&
4602 (c = block_rule(p))
4603 )
4604 {
4605 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4606 if (token == NULL) {
4607 return NULL;
4608 }
4609 int end_lineno = token->end_lineno;
4610 UNUSED(end_lineno); // Only used by EXTRA macro
4611 int end_col_offset = token->end_col_offset;
4612 UNUSED(end_col_offset); // Only used by EXTRA macro
4613 res = _Py_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA );
4614 if (res == NULL && PyErr_Occurred()) {
4615 p->error_indicator = 1;
4616 return NULL;
4617 }
4618 goto done;
4619 }
4620 p->mark = mark;
4621 }
4622 res = NULL;
4623 done:
4624 return res;
4625}
4626
4627// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
4628static asdl_seq*
4629block_rule(Parser *p)
4630{
4631 if (p->error_indicator) {
4632 return NULL;
4633 }
4634 asdl_seq* res = NULL;
4635 if (_PyPegen_is_memoized(p, block_type, &res))
4636 return res;
4637 int mark = p->mark;
4638 { // NEWLINE INDENT statements DEDENT
4639 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004640 Token * dedent_var;
4641 Token * indent_var;
4642 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004643 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +01004644 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004645 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01004646 (indent_var = _PyPegen_expect_token(p, INDENT))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004647 &&
4648 (a = statements_rule(p))
4649 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +01004650 (dedent_var = _PyPegen_expect_token(p, DEDENT))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004651 )
4652 {
4653 res = a;
4654 if (res == NULL && PyErr_Occurred()) {
4655 p->error_indicator = 1;
4656 return NULL;
4657 }
4658 goto done;
4659 }
4660 p->mark = mark;
4661 }
4662 { // simple_stmt
4663 asdl_seq* simple_stmt_var;
4664 if (
4665 (simple_stmt_var = simple_stmt_rule(p))
4666 )
4667 {
4668 res = simple_stmt_var;
4669 goto done;
4670 }
4671 p->mark = mark;
4672 }
4673 { // invalid_block
4674 void *invalid_block_var;
4675 if (
4676 (invalid_block_var = invalid_block_rule(p))
4677 )
4678 {
4679 res = invalid_block_var;
4680 goto done;
4681 }
4682 p->mark = mark;
4683 }
4684 res = NULL;
4685 done:
4686 _PyPegen_insert_memo(p, mark, block_type, res);
4687 return res;
4688}
4689
4690// expressions_list: ','.star_expression+ ','?
4691static asdl_seq*
4692expressions_list_rule(Parser *p)
4693{
4694 if (p->error_indicator) {
4695 return NULL;
4696 }
4697 asdl_seq* res = NULL;
4698 int mark = p->mark;
4699 { // ','.star_expression+ ','?
4700 asdl_seq * a;
4701 void *opt_var;
4702 UNUSED(opt_var); // Silence compiler warnings
4703 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004704 (a = _gather_69_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004705 &&
4706 (opt_var = _PyPegen_expect_token(p, 12), 1)
4707 )
4708 {
4709 res = a;
4710 if (res == NULL && PyErr_Occurred()) {
4711 p->error_indicator = 1;
4712 return NULL;
4713 }
4714 goto done;
4715 }
4716 p->mark = mark;
4717 }
4718 res = NULL;
4719 done:
4720 return res;
4721}
4722
4723// star_expressions:
4724// | star_expression ((',' star_expression))+ ','?
4725// | star_expression ','
4726// | star_expression
4727static expr_ty
4728star_expressions_rule(Parser *p)
4729{
4730 if (p->error_indicator) {
4731 return NULL;
4732 }
4733 expr_ty res = NULL;
4734 int mark = p->mark;
4735 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4736 p->error_indicator = 1;
4737 return NULL;
4738 }
4739 int start_lineno = p->tokens[mark]->lineno;
4740 UNUSED(start_lineno); // Only used by EXTRA macro
4741 int start_col_offset = p->tokens[mark]->col_offset;
4742 UNUSED(start_col_offset); // Only used by EXTRA macro
4743 { // star_expression ((',' star_expression))+ ','?
4744 expr_ty a;
4745 asdl_seq * b;
4746 void *opt_var;
4747 UNUSED(opt_var); // Silence compiler warnings
4748 if (
4749 (a = star_expression_rule(p))
4750 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004751 (b = _loop1_71_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004752 &&
4753 (opt_var = _PyPegen_expect_token(p, 12), 1)
4754 )
4755 {
4756 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4757 if (token == NULL) {
4758 return NULL;
4759 }
4760 int end_lineno = token->end_lineno;
4761 UNUSED(end_lineno); // Only used by EXTRA macro
4762 int end_col_offset = token->end_col_offset;
4763 UNUSED(end_col_offset); // Only used by EXTRA macro
4764 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
4765 if (res == NULL && PyErr_Occurred()) {
4766 p->error_indicator = 1;
4767 return NULL;
4768 }
4769 goto done;
4770 }
4771 p->mark = mark;
4772 }
4773 { // star_expression ','
4774 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004775 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004776 if (
4777 (a = star_expression_rule(p))
4778 &&
4779 (literal = _PyPegen_expect_token(p, 12))
4780 )
4781 {
4782 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4783 if (token == NULL) {
4784 return NULL;
4785 }
4786 int end_lineno = token->end_lineno;
4787 UNUSED(end_lineno); // Only used by EXTRA macro
4788 int end_col_offset = token->end_col_offset;
4789 UNUSED(end_col_offset); // Only used by EXTRA macro
4790 res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
4791 if (res == NULL && PyErr_Occurred()) {
4792 p->error_indicator = 1;
4793 return NULL;
4794 }
4795 goto done;
4796 }
4797 p->mark = mark;
4798 }
4799 { // star_expression
4800 expr_ty star_expression_var;
4801 if (
4802 (star_expression_var = star_expression_rule(p))
4803 )
4804 {
4805 res = star_expression_var;
4806 goto done;
4807 }
4808 p->mark = mark;
4809 }
4810 res = NULL;
4811 done:
4812 return res;
4813}
4814
4815// star_expression: '*' bitwise_or | expression
4816static expr_ty
4817star_expression_rule(Parser *p)
4818{
4819 if (p->error_indicator) {
4820 return NULL;
4821 }
4822 expr_ty res = NULL;
4823 if (_PyPegen_is_memoized(p, star_expression_type, &res))
4824 return res;
4825 int mark = p->mark;
4826 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4827 p->error_indicator = 1;
4828 return NULL;
4829 }
4830 int start_lineno = p->tokens[mark]->lineno;
4831 UNUSED(start_lineno); // Only used by EXTRA macro
4832 int start_col_offset = p->tokens[mark]->col_offset;
4833 UNUSED(start_col_offset); // Only used by EXTRA macro
4834 { // '*' bitwise_or
4835 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004836 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004837 if (
4838 (literal = _PyPegen_expect_token(p, 16))
4839 &&
4840 (a = bitwise_or_rule(p))
4841 )
4842 {
4843 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4844 if (token == NULL) {
4845 return NULL;
4846 }
4847 int end_lineno = token->end_lineno;
4848 UNUSED(end_lineno); // Only used by EXTRA macro
4849 int end_col_offset = token->end_col_offset;
4850 UNUSED(end_col_offset); // Only used by EXTRA macro
4851 res = _Py_Starred ( a , Load , EXTRA );
4852 if (res == NULL && PyErr_Occurred()) {
4853 p->error_indicator = 1;
4854 return NULL;
4855 }
4856 goto done;
4857 }
4858 p->mark = mark;
4859 }
4860 { // expression
4861 expr_ty expression_var;
4862 if (
4863 (expression_var = expression_rule(p))
4864 )
4865 {
4866 res = expression_var;
4867 goto done;
4868 }
4869 p->mark = mark;
4870 }
4871 res = NULL;
4872 done:
4873 _PyPegen_insert_memo(p, mark, star_expression_type, res);
4874 return res;
4875}
4876
4877// star_named_expressions: ','.star_named_expression+ ','?
4878static asdl_seq*
4879star_named_expressions_rule(Parser *p)
4880{
4881 if (p->error_indicator) {
4882 return NULL;
4883 }
4884 asdl_seq* res = NULL;
4885 int mark = p->mark;
4886 { // ','.star_named_expression+ ','?
4887 asdl_seq * a;
4888 void *opt_var;
4889 UNUSED(opt_var); // Silence compiler warnings
4890 if (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03004891 (a = _gather_72_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004892 &&
4893 (opt_var = _PyPegen_expect_token(p, 12), 1)
4894 )
4895 {
4896 res = a;
4897 if (res == NULL && PyErr_Occurred()) {
4898 p->error_indicator = 1;
4899 return NULL;
4900 }
4901 goto done;
4902 }
4903 p->mark = mark;
4904 }
4905 res = NULL;
4906 done:
4907 return res;
4908}
4909
4910// star_named_expression: '*' bitwise_or | named_expression
4911static expr_ty
4912star_named_expression_rule(Parser *p)
4913{
4914 if (p->error_indicator) {
4915 return NULL;
4916 }
4917 expr_ty res = NULL;
4918 int mark = p->mark;
4919 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4920 p->error_indicator = 1;
4921 return NULL;
4922 }
4923 int start_lineno = p->tokens[mark]->lineno;
4924 UNUSED(start_lineno); // Only used by EXTRA macro
4925 int start_col_offset = p->tokens[mark]->col_offset;
4926 UNUSED(start_col_offset); // Only used by EXTRA macro
4927 { // '*' bitwise_or
4928 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004929 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004930 if (
4931 (literal = _PyPegen_expect_token(p, 16))
4932 &&
4933 (a = bitwise_or_rule(p))
4934 )
4935 {
4936 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4937 if (token == NULL) {
4938 return NULL;
4939 }
4940 int end_lineno = token->end_lineno;
4941 UNUSED(end_lineno); // Only used by EXTRA macro
4942 int end_col_offset = token->end_col_offset;
4943 UNUSED(end_col_offset); // Only used by EXTRA macro
4944 res = _Py_Starred ( a , Load , EXTRA );
4945 if (res == NULL && PyErr_Occurred()) {
4946 p->error_indicator = 1;
4947 return NULL;
4948 }
4949 goto done;
4950 }
4951 p->mark = mark;
4952 }
4953 { // named_expression
4954 expr_ty named_expression_var;
4955 if (
4956 (named_expression_var = named_expression_rule(p))
4957 )
4958 {
4959 res = named_expression_var;
4960 goto done;
4961 }
4962 p->mark = mark;
4963 }
4964 res = NULL;
4965 done:
4966 return res;
4967}
4968
4969// named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression
4970static expr_ty
4971named_expression_rule(Parser *p)
4972{
4973 if (p->error_indicator) {
4974 return NULL;
4975 }
4976 expr_ty res = NULL;
4977 int mark = p->mark;
4978 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4979 p->error_indicator = 1;
4980 return NULL;
4981 }
4982 int start_lineno = p->tokens[mark]->lineno;
4983 UNUSED(start_lineno); // Only used by EXTRA macro
4984 int start_col_offset = p->tokens[mark]->col_offset;
4985 UNUSED(start_col_offset); // Only used by EXTRA macro
4986 { // NAME ':=' expression
4987 expr_ty a;
4988 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004989 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004990 if (
4991 (a = _PyPegen_name_token(p))
4992 &&
4993 (literal = _PyPegen_expect_token(p, 53))
4994 &&
4995 (b = expression_rule(p))
4996 )
4997 {
4998 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4999 if (token == NULL) {
5000 return NULL;
5001 }
5002 int end_lineno = token->end_lineno;
5003 UNUSED(end_lineno); // Only used by EXTRA macro
5004 int end_col_offset = token->end_col_offset;
5005 UNUSED(end_col_offset); // Only used by EXTRA macro
5006 res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA );
5007 if (res == NULL && PyErr_Occurred()) {
5008 p->error_indicator = 1;
5009 return NULL;
5010 }
5011 goto done;
5012 }
5013 p->mark = mark;
5014 }
5015 { // expression !':='
5016 expr_ty expression_var;
5017 if (
5018 (expression_var = expression_rule(p))
5019 &&
5020 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53)
5021 )
5022 {
5023 res = expression_var;
5024 goto done;
5025 }
5026 p->mark = mark;
5027 }
5028 { // invalid_named_expression
5029 void *invalid_named_expression_var;
5030 if (
5031 (invalid_named_expression_var = invalid_named_expression_rule(p))
5032 )
5033 {
5034 res = invalid_named_expression_var;
5035 goto done;
5036 }
5037 p->mark = mark;
5038 }
5039 res = NULL;
5040 done:
5041 return res;
5042}
5043
5044// annotated_rhs: yield_expr | star_expressions
5045static expr_ty
5046annotated_rhs_rule(Parser *p)
5047{
5048 if (p->error_indicator) {
5049 return NULL;
5050 }
5051 expr_ty res = NULL;
5052 int mark = p->mark;
5053 { // yield_expr
5054 expr_ty yield_expr_var;
5055 if (
5056 (yield_expr_var = yield_expr_rule(p))
5057 )
5058 {
5059 res = yield_expr_var;
5060 goto done;
5061 }
5062 p->mark = mark;
5063 }
5064 { // star_expressions
5065 expr_ty star_expressions_var;
5066 if (
5067 (star_expressions_var = star_expressions_rule(p))
5068 )
5069 {
5070 res = star_expressions_var;
5071 goto done;
5072 }
5073 p->mark = mark;
5074 }
5075 res = NULL;
5076 done:
5077 return res;
5078}
5079
5080// expressions: expression ((',' expression))+ ','? | expression ',' | expression
5081static expr_ty
5082expressions_rule(Parser *p)
5083{
5084 if (p->error_indicator) {
5085 return NULL;
5086 }
5087 expr_ty res = NULL;
5088 int mark = p->mark;
5089 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5090 p->error_indicator = 1;
5091 return NULL;
5092 }
5093 int start_lineno = p->tokens[mark]->lineno;
5094 UNUSED(start_lineno); // Only used by EXTRA macro
5095 int start_col_offset = p->tokens[mark]->col_offset;
5096 UNUSED(start_col_offset); // Only used by EXTRA macro
5097 { // expression ((',' expression))+ ','?
5098 expr_ty a;
5099 asdl_seq * b;
5100 void *opt_var;
5101 UNUSED(opt_var); // Silence compiler warnings
5102 if (
5103 (a = expression_rule(p))
5104 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03005105 (b = _loop1_74_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005106 &&
5107 (opt_var = _PyPegen_expect_token(p, 12), 1)
5108 )
5109 {
5110 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5111 if (token == NULL) {
5112 return NULL;
5113 }
5114 int end_lineno = token->end_lineno;
5115 UNUSED(end_lineno); // Only used by EXTRA macro
5116 int end_col_offset = token->end_col_offset;
5117 UNUSED(end_col_offset); // Only used by EXTRA macro
5118 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
5119 if (res == NULL && PyErr_Occurred()) {
5120 p->error_indicator = 1;
5121 return NULL;
5122 }
5123 goto done;
5124 }
5125 p->mark = mark;
5126 }
5127 { // expression ','
5128 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005129 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005130 if (
5131 (a = expression_rule(p))
5132 &&
5133 (literal = _PyPegen_expect_token(p, 12))
5134 )
5135 {
5136 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5137 if (token == NULL) {
5138 return NULL;
5139 }
5140 int end_lineno = token->end_lineno;
5141 UNUSED(end_lineno); // Only used by EXTRA macro
5142 int end_col_offset = token->end_col_offset;
5143 UNUSED(end_col_offset); // Only used by EXTRA macro
5144 res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
5145 if (res == NULL && PyErr_Occurred()) {
5146 p->error_indicator = 1;
5147 return NULL;
5148 }
5149 goto done;
5150 }
5151 p->mark = mark;
5152 }
5153 { // expression
5154 expr_ty expression_var;
5155 if (
5156 (expression_var = expression_rule(p))
5157 )
5158 {
5159 res = expression_var;
5160 goto done;
5161 }
5162 p->mark = mark;
5163 }
5164 res = NULL;
5165 done:
5166 return res;
5167}
5168
5169// expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef
5170static expr_ty
5171expression_rule(Parser *p)
5172{
5173 if (p->error_indicator) {
5174 return NULL;
5175 }
5176 expr_ty res = NULL;
5177 if (_PyPegen_is_memoized(p, expression_type, &res))
5178 return res;
5179 int mark = p->mark;
5180 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5181 p->error_indicator = 1;
5182 return NULL;
5183 }
5184 int start_lineno = p->tokens[mark]->lineno;
5185 UNUSED(start_lineno); // Only used by EXTRA macro
5186 int start_col_offset = p->tokens[mark]->col_offset;
5187 UNUSED(start_col_offset); // Only used by EXTRA macro
5188 { // disjunction 'if' disjunction 'else' expression
5189 expr_ty a;
5190 expr_ty b;
5191 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005192 Token * keyword;
5193 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005194 if (
5195 (a = disjunction_rule(p))
5196 &&
5197 (keyword = _PyPegen_expect_token(p, 510))
5198 &&
5199 (b = disjunction_rule(p))
5200 &&
5201 (keyword_1 = _PyPegen_expect_token(p, 516))
5202 &&
5203 (c = expression_rule(p))
5204 )
5205 {
5206 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5207 if (token == NULL) {
5208 return NULL;
5209 }
5210 int end_lineno = token->end_lineno;
5211 UNUSED(end_lineno); // Only used by EXTRA macro
5212 int end_col_offset = token->end_col_offset;
5213 UNUSED(end_col_offset); // Only used by EXTRA macro
5214 res = _Py_IfExp ( b , a , c , EXTRA );
5215 if (res == NULL && PyErr_Occurred()) {
5216 p->error_indicator = 1;
5217 return NULL;
5218 }
5219 goto done;
5220 }
5221 p->mark = mark;
5222 }
5223 { // disjunction
5224 expr_ty disjunction_var;
5225 if (
5226 (disjunction_var = disjunction_rule(p))
5227 )
5228 {
5229 res = disjunction_var;
5230 goto done;
5231 }
5232 p->mark = mark;
5233 }
5234 { // lambdef
5235 expr_ty lambdef_var;
5236 if (
5237 (lambdef_var = lambdef_rule(p))
5238 )
5239 {
5240 res = lambdef_var;
5241 goto done;
5242 }
5243 p->mark = mark;
5244 }
5245 res = NULL;
5246 done:
5247 _PyPegen_insert_memo(p, mark, expression_type, res);
5248 return res;
5249}
5250
5251// lambdef: 'lambda' lambda_parameters? ':' expression
5252static expr_ty
5253lambdef_rule(Parser *p)
5254{
5255 if (p->error_indicator) {
5256 return NULL;
5257 }
5258 expr_ty res = NULL;
5259 int mark = p->mark;
5260 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5261 p->error_indicator = 1;
5262 return NULL;
5263 }
5264 int start_lineno = p->tokens[mark]->lineno;
5265 UNUSED(start_lineno); // Only used by EXTRA macro
5266 int start_col_offset = p->tokens[mark]->col_offset;
5267 UNUSED(start_col_offset); // Only used by EXTRA macro
5268 { // 'lambda' lambda_parameters? ':' expression
5269 void *a;
5270 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005271 Token * keyword;
5272 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005273 if (
5274 (keyword = _PyPegen_expect_token(p, 524))
5275 &&
5276 (a = lambda_parameters_rule(p), 1)
5277 &&
5278 (literal = _PyPegen_expect_token(p, 11))
5279 &&
5280 (b = expression_rule(p))
5281 )
5282 {
5283 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5284 if (token == NULL) {
5285 return NULL;
5286 }
5287 int end_lineno = token->end_lineno;
5288 UNUSED(end_lineno); // Only used by EXTRA macro
5289 int end_col_offset = token->end_col_offset;
5290 UNUSED(end_col_offset); // Only used by EXTRA macro
5291 res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA );
5292 if (res == NULL && PyErr_Occurred()) {
5293 p->error_indicator = 1;
5294 return NULL;
5295 }
5296 goto done;
5297 }
5298 p->mark = mark;
5299 }
5300 res = NULL;
5301 done:
5302 return res;
5303}
5304
5305// lambda_parameters:
Guido van Rossum3941d972020-05-01 09:42:03 -07005306// | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
5307// | lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
5308// | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
5309// | lambda_param_with_default+ lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005310// | lambda_star_etc
5311static arguments_ty
5312lambda_parameters_rule(Parser *p)
5313{
5314 if (p->error_indicator) {
5315 return NULL;
5316 }
5317 arguments_ty res = NULL;
5318 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -07005319 { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005320 asdl_seq* a;
Guido van Rossum3941d972020-05-01 09:42:03 -07005321 asdl_seq * b;
5322 asdl_seq * c;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005323 void *d;
5324 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07005325 (a = lambda_slash_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005326 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005327 (b = _loop0_75_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005328 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005329 (c = _loop0_76_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005330 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005331 (d = lambda_star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005332 )
5333 {
5334 res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
5335 if (res == NULL && PyErr_Occurred()) {
5336 p->error_indicator = 1;
5337 return NULL;
5338 }
5339 goto done;
5340 }
5341 p->mark = mark;
5342 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005343 { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005344 SlashWithDefault* a;
Guido van Rossum3941d972020-05-01 09:42:03 -07005345 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005346 void *c;
5347 if (
5348 (a = lambda_slash_with_default_rule(p))
5349 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005350 (b = _loop0_77_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005351 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005352 (c = lambda_star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005353 )
5354 {
5355 res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
5356 if (res == NULL && PyErr_Occurred()) {
5357 p->error_indicator = 1;
5358 return NULL;
5359 }
5360 goto done;
5361 }
5362 p->mark = mark;
5363 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005364 { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
5365 asdl_seq * a;
5366 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005367 void *c;
5368 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07005369 (a = _loop1_78_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005370 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005371 (b = _loop0_79_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005372 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005373 (c = lambda_star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005374 )
5375 {
5376 res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
5377 if (res == NULL && PyErr_Occurred()) {
5378 p->error_indicator = 1;
5379 return NULL;
5380 }
5381 goto done;
5382 }
5383 p->mark = mark;
5384 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005385 { // lambda_param_with_default+ lambda_star_etc?
5386 asdl_seq * a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005387 void *b;
5388 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07005389 (a = _loop1_80_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005390 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005391 (b = lambda_star_etc_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005392 )
5393 {
5394 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
5395 if (res == NULL && PyErr_Occurred()) {
5396 p->error_indicator = 1;
5397 return NULL;
5398 }
5399 goto done;
5400 }
5401 p->mark = mark;
5402 }
5403 { // lambda_star_etc
5404 StarEtc* a;
5405 if (
5406 (a = lambda_star_etc_rule(p))
5407 )
5408 {
5409 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
5410 if (res == NULL && PyErr_Occurred()) {
5411 p->error_indicator = 1;
5412 return NULL;
5413 }
5414 goto done;
5415 }
5416 p->mark = mark;
5417 }
5418 res = NULL;
5419 done:
5420 return res;
5421}
5422
Guido van Rossum3941d972020-05-01 09:42:03 -07005423// lambda_slash_no_default:
5424// | lambda_param_no_default+ '/' ','
5425// | lambda_param_no_default+ '/' &':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005426static asdl_seq*
Guido van Rossum3941d972020-05-01 09:42:03 -07005427lambda_slash_no_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005428{
5429 if (p->error_indicator) {
5430 return NULL;
5431 }
5432 asdl_seq* res = NULL;
5433 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -07005434 { // lambda_param_no_default+ '/' ','
5435 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005436 Token * literal;
5437 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005438 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07005439 (a = _loop1_81_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005440 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005441 (literal = _PyPegen_expect_token(p, 17))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005442 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005443 (literal_1 = _PyPegen_expect_token(p, 12))
5444 )
5445 {
5446 res = a;
5447 if (res == NULL && PyErr_Occurred()) {
5448 p->error_indicator = 1;
5449 return NULL;
5450 }
5451 goto done;
5452 }
5453 p->mark = mark;
5454 }
5455 { // lambda_param_no_default+ '/' &':'
5456 asdl_seq * a;
5457 Token * literal;
5458 if (
5459 (a = _loop1_82_rule(p))
5460 &&
5461 (literal = _PyPegen_expect_token(p, 17))
5462 &&
5463 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005464 )
5465 {
5466 res = a;
5467 if (res == NULL && PyErr_Occurred()) {
5468 p->error_indicator = 1;
5469 return NULL;
5470 }
5471 goto done;
5472 }
5473 p->mark = mark;
5474 }
5475 res = NULL;
5476 done:
5477 return res;
5478}
5479
Guido van Rossum3941d972020-05-01 09:42:03 -07005480// lambda_slash_with_default:
5481// | lambda_param_no_default* lambda_param_with_default+ '/' ','
5482// | lambda_param_no_default* lambda_param_with_default+ '/' &':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005483static SlashWithDefault*
5484lambda_slash_with_default_rule(Parser *p)
5485{
5486 if (p->error_indicator) {
5487 return NULL;
5488 }
5489 SlashWithDefault* res = NULL;
5490 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -07005491 { // lambda_param_no_default* lambda_param_with_default+ '/' ','
5492 asdl_seq * a;
5493 asdl_seq * b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005494 Token * literal;
5495 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005496 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07005497 (a = _loop0_83_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005498 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005499 (b = _loop1_84_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005500 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005501 (literal = _PyPegen_expect_token(p, 17))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005502 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005503 (literal_1 = _PyPegen_expect_token(p, 12))
5504 )
5505 {
5506 res = _PyPegen_slash_with_default ( p , a , b );
5507 if (res == NULL && PyErr_Occurred()) {
5508 p->error_indicator = 1;
5509 return NULL;
5510 }
5511 goto done;
5512 }
5513 p->mark = mark;
5514 }
5515 { // lambda_param_no_default* lambda_param_with_default+ '/' &':'
5516 asdl_seq * a;
5517 asdl_seq * b;
5518 Token * literal;
5519 if (
5520 (a = _loop0_85_rule(p))
5521 &&
5522 (b = _loop1_86_rule(p))
5523 &&
5524 (literal = _PyPegen_expect_token(p, 17))
5525 &&
5526 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005527 )
5528 {
5529 res = _PyPegen_slash_with_default ( p , a , b );
5530 if (res == NULL && PyErr_Occurred()) {
5531 p->error_indicator = 1;
5532 return NULL;
5533 }
5534 goto done;
5535 }
5536 p->mark = mark;
5537 }
5538 res = NULL;
5539 done:
5540 return res;
5541}
5542
5543// lambda_star_etc:
Guido van Rossum3941d972020-05-01 09:42:03 -07005544// | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
5545// | '*' ',' lambda_param_maybe_default+ lambda_kwds?
5546// | lambda_kwds
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03005547// | invalid_lambda_star_etc
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005548static StarEtc*
5549lambda_star_etc_rule(Parser *p)
5550{
5551 if (p->error_indicator) {
5552 return NULL;
5553 }
5554 StarEtc* res = NULL;
5555 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -07005556 { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005557 arg_ty a;
5558 asdl_seq * b;
5559 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005560 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005561 if (
5562 (literal = _PyPegen_expect_token(p, 16))
5563 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005564 (a = lambda_param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005565 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005566 (b = _loop0_87_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005567 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005568 (c = lambda_kwds_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005569 )
5570 {
5571 res = _PyPegen_star_etc ( p , a , b , c );
5572 if (res == NULL && PyErr_Occurred()) {
5573 p->error_indicator = 1;
5574 return NULL;
5575 }
5576 goto done;
5577 }
5578 p->mark = mark;
5579 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005580 { // '*' ',' lambda_param_maybe_default+ lambda_kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005581 asdl_seq * b;
5582 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005583 Token * literal;
Guido van Rossum3941d972020-05-01 09:42:03 -07005584 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005585 if (
5586 (literal = _PyPegen_expect_token(p, 16))
5587 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005588 (literal_1 = _PyPegen_expect_token(p, 12))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005589 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005590 (b = _loop1_88_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005591 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005592 (c = lambda_kwds_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005593 )
5594 {
5595 res = _PyPegen_star_etc ( p , NULL , b , c );
5596 if (res == NULL && PyErr_Occurred()) {
5597 p->error_indicator = 1;
5598 return NULL;
5599 }
5600 goto done;
5601 }
5602 p->mark = mark;
5603 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005604 { // lambda_kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005605 arg_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005606 if (
5607 (a = lambda_kwds_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005608 )
5609 {
5610 res = _PyPegen_star_etc ( p , NULL , NULL , a );
5611 if (res == NULL && PyErr_Occurred()) {
5612 p->error_indicator = 1;
5613 return NULL;
5614 }
5615 goto done;
5616 }
5617 p->mark = mark;
5618 }
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03005619 { // invalid_lambda_star_etc
5620 void *invalid_lambda_star_etc_var;
5621 if (
5622 (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p))
5623 )
5624 {
5625 res = invalid_lambda_star_etc_var;
5626 goto done;
5627 }
5628 p->mark = mark;
5629 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005630 res = NULL;
5631 done:
5632 return res;
5633}
5634
Guido van Rossum3941d972020-05-01 09:42:03 -07005635// lambda_kwds: '**' lambda_param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005636static arg_ty
Guido van Rossum3941d972020-05-01 09:42:03 -07005637lambda_kwds_rule(Parser *p)
5638{
5639 if (p->error_indicator) {
5640 return NULL;
5641 }
5642 arg_ty res = NULL;
5643 int mark = p->mark;
5644 { // '**' lambda_param_no_default
5645 arg_ty a;
5646 Token * literal;
5647 if (
5648 (literal = _PyPegen_expect_token(p, 35))
5649 &&
5650 (a = lambda_param_no_default_rule(p))
5651 )
5652 {
5653 res = a;
5654 if (res == NULL && PyErr_Occurred()) {
5655 p->error_indicator = 1;
5656 return NULL;
5657 }
5658 goto done;
5659 }
5660 p->mark = mark;
5661 }
5662 res = NULL;
5663 done:
5664 return res;
5665}
5666
5667// lambda_param_no_default: lambda_param ',' | lambda_param &':'
5668static arg_ty
5669lambda_param_no_default_rule(Parser *p)
5670{
5671 if (p->error_indicator) {
5672 return NULL;
5673 }
5674 arg_ty res = NULL;
5675 int mark = p->mark;
5676 { // lambda_param ','
5677 arg_ty a;
5678 Token * literal;
5679 if (
5680 (a = lambda_param_rule(p))
5681 &&
5682 (literal = _PyPegen_expect_token(p, 12))
5683 )
5684 {
5685 res = a;
5686 if (res == NULL && PyErr_Occurred()) {
5687 p->error_indicator = 1;
5688 return NULL;
5689 }
5690 goto done;
5691 }
5692 p->mark = mark;
5693 }
5694 { // lambda_param &':'
5695 arg_ty a;
5696 if (
5697 (a = lambda_param_rule(p))
5698 &&
5699 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11)
5700 )
5701 {
5702 res = a;
5703 if (res == NULL && PyErr_Occurred()) {
5704 p->error_indicator = 1;
5705 return NULL;
5706 }
5707 goto done;
5708 }
5709 p->mark = mark;
5710 }
5711 res = NULL;
5712 done:
5713 return res;
5714}
5715
5716// lambda_param_with_default: lambda_param default ',' | lambda_param default &':'
5717static NameDefaultPair*
5718lambda_param_with_default_rule(Parser *p)
5719{
5720 if (p->error_indicator) {
5721 return NULL;
5722 }
5723 NameDefaultPair* res = NULL;
5724 int mark = p->mark;
5725 { // lambda_param default ','
5726 arg_ty a;
5727 expr_ty c;
5728 Token * literal;
5729 if (
5730 (a = lambda_param_rule(p))
5731 &&
5732 (c = default_rule(p))
5733 &&
5734 (literal = _PyPegen_expect_token(p, 12))
5735 )
5736 {
5737 res = _PyPegen_name_default_pair ( p , a , c , NULL );
5738 if (res == NULL && PyErr_Occurred()) {
5739 p->error_indicator = 1;
5740 return NULL;
5741 }
5742 goto done;
5743 }
5744 p->mark = mark;
5745 }
5746 { // lambda_param default &':'
5747 arg_ty a;
5748 expr_ty c;
5749 if (
5750 (a = lambda_param_rule(p))
5751 &&
5752 (c = default_rule(p))
5753 &&
5754 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11)
5755 )
5756 {
5757 res = _PyPegen_name_default_pair ( p , a , c , NULL );
5758 if (res == NULL && PyErr_Occurred()) {
5759 p->error_indicator = 1;
5760 return NULL;
5761 }
5762 goto done;
5763 }
5764 p->mark = mark;
5765 }
5766 res = NULL;
5767 done:
5768 return res;
5769}
5770
5771// lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':'
5772static NameDefaultPair*
5773lambda_param_maybe_default_rule(Parser *p)
5774{
5775 if (p->error_indicator) {
5776 return NULL;
5777 }
5778 NameDefaultPair* res = NULL;
5779 int mark = p->mark;
5780 { // lambda_param default? ','
5781 arg_ty a;
5782 void *c;
5783 Token * literal;
5784 if (
5785 (a = lambda_param_rule(p))
5786 &&
5787 (c = default_rule(p), 1)
5788 &&
5789 (literal = _PyPegen_expect_token(p, 12))
5790 )
5791 {
5792 res = _PyPegen_name_default_pair ( p , a , c , NULL );
5793 if (res == NULL && PyErr_Occurred()) {
5794 p->error_indicator = 1;
5795 return NULL;
5796 }
5797 goto done;
5798 }
5799 p->mark = mark;
5800 }
5801 { // lambda_param default? &':'
5802 arg_ty a;
5803 void *c;
5804 if (
5805 (a = lambda_param_rule(p))
5806 &&
5807 (c = default_rule(p), 1)
5808 &&
5809 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11)
5810 )
5811 {
5812 res = _PyPegen_name_default_pair ( p , a , c , NULL );
5813 if (res == NULL && PyErr_Occurred()) {
5814 p->error_indicator = 1;
5815 return NULL;
5816 }
5817 goto done;
5818 }
5819 p->mark = mark;
5820 }
5821 res = NULL;
5822 done:
5823 return res;
5824}
5825
5826// lambda_param: NAME
5827static arg_ty
5828lambda_param_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005829{
5830 if (p->error_indicator) {
5831 return NULL;
5832 }
5833 arg_ty res = NULL;
5834 int mark = p->mark;
5835 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5836 p->error_indicator = 1;
5837 return NULL;
5838 }
5839 int start_lineno = p->tokens[mark]->lineno;
5840 UNUSED(start_lineno); // Only used by EXTRA macro
5841 int start_col_offset = p->tokens[mark]->col_offset;
5842 UNUSED(start_col_offset); // Only used by EXTRA macro
5843 { // NAME
5844 expr_ty a;
5845 if (
5846 (a = _PyPegen_name_token(p))
5847 )
5848 {
5849 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5850 if (token == NULL) {
5851 return NULL;
5852 }
5853 int end_lineno = token->end_lineno;
5854 UNUSED(end_lineno); // Only used by EXTRA macro
5855 int end_col_offset = token->end_col_offset;
5856 UNUSED(end_col_offset); // Only used by EXTRA macro
5857 res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA );
5858 if (res == NULL && PyErr_Occurred()) {
5859 p->error_indicator = 1;
5860 return NULL;
5861 }
5862 goto done;
5863 }
5864 p->mark = mark;
5865 }
5866 res = NULL;
5867 done:
5868 return res;
5869}
5870
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005871// disjunction: conjunction (('or' conjunction))+ | conjunction
5872static expr_ty
5873disjunction_rule(Parser *p)
5874{
5875 if (p->error_indicator) {
5876 return NULL;
5877 }
5878 expr_ty res = NULL;
5879 if (_PyPegen_is_memoized(p, disjunction_type, &res))
5880 return res;
5881 int mark = p->mark;
5882 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5883 p->error_indicator = 1;
5884 return NULL;
5885 }
5886 int start_lineno = p->tokens[mark]->lineno;
5887 UNUSED(start_lineno); // Only used by EXTRA macro
5888 int start_col_offset = p->tokens[mark]->col_offset;
5889 UNUSED(start_col_offset); // Only used by EXTRA macro
5890 { // conjunction (('or' conjunction))+
5891 expr_ty a;
5892 asdl_seq * b;
5893 if (
5894 (a = conjunction_rule(p))
5895 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005896 (b = _loop1_89_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005897 )
5898 {
5899 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5900 if (token == NULL) {
5901 return NULL;
5902 }
5903 int end_lineno = token->end_lineno;
5904 UNUSED(end_lineno); // Only used by EXTRA macro
5905 int end_col_offset = token->end_col_offset;
5906 UNUSED(end_col_offset); // Only used by EXTRA macro
5907 res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
5908 if (res == NULL && PyErr_Occurred()) {
5909 p->error_indicator = 1;
5910 return NULL;
5911 }
5912 goto done;
5913 }
5914 p->mark = mark;
5915 }
5916 { // conjunction
5917 expr_ty conjunction_var;
5918 if (
5919 (conjunction_var = conjunction_rule(p))
5920 )
5921 {
5922 res = conjunction_var;
5923 goto done;
5924 }
5925 p->mark = mark;
5926 }
5927 res = NULL;
5928 done:
5929 _PyPegen_insert_memo(p, mark, disjunction_type, res);
5930 return res;
5931}
5932
5933// conjunction: inversion (('and' inversion))+ | inversion
5934static expr_ty
5935conjunction_rule(Parser *p)
5936{
5937 if (p->error_indicator) {
5938 return NULL;
5939 }
5940 expr_ty res = NULL;
5941 if (_PyPegen_is_memoized(p, conjunction_type, &res))
5942 return res;
5943 int mark = p->mark;
5944 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5945 p->error_indicator = 1;
5946 return NULL;
5947 }
5948 int start_lineno = p->tokens[mark]->lineno;
5949 UNUSED(start_lineno); // Only used by EXTRA macro
5950 int start_col_offset = p->tokens[mark]->col_offset;
5951 UNUSED(start_col_offset); // Only used by EXTRA macro
5952 { // inversion (('and' inversion))+
5953 expr_ty a;
5954 asdl_seq * b;
5955 if (
5956 (a = inversion_rule(p))
5957 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07005958 (b = _loop1_90_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005959 )
5960 {
5961 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5962 if (token == NULL) {
5963 return NULL;
5964 }
5965 int end_lineno = token->end_lineno;
5966 UNUSED(end_lineno); // Only used by EXTRA macro
5967 int end_col_offset = token->end_col_offset;
5968 UNUSED(end_col_offset); // Only used by EXTRA macro
5969 res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
5970 if (res == NULL && PyErr_Occurred()) {
5971 p->error_indicator = 1;
5972 return NULL;
5973 }
5974 goto done;
5975 }
5976 p->mark = mark;
5977 }
5978 { // inversion
5979 expr_ty inversion_var;
5980 if (
5981 (inversion_var = inversion_rule(p))
5982 )
5983 {
5984 res = inversion_var;
5985 goto done;
5986 }
5987 p->mark = mark;
5988 }
5989 res = NULL;
5990 done:
5991 _PyPegen_insert_memo(p, mark, conjunction_type, res);
5992 return res;
5993}
5994
5995// inversion: 'not' inversion | comparison
5996static expr_ty
5997inversion_rule(Parser *p)
5998{
5999 if (p->error_indicator) {
6000 return NULL;
6001 }
6002 expr_ty res = NULL;
6003 if (_PyPegen_is_memoized(p, inversion_type, &res))
6004 return res;
6005 int mark = p->mark;
6006 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6007 p->error_indicator = 1;
6008 return NULL;
6009 }
6010 int start_lineno = p->tokens[mark]->lineno;
6011 UNUSED(start_lineno); // Only used by EXTRA macro
6012 int start_col_offset = p->tokens[mark]->col_offset;
6013 UNUSED(start_col_offset); // Only used by EXTRA macro
6014 { // 'not' inversion
6015 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006016 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006017 if (
6018 (keyword = _PyPegen_expect_token(p, 525))
6019 &&
6020 (a = inversion_rule(p))
6021 )
6022 {
6023 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6024 if (token == NULL) {
6025 return NULL;
6026 }
6027 int end_lineno = token->end_lineno;
6028 UNUSED(end_lineno); // Only used by EXTRA macro
6029 int end_col_offset = token->end_col_offset;
6030 UNUSED(end_col_offset); // Only used by EXTRA macro
6031 res = _Py_UnaryOp ( Not , a , EXTRA );
6032 if (res == NULL && PyErr_Occurred()) {
6033 p->error_indicator = 1;
6034 return NULL;
6035 }
6036 goto done;
6037 }
6038 p->mark = mark;
6039 }
6040 { // comparison
6041 expr_ty comparison_var;
6042 if (
6043 (comparison_var = comparison_rule(p))
6044 )
6045 {
6046 res = comparison_var;
6047 goto done;
6048 }
6049 p->mark = mark;
6050 }
6051 res = NULL;
6052 done:
6053 _PyPegen_insert_memo(p, mark, inversion_type, res);
6054 return res;
6055}
6056
6057// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or
6058static expr_ty
6059comparison_rule(Parser *p)
6060{
6061 if (p->error_indicator) {
6062 return NULL;
6063 }
6064 expr_ty res = NULL;
6065 int mark = p->mark;
6066 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6067 p->error_indicator = 1;
6068 return NULL;
6069 }
6070 int start_lineno = p->tokens[mark]->lineno;
6071 UNUSED(start_lineno); // Only used by EXTRA macro
6072 int start_col_offset = p->tokens[mark]->col_offset;
6073 UNUSED(start_col_offset); // Only used by EXTRA macro
6074 { // bitwise_or compare_op_bitwise_or_pair+
6075 expr_ty a;
6076 asdl_seq * b;
6077 if (
6078 (a = bitwise_or_rule(p))
6079 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07006080 (b = _loop1_91_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006081 )
6082 {
6083 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6084 if (token == NULL) {
6085 return NULL;
6086 }
6087 int end_lineno = token->end_lineno;
6088 UNUSED(end_lineno); // Only used by EXTRA macro
6089 int end_col_offset = token->end_col_offset;
6090 UNUSED(end_col_offset); // Only used by EXTRA macro
6091 res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA );
6092 if (res == NULL && PyErr_Occurred()) {
6093 p->error_indicator = 1;
6094 return NULL;
6095 }
6096 goto done;
6097 }
6098 p->mark = mark;
6099 }
6100 { // bitwise_or
6101 expr_ty bitwise_or_var;
6102 if (
6103 (bitwise_or_var = bitwise_or_rule(p))
6104 )
6105 {
6106 res = bitwise_or_var;
6107 goto done;
6108 }
6109 p->mark = mark;
6110 }
6111 res = NULL;
6112 done:
6113 return res;
6114}
6115
6116// compare_op_bitwise_or_pair:
6117// | eq_bitwise_or
6118// | noteq_bitwise_or
6119// | lte_bitwise_or
6120// | lt_bitwise_or
6121// | gte_bitwise_or
6122// | gt_bitwise_or
6123// | notin_bitwise_or
6124// | in_bitwise_or
6125// | isnot_bitwise_or
6126// | is_bitwise_or
6127static CmpopExprPair*
6128compare_op_bitwise_or_pair_rule(Parser *p)
6129{
6130 if (p->error_indicator) {
6131 return NULL;
6132 }
6133 CmpopExprPair* res = NULL;
6134 int mark = p->mark;
6135 { // eq_bitwise_or
6136 CmpopExprPair* eq_bitwise_or_var;
6137 if (
6138 (eq_bitwise_or_var = eq_bitwise_or_rule(p))
6139 )
6140 {
6141 res = eq_bitwise_or_var;
6142 goto done;
6143 }
6144 p->mark = mark;
6145 }
6146 { // noteq_bitwise_or
6147 CmpopExprPair* noteq_bitwise_or_var;
6148 if (
6149 (noteq_bitwise_or_var = noteq_bitwise_or_rule(p))
6150 )
6151 {
6152 res = noteq_bitwise_or_var;
6153 goto done;
6154 }
6155 p->mark = mark;
6156 }
6157 { // lte_bitwise_or
6158 CmpopExprPair* lte_bitwise_or_var;
6159 if (
6160 (lte_bitwise_or_var = lte_bitwise_or_rule(p))
6161 )
6162 {
6163 res = lte_bitwise_or_var;
6164 goto done;
6165 }
6166 p->mark = mark;
6167 }
6168 { // lt_bitwise_or
6169 CmpopExprPair* lt_bitwise_or_var;
6170 if (
6171 (lt_bitwise_or_var = lt_bitwise_or_rule(p))
6172 )
6173 {
6174 res = lt_bitwise_or_var;
6175 goto done;
6176 }
6177 p->mark = mark;
6178 }
6179 { // gte_bitwise_or
6180 CmpopExprPair* gte_bitwise_or_var;
6181 if (
6182 (gte_bitwise_or_var = gte_bitwise_or_rule(p))
6183 )
6184 {
6185 res = gte_bitwise_or_var;
6186 goto done;
6187 }
6188 p->mark = mark;
6189 }
6190 { // gt_bitwise_or
6191 CmpopExprPair* gt_bitwise_or_var;
6192 if (
6193 (gt_bitwise_or_var = gt_bitwise_or_rule(p))
6194 )
6195 {
6196 res = gt_bitwise_or_var;
6197 goto done;
6198 }
6199 p->mark = mark;
6200 }
6201 { // notin_bitwise_or
6202 CmpopExprPair* notin_bitwise_or_var;
6203 if (
6204 (notin_bitwise_or_var = notin_bitwise_or_rule(p))
6205 )
6206 {
6207 res = notin_bitwise_or_var;
6208 goto done;
6209 }
6210 p->mark = mark;
6211 }
6212 { // in_bitwise_or
6213 CmpopExprPair* in_bitwise_or_var;
6214 if (
6215 (in_bitwise_or_var = in_bitwise_or_rule(p))
6216 )
6217 {
6218 res = in_bitwise_or_var;
6219 goto done;
6220 }
6221 p->mark = mark;
6222 }
6223 { // isnot_bitwise_or
6224 CmpopExprPair* isnot_bitwise_or_var;
6225 if (
6226 (isnot_bitwise_or_var = isnot_bitwise_or_rule(p))
6227 )
6228 {
6229 res = isnot_bitwise_or_var;
6230 goto done;
6231 }
6232 p->mark = mark;
6233 }
6234 { // is_bitwise_or
6235 CmpopExprPair* is_bitwise_or_var;
6236 if (
6237 (is_bitwise_or_var = is_bitwise_or_rule(p))
6238 )
6239 {
6240 res = is_bitwise_or_var;
6241 goto done;
6242 }
6243 p->mark = mark;
6244 }
6245 res = NULL;
6246 done:
6247 return res;
6248}
6249
6250// eq_bitwise_or: '==' bitwise_or
6251static CmpopExprPair*
6252eq_bitwise_or_rule(Parser *p)
6253{
6254 if (p->error_indicator) {
6255 return NULL;
6256 }
6257 CmpopExprPair* res = NULL;
6258 int mark = p->mark;
6259 { // '==' bitwise_or
6260 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006261 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006262 if (
6263 (literal = _PyPegen_expect_token(p, 27))
6264 &&
6265 (a = bitwise_or_rule(p))
6266 )
6267 {
6268 res = _PyPegen_cmpop_expr_pair ( p , Eq , a );
6269 if (res == NULL && PyErr_Occurred()) {
6270 p->error_indicator = 1;
6271 return NULL;
6272 }
6273 goto done;
6274 }
6275 p->mark = mark;
6276 }
6277 res = NULL;
6278 done:
6279 return res;
6280}
6281
Pablo Galindo2b74c832020-04-27 18:02:07 +01006282// noteq_bitwise_or: ('!=') bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006283static CmpopExprPair*
6284noteq_bitwise_or_rule(Parser *p)
6285{
6286 if (p->error_indicator) {
6287 return NULL;
6288 }
6289 CmpopExprPair* res = NULL;
6290 int mark = p->mark;
Pablo Galindo2b74c832020-04-27 18:02:07 +01006291 { // ('!=') bitwise_or
Guido van Rossum3941d972020-05-01 09:42:03 -07006292 void *_tmp_92_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006293 expr_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006294 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07006295 (_tmp_92_var = _tmp_92_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006296 &&
6297 (a = bitwise_or_rule(p))
6298 )
6299 {
6300 res = _PyPegen_cmpop_expr_pair ( p , NotEq , a );
6301 if (res == NULL && PyErr_Occurred()) {
6302 p->error_indicator = 1;
6303 return NULL;
6304 }
6305 goto done;
6306 }
6307 p->mark = mark;
6308 }
6309 res = NULL;
6310 done:
6311 return res;
6312}
6313
6314// lte_bitwise_or: '<=' bitwise_or
6315static CmpopExprPair*
6316lte_bitwise_or_rule(Parser *p)
6317{
6318 if (p->error_indicator) {
6319 return NULL;
6320 }
6321 CmpopExprPair* res = NULL;
6322 int mark = p->mark;
6323 { // '<=' bitwise_or
6324 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006325 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006326 if (
6327 (literal = _PyPegen_expect_token(p, 29))
6328 &&
6329 (a = bitwise_or_rule(p))
6330 )
6331 {
6332 res = _PyPegen_cmpop_expr_pair ( p , LtE , a );
6333 if (res == NULL && PyErr_Occurred()) {
6334 p->error_indicator = 1;
6335 return NULL;
6336 }
6337 goto done;
6338 }
6339 p->mark = mark;
6340 }
6341 res = NULL;
6342 done:
6343 return res;
6344}
6345
6346// lt_bitwise_or: '<' bitwise_or
6347static CmpopExprPair*
6348lt_bitwise_or_rule(Parser *p)
6349{
6350 if (p->error_indicator) {
6351 return NULL;
6352 }
6353 CmpopExprPair* res = NULL;
6354 int mark = p->mark;
6355 { // '<' bitwise_or
6356 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006357 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006358 if (
6359 (literal = _PyPegen_expect_token(p, 20))
6360 &&
6361 (a = bitwise_or_rule(p))
6362 )
6363 {
6364 res = _PyPegen_cmpop_expr_pair ( p , Lt , a );
6365 if (res == NULL && PyErr_Occurred()) {
6366 p->error_indicator = 1;
6367 return NULL;
6368 }
6369 goto done;
6370 }
6371 p->mark = mark;
6372 }
6373 res = NULL;
6374 done:
6375 return res;
6376}
6377
6378// gte_bitwise_or: '>=' bitwise_or
6379static CmpopExprPair*
6380gte_bitwise_or_rule(Parser *p)
6381{
6382 if (p->error_indicator) {
6383 return NULL;
6384 }
6385 CmpopExprPair* res = NULL;
6386 int mark = p->mark;
6387 { // '>=' bitwise_or
6388 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006389 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006390 if (
6391 (literal = _PyPegen_expect_token(p, 30))
6392 &&
6393 (a = bitwise_or_rule(p))
6394 )
6395 {
6396 res = _PyPegen_cmpop_expr_pair ( p , GtE , a );
6397 if (res == NULL && PyErr_Occurred()) {
6398 p->error_indicator = 1;
6399 return NULL;
6400 }
6401 goto done;
6402 }
6403 p->mark = mark;
6404 }
6405 res = NULL;
6406 done:
6407 return res;
6408}
6409
6410// gt_bitwise_or: '>' bitwise_or
6411static CmpopExprPair*
6412gt_bitwise_or_rule(Parser *p)
6413{
6414 if (p->error_indicator) {
6415 return NULL;
6416 }
6417 CmpopExprPair* res = NULL;
6418 int mark = p->mark;
6419 { // '>' bitwise_or
6420 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006421 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006422 if (
6423 (literal = _PyPegen_expect_token(p, 21))
6424 &&
6425 (a = bitwise_or_rule(p))
6426 )
6427 {
6428 res = _PyPegen_cmpop_expr_pair ( p , Gt , a );
6429 if (res == NULL && PyErr_Occurred()) {
6430 p->error_indicator = 1;
6431 return NULL;
6432 }
6433 goto done;
6434 }
6435 p->mark = mark;
6436 }
6437 res = NULL;
6438 done:
6439 return res;
6440}
6441
6442// notin_bitwise_or: 'not' 'in' bitwise_or
6443static CmpopExprPair*
6444notin_bitwise_or_rule(Parser *p)
6445{
6446 if (p->error_indicator) {
6447 return NULL;
6448 }
6449 CmpopExprPair* res = NULL;
6450 int mark = p->mark;
6451 { // 'not' 'in' bitwise_or
6452 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006453 Token * keyword;
6454 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006455 if (
6456 (keyword = _PyPegen_expect_token(p, 525))
6457 &&
6458 (keyword_1 = _PyPegen_expect_token(p, 518))
6459 &&
6460 (a = bitwise_or_rule(p))
6461 )
6462 {
6463 res = _PyPegen_cmpop_expr_pair ( p , NotIn , a );
6464 if (res == NULL && PyErr_Occurred()) {
6465 p->error_indicator = 1;
6466 return NULL;
6467 }
6468 goto done;
6469 }
6470 p->mark = mark;
6471 }
6472 res = NULL;
6473 done:
6474 return res;
6475}
6476
6477// in_bitwise_or: 'in' bitwise_or
6478static CmpopExprPair*
6479in_bitwise_or_rule(Parser *p)
6480{
6481 if (p->error_indicator) {
6482 return NULL;
6483 }
6484 CmpopExprPair* res = NULL;
6485 int mark = p->mark;
6486 { // 'in' bitwise_or
6487 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006488 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006489 if (
6490 (keyword = _PyPegen_expect_token(p, 518))
6491 &&
6492 (a = bitwise_or_rule(p))
6493 )
6494 {
6495 res = _PyPegen_cmpop_expr_pair ( p , In , a );
6496 if (res == NULL && PyErr_Occurred()) {
6497 p->error_indicator = 1;
6498 return NULL;
6499 }
6500 goto done;
6501 }
6502 p->mark = mark;
6503 }
6504 res = NULL;
6505 done:
6506 return res;
6507}
6508
6509// isnot_bitwise_or: 'is' 'not' bitwise_or
6510static CmpopExprPair*
6511isnot_bitwise_or_rule(Parser *p)
6512{
6513 if (p->error_indicator) {
6514 return NULL;
6515 }
6516 CmpopExprPair* res = NULL;
6517 int mark = p->mark;
6518 { // 'is' 'not' bitwise_or
6519 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006520 Token * keyword;
6521 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006522 if (
6523 (keyword = _PyPegen_expect_token(p, 526))
6524 &&
6525 (keyword_1 = _PyPegen_expect_token(p, 525))
6526 &&
6527 (a = bitwise_or_rule(p))
6528 )
6529 {
6530 res = _PyPegen_cmpop_expr_pair ( p , IsNot , a );
6531 if (res == NULL && PyErr_Occurred()) {
6532 p->error_indicator = 1;
6533 return NULL;
6534 }
6535 goto done;
6536 }
6537 p->mark = mark;
6538 }
6539 res = NULL;
6540 done:
6541 return res;
6542}
6543
6544// is_bitwise_or: 'is' bitwise_or
6545static CmpopExprPair*
6546is_bitwise_or_rule(Parser *p)
6547{
6548 if (p->error_indicator) {
6549 return NULL;
6550 }
6551 CmpopExprPair* res = NULL;
6552 int mark = p->mark;
6553 { // 'is' bitwise_or
6554 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006555 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006556 if (
6557 (keyword = _PyPegen_expect_token(p, 526))
6558 &&
6559 (a = bitwise_or_rule(p))
6560 )
6561 {
6562 res = _PyPegen_cmpop_expr_pair ( p , Is , a );
6563 if (res == NULL && PyErr_Occurred()) {
6564 p->error_indicator = 1;
6565 return NULL;
6566 }
6567 goto done;
6568 }
6569 p->mark = mark;
6570 }
6571 res = NULL;
6572 done:
6573 return res;
6574}
6575
6576// Left-recursive
6577// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor
6578static expr_ty bitwise_or_raw(Parser *);
6579static expr_ty
6580bitwise_or_rule(Parser *p)
6581{
6582 expr_ty res = NULL;
6583 if (_PyPegen_is_memoized(p, bitwise_or_type, &res))
6584 return res;
6585 int mark = p->mark;
6586 int resmark = p->mark;
6587 while (1) {
6588 int tmpvar_1 = _PyPegen_update_memo(p, mark, bitwise_or_type, res);
6589 if (tmpvar_1) {
6590 return res;
6591 }
6592 p->mark = mark;
6593 void *raw = bitwise_or_raw(p);
6594 if (raw == NULL || p->mark <= resmark)
6595 break;
6596 resmark = p->mark;
6597 res = raw;
6598 }
6599 p->mark = resmark;
6600 return res;
6601}
6602static expr_ty
6603bitwise_or_raw(Parser *p)
6604{
6605 if (p->error_indicator) {
6606 return NULL;
6607 }
6608 expr_ty res = NULL;
6609 int mark = p->mark;
6610 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6611 p->error_indicator = 1;
6612 return NULL;
6613 }
6614 int start_lineno = p->tokens[mark]->lineno;
6615 UNUSED(start_lineno); // Only used by EXTRA macro
6616 int start_col_offset = p->tokens[mark]->col_offset;
6617 UNUSED(start_col_offset); // Only used by EXTRA macro
6618 { // bitwise_or '|' bitwise_xor
6619 expr_ty a;
6620 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006621 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006622 if (
6623 (a = bitwise_or_rule(p))
6624 &&
6625 (literal = _PyPegen_expect_token(p, 18))
6626 &&
6627 (b = bitwise_xor_rule(p))
6628 )
6629 {
6630 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6631 if (token == NULL) {
6632 return NULL;
6633 }
6634 int end_lineno = token->end_lineno;
6635 UNUSED(end_lineno); // Only used by EXTRA macro
6636 int end_col_offset = token->end_col_offset;
6637 UNUSED(end_col_offset); // Only used by EXTRA macro
6638 res = _Py_BinOp ( a , BitOr , b , EXTRA );
6639 if (res == NULL && PyErr_Occurred()) {
6640 p->error_indicator = 1;
6641 return NULL;
6642 }
6643 goto done;
6644 }
6645 p->mark = mark;
6646 }
6647 { // bitwise_xor
6648 expr_ty bitwise_xor_var;
6649 if (
6650 (bitwise_xor_var = bitwise_xor_rule(p))
6651 )
6652 {
6653 res = bitwise_xor_var;
6654 goto done;
6655 }
6656 p->mark = mark;
6657 }
6658 res = NULL;
6659 done:
6660 return res;
6661}
6662
6663// Left-recursive
6664// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and
6665static expr_ty bitwise_xor_raw(Parser *);
6666static expr_ty
6667bitwise_xor_rule(Parser *p)
6668{
6669 expr_ty res = NULL;
6670 if (_PyPegen_is_memoized(p, bitwise_xor_type, &res))
6671 return res;
6672 int mark = p->mark;
6673 int resmark = p->mark;
6674 while (1) {
6675 int tmpvar_2 = _PyPegen_update_memo(p, mark, bitwise_xor_type, res);
6676 if (tmpvar_2) {
6677 return res;
6678 }
6679 p->mark = mark;
6680 void *raw = bitwise_xor_raw(p);
6681 if (raw == NULL || p->mark <= resmark)
6682 break;
6683 resmark = p->mark;
6684 res = raw;
6685 }
6686 p->mark = resmark;
6687 return res;
6688}
6689static expr_ty
6690bitwise_xor_raw(Parser *p)
6691{
6692 if (p->error_indicator) {
6693 return NULL;
6694 }
6695 expr_ty res = NULL;
6696 int mark = p->mark;
6697 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6698 p->error_indicator = 1;
6699 return NULL;
6700 }
6701 int start_lineno = p->tokens[mark]->lineno;
6702 UNUSED(start_lineno); // Only used by EXTRA macro
6703 int start_col_offset = p->tokens[mark]->col_offset;
6704 UNUSED(start_col_offset); // Only used by EXTRA macro
6705 { // bitwise_xor '^' bitwise_and
6706 expr_ty a;
6707 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006708 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006709 if (
6710 (a = bitwise_xor_rule(p))
6711 &&
6712 (literal = _PyPegen_expect_token(p, 32))
6713 &&
6714 (b = bitwise_and_rule(p))
6715 )
6716 {
6717 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6718 if (token == NULL) {
6719 return NULL;
6720 }
6721 int end_lineno = token->end_lineno;
6722 UNUSED(end_lineno); // Only used by EXTRA macro
6723 int end_col_offset = token->end_col_offset;
6724 UNUSED(end_col_offset); // Only used by EXTRA macro
6725 res = _Py_BinOp ( a , BitXor , b , EXTRA );
6726 if (res == NULL && PyErr_Occurred()) {
6727 p->error_indicator = 1;
6728 return NULL;
6729 }
6730 goto done;
6731 }
6732 p->mark = mark;
6733 }
6734 { // bitwise_and
6735 expr_ty bitwise_and_var;
6736 if (
6737 (bitwise_and_var = bitwise_and_rule(p))
6738 )
6739 {
6740 res = bitwise_and_var;
6741 goto done;
6742 }
6743 p->mark = mark;
6744 }
6745 res = NULL;
6746 done:
6747 return res;
6748}
6749
6750// Left-recursive
6751// bitwise_and: bitwise_and '&' shift_expr | shift_expr
6752static expr_ty bitwise_and_raw(Parser *);
6753static expr_ty
6754bitwise_and_rule(Parser *p)
6755{
6756 expr_ty res = NULL;
6757 if (_PyPegen_is_memoized(p, bitwise_and_type, &res))
6758 return res;
6759 int mark = p->mark;
6760 int resmark = p->mark;
6761 while (1) {
6762 int tmpvar_3 = _PyPegen_update_memo(p, mark, bitwise_and_type, res);
6763 if (tmpvar_3) {
6764 return res;
6765 }
6766 p->mark = mark;
6767 void *raw = bitwise_and_raw(p);
6768 if (raw == NULL || p->mark <= resmark)
6769 break;
6770 resmark = p->mark;
6771 res = raw;
6772 }
6773 p->mark = resmark;
6774 return res;
6775}
6776static expr_ty
6777bitwise_and_raw(Parser *p)
6778{
6779 if (p->error_indicator) {
6780 return NULL;
6781 }
6782 expr_ty res = NULL;
6783 int mark = p->mark;
6784 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6785 p->error_indicator = 1;
6786 return NULL;
6787 }
6788 int start_lineno = p->tokens[mark]->lineno;
6789 UNUSED(start_lineno); // Only used by EXTRA macro
6790 int start_col_offset = p->tokens[mark]->col_offset;
6791 UNUSED(start_col_offset); // Only used by EXTRA macro
6792 { // bitwise_and '&' shift_expr
6793 expr_ty a;
6794 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006795 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006796 if (
6797 (a = bitwise_and_rule(p))
6798 &&
6799 (literal = _PyPegen_expect_token(p, 19))
6800 &&
6801 (b = shift_expr_rule(p))
6802 )
6803 {
6804 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6805 if (token == NULL) {
6806 return NULL;
6807 }
6808 int end_lineno = token->end_lineno;
6809 UNUSED(end_lineno); // Only used by EXTRA macro
6810 int end_col_offset = token->end_col_offset;
6811 UNUSED(end_col_offset); // Only used by EXTRA macro
6812 res = _Py_BinOp ( a , BitAnd , b , EXTRA );
6813 if (res == NULL && PyErr_Occurred()) {
6814 p->error_indicator = 1;
6815 return NULL;
6816 }
6817 goto done;
6818 }
6819 p->mark = mark;
6820 }
6821 { // shift_expr
6822 expr_ty shift_expr_var;
6823 if (
6824 (shift_expr_var = shift_expr_rule(p))
6825 )
6826 {
6827 res = shift_expr_var;
6828 goto done;
6829 }
6830 p->mark = mark;
6831 }
6832 res = NULL;
6833 done:
6834 return res;
6835}
6836
6837// Left-recursive
6838// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum
6839static expr_ty shift_expr_raw(Parser *);
6840static expr_ty
6841shift_expr_rule(Parser *p)
6842{
6843 expr_ty res = NULL;
6844 if (_PyPegen_is_memoized(p, shift_expr_type, &res))
6845 return res;
6846 int mark = p->mark;
6847 int resmark = p->mark;
6848 while (1) {
6849 int tmpvar_4 = _PyPegen_update_memo(p, mark, shift_expr_type, res);
6850 if (tmpvar_4) {
6851 return res;
6852 }
6853 p->mark = mark;
6854 void *raw = shift_expr_raw(p);
6855 if (raw == NULL || p->mark <= resmark)
6856 break;
6857 resmark = p->mark;
6858 res = raw;
6859 }
6860 p->mark = resmark;
6861 return res;
6862}
6863static expr_ty
6864shift_expr_raw(Parser *p)
6865{
6866 if (p->error_indicator) {
6867 return NULL;
6868 }
6869 expr_ty res = NULL;
6870 int mark = p->mark;
6871 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6872 p->error_indicator = 1;
6873 return NULL;
6874 }
6875 int start_lineno = p->tokens[mark]->lineno;
6876 UNUSED(start_lineno); // Only used by EXTRA macro
6877 int start_col_offset = p->tokens[mark]->col_offset;
6878 UNUSED(start_col_offset); // Only used by EXTRA macro
6879 { // shift_expr '<<' sum
6880 expr_ty a;
6881 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006882 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006883 if (
6884 (a = shift_expr_rule(p))
6885 &&
6886 (literal = _PyPegen_expect_token(p, 33))
6887 &&
6888 (b = sum_rule(p))
6889 )
6890 {
6891 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6892 if (token == NULL) {
6893 return NULL;
6894 }
6895 int end_lineno = token->end_lineno;
6896 UNUSED(end_lineno); // Only used by EXTRA macro
6897 int end_col_offset = token->end_col_offset;
6898 UNUSED(end_col_offset); // Only used by EXTRA macro
6899 res = _Py_BinOp ( a , LShift , b , EXTRA );
6900 if (res == NULL && PyErr_Occurred()) {
6901 p->error_indicator = 1;
6902 return NULL;
6903 }
6904 goto done;
6905 }
6906 p->mark = mark;
6907 }
6908 { // shift_expr '>>' sum
6909 expr_ty a;
6910 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006911 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006912 if (
6913 (a = shift_expr_rule(p))
6914 &&
6915 (literal = _PyPegen_expect_token(p, 34))
6916 &&
6917 (b = sum_rule(p))
6918 )
6919 {
6920 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6921 if (token == NULL) {
6922 return NULL;
6923 }
6924 int end_lineno = token->end_lineno;
6925 UNUSED(end_lineno); // Only used by EXTRA macro
6926 int end_col_offset = token->end_col_offset;
6927 UNUSED(end_col_offset); // Only used by EXTRA macro
6928 res = _Py_BinOp ( a , RShift , b , EXTRA );
6929 if (res == NULL && PyErr_Occurred()) {
6930 p->error_indicator = 1;
6931 return NULL;
6932 }
6933 goto done;
6934 }
6935 p->mark = mark;
6936 }
6937 { // sum
6938 expr_ty sum_var;
6939 if (
6940 (sum_var = sum_rule(p))
6941 )
6942 {
6943 res = sum_var;
6944 goto done;
6945 }
6946 p->mark = mark;
6947 }
6948 res = NULL;
6949 done:
6950 return res;
6951}
6952
6953// Left-recursive
6954// sum: sum '+' term | sum '-' term | term
6955static expr_ty sum_raw(Parser *);
6956static expr_ty
6957sum_rule(Parser *p)
6958{
6959 expr_ty res = NULL;
6960 if (_PyPegen_is_memoized(p, sum_type, &res))
6961 return res;
6962 int mark = p->mark;
6963 int resmark = p->mark;
6964 while (1) {
6965 int tmpvar_5 = _PyPegen_update_memo(p, mark, sum_type, res);
6966 if (tmpvar_5) {
6967 return res;
6968 }
6969 p->mark = mark;
6970 void *raw = sum_raw(p);
6971 if (raw == NULL || p->mark <= resmark)
6972 break;
6973 resmark = p->mark;
6974 res = raw;
6975 }
6976 p->mark = resmark;
6977 return res;
6978}
6979static expr_ty
6980sum_raw(Parser *p)
6981{
6982 if (p->error_indicator) {
6983 return NULL;
6984 }
6985 expr_ty res = NULL;
6986 int mark = p->mark;
6987 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6988 p->error_indicator = 1;
6989 return NULL;
6990 }
6991 int start_lineno = p->tokens[mark]->lineno;
6992 UNUSED(start_lineno); // Only used by EXTRA macro
6993 int start_col_offset = p->tokens[mark]->col_offset;
6994 UNUSED(start_col_offset); // Only used by EXTRA macro
6995 { // sum '+' term
6996 expr_ty a;
6997 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006998 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006999 if (
7000 (a = sum_rule(p))
7001 &&
7002 (literal = _PyPegen_expect_token(p, 14))
7003 &&
7004 (b = term_rule(p))
7005 )
7006 {
7007 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7008 if (token == NULL) {
7009 return NULL;
7010 }
7011 int end_lineno = token->end_lineno;
7012 UNUSED(end_lineno); // Only used by EXTRA macro
7013 int end_col_offset = token->end_col_offset;
7014 UNUSED(end_col_offset); // Only used by EXTRA macro
7015 res = _Py_BinOp ( a , Add , b , EXTRA );
7016 if (res == NULL && PyErr_Occurred()) {
7017 p->error_indicator = 1;
7018 return NULL;
7019 }
7020 goto done;
7021 }
7022 p->mark = mark;
7023 }
7024 { // sum '-' term
7025 expr_ty a;
7026 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007027 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007028 if (
7029 (a = sum_rule(p))
7030 &&
7031 (literal = _PyPegen_expect_token(p, 15))
7032 &&
7033 (b = term_rule(p))
7034 )
7035 {
7036 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7037 if (token == NULL) {
7038 return NULL;
7039 }
7040 int end_lineno = token->end_lineno;
7041 UNUSED(end_lineno); // Only used by EXTRA macro
7042 int end_col_offset = token->end_col_offset;
7043 UNUSED(end_col_offset); // Only used by EXTRA macro
7044 res = _Py_BinOp ( a , Sub , b , EXTRA );
7045 if (res == NULL && PyErr_Occurred()) {
7046 p->error_indicator = 1;
7047 return NULL;
7048 }
7049 goto done;
7050 }
7051 p->mark = mark;
7052 }
7053 { // term
7054 expr_ty term_var;
7055 if (
7056 (term_var = term_rule(p))
7057 )
7058 {
7059 res = term_var;
7060 goto done;
7061 }
7062 p->mark = mark;
7063 }
7064 res = NULL;
7065 done:
7066 return res;
7067}
7068
7069// Left-recursive
7070// term:
7071// | term '*' factor
7072// | term '/' factor
7073// | term '//' factor
7074// | term '%' factor
7075// | term '@' factor
7076// | factor
7077static expr_ty term_raw(Parser *);
7078static expr_ty
7079term_rule(Parser *p)
7080{
7081 expr_ty res = NULL;
7082 if (_PyPegen_is_memoized(p, term_type, &res))
7083 return res;
7084 int mark = p->mark;
7085 int resmark = p->mark;
7086 while (1) {
7087 int tmpvar_6 = _PyPegen_update_memo(p, mark, term_type, res);
7088 if (tmpvar_6) {
7089 return res;
7090 }
7091 p->mark = mark;
7092 void *raw = term_raw(p);
7093 if (raw == NULL || p->mark <= resmark)
7094 break;
7095 resmark = p->mark;
7096 res = raw;
7097 }
7098 p->mark = resmark;
7099 return res;
7100}
7101static expr_ty
7102term_raw(Parser *p)
7103{
7104 if (p->error_indicator) {
7105 return NULL;
7106 }
7107 expr_ty res = NULL;
7108 int mark = p->mark;
7109 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7110 p->error_indicator = 1;
7111 return NULL;
7112 }
7113 int start_lineno = p->tokens[mark]->lineno;
7114 UNUSED(start_lineno); // Only used by EXTRA macro
7115 int start_col_offset = p->tokens[mark]->col_offset;
7116 UNUSED(start_col_offset); // Only used by EXTRA macro
7117 { // term '*' factor
7118 expr_ty a;
7119 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007120 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007121 if (
7122 (a = term_rule(p))
7123 &&
7124 (literal = _PyPegen_expect_token(p, 16))
7125 &&
7126 (b = factor_rule(p))
7127 )
7128 {
7129 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7130 if (token == NULL) {
7131 return NULL;
7132 }
7133 int end_lineno = token->end_lineno;
7134 UNUSED(end_lineno); // Only used by EXTRA macro
7135 int end_col_offset = token->end_col_offset;
7136 UNUSED(end_col_offset); // Only used by EXTRA macro
7137 res = _Py_BinOp ( a , Mult , b , EXTRA );
7138 if (res == NULL && PyErr_Occurred()) {
7139 p->error_indicator = 1;
7140 return NULL;
7141 }
7142 goto done;
7143 }
7144 p->mark = mark;
7145 }
7146 { // term '/' factor
7147 expr_ty a;
7148 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007149 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007150 if (
7151 (a = term_rule(p))
7152 &&
7153 (literal = _PyPegen_expect_token(p, 17))
7154 &&
7155 (b = factor_rule(p))
7156 )
7157 {
7158 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7159 if (token == NULL) {
7160 return NULL;
7161 }
7162 int end_lineno = token->end_lineno;
7163 UNUSED(end_lineno); // Only used by EXTRA macro
7164 int end_col_offset = token->end_col_offset;
7165 UNUSED(end_col_offset); // Only used by EXTRA macro
7166 res = _Py_BinOp ( a , Div , b , EXTRA );
7167 if (res == NULL && PyErr_Occurred()) {
7168 p->error_indicator = 1;
7169 return NULL;
7170 }
7171 goto done;
7172 }
7173 p->mark = mark;
7174 }
7175 { // term '//' factor
7176 expr_ty a;
7177 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007178 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007179 if (
7180 (a = term_rule(p))
7181 &&
7182 (literal = _PyPegen_expect_token(p, 47))
7183 &&
7184 (b = factor_rule(p))
7185 )
7186 {
7187 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7188 if (token == NULL) {
7189 return NULL;
7190 }
7191 int end_lineno = token->end_lineno;
7192 UNUSED(end_lineno); // Only used by EXTRA macro
7193 int end_col_offset = token->end_col_offset;
7194 UNUSED(end_col_offset); // Only used by EXTRA macro
7195 res = _Py_BinOp ( a , FloorDiv , b , EXTRA );
7196 if (res == NULL && PyErr_Occurred()) {
7197 p->error_indicator = 1;
7198 return NULL;
7199 }
7200 goto done;
7201 }
7202 p->mark = mark;
7203 }
7204 { // term '%' factor
7205 expr_ty a;
7206 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007207 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007208 if (
7209 (a = term_rule(p))
7210 &&
7211 (literal = _PyPegen_expect_token(p, 24))
7212 &&
7213 (b = factor_rule(p))
7214 )
7215 {
7216 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7217 if (token == NULL) {
7218 return NULL;
7219 }
7220 int end_lineno = token->end_lineno;
7221 UNUSED(end_lineno); // Only used by EXTRA macro
7222 int end_col_offset = token->end_col_offset;
7223 UNUSED(end_col_offset); // Only used by EXTRA macro
7224 res = _Py_BinOp ( a , Mod , b , EXTRA );
7225 if (res == NULL && PyErr_Occurred()) {
7226 p->error_indicator = 1;
7227 return NULL;
7228 }
7229 goto done;
7230 }
7231 p->mark = mark;
7232 }
7233 { // term '@' factor
7234 expr_ty a;
7235 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007236 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007237 if (
7238 (a = term_rule(p))
7239 &&
7240 (literal = _PyPegen_expect_token(p, 49))
7241 &&
7242 (b = factor_rule(p))
7243 )
7244 {
7245 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7246 if (token == NULL) {
7247 return NULL;
7248 }
7249 int end_lineno = token->end_lineno;
7250 UNUSED(end_lineno); // Only used by EXTRA macro
7251 int end_col_offset = token->end_col_offset;
7252 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007253 res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007254 if (res == NULL && PyErr_Occurred()) {
7255 p->error_indicator = 1;
7256 return NULL;
7257 }
7258 goto done;
7259 }
7260 p->mark = mark;
7261 }
7262 { // factor
7263 expr_ty factor_var;
7264 if (
7265 (factor_var = factor_rule(p))
7266 )
7267 {
7268 res = factor_var;
7269 goto done;
7270 }
7271 p->mark = mark;
7272 }
7273 res = NULL;
7274 done:
7275 return res;
7276}
7277
7278// factor: '+' factor | '-' factor | '~' factor | power
7279static expr_ty
7280factor_rule(Parser *p)
7281{
7282 if (p->error_indicator) {
7283 return NULL;
7284 }
7285 expr_ty res = NULL;
7286 if (_PyPegen_is_memoized(p, factor_type, &res))
7287 return res;
7288 int mark = p->mark;
7289 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7290 p->error_indicator = 1;
7291 return NULL;
7292 }
7293 int start_lineno = p->tokens[mark]->lineno;
7294 UNUSED(start_lineno); // Only used by EXTRA macro
7295 int start_col_offset = p->tokens[mark]->col_offset;
7296 UNUSED(start_col_offset); // Only used by EXTRA macro
7297 { // '+' factor
7298 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007299 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007300 if (
7301 (literal = _PyPegen_expect_token(p, 14))
7302 &&
7303 (a = factor_rule(p))
7304 )
7305 {
7306 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7307 if (token == NULL) {
7308 return NULL;
7309 }
7310 int end_lineno = token->end_lineno;
7311 UNUSED(end_lineno); // Only used by EXTRA macro
7312 int end_col_offset = token->end_col_offset;
7313 UNUSED(end_col_offset); // Only used by EXTRA macro
7314 res = _Py_UnaryOp ( UAdd , a , EXTRA );
7315 if (res == NULL && PyErr_Occurred()) {
7316 p->error_indicator = 1;
7317 return NULL;
7318 }
7319 goto done;
7320 }
7321 p->mark = mark;
7322 }
7323 { // '-' factor
7324 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007325 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007326 if (
7327 (literal = _PyPegen_expect_token(p, 15))
7328 &&
7329 (a = factor_rule(p))
7330 )
7331 {
7332 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7333 if (token == NULL) {
7334 return NULL;
7335 }
7336 int end_lineno = token->end_lineno;
7337 UNUSED(end_lineno); // Only used by EXTRA macro
7338 int end_col_offset = token->end_col_offset;
7339 UNUSED(end_col_offset); // Only used by EXTRA macro
7340 res = _Py_UnaryOp ( USub , a , EXTRA );
7341 if (res == NULL && PyErr_Occurred()) {
7342 p->error_indicator = 1;
7343 return NULL;
7344 }
7345 goto done;
7346 }
7347 p->mark = mark;
7348 }
7349 { // '~' factor
7350 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007351 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007352 if (
7353 (literal = _PyPegen_expect_token(p, 31))
7354 &&
7355 (a = factor_rule(p))
7356 )
7357 {
7358 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7359 if (token == NULL) {
7360 return NULL;
7361 }
7362 int end_lineno = token->end_lineno;
7363 UNUSED(end_lineno); // Only used by EXTRA macro
7364 int end_col_offset = token->end_col_offset;
7365 UNUSED(end_col_offset); // Only used by EXTRA macro
7366 res = _Py_UnaryOp ( Invert , a , EXTRA );
7367 if (res == NULL && PyErr_Occurred()) {
7368 p->error_indicator = 1;
7369 return NULL;
7370 }
7371 goto done;
7372 }
7373 p->mark = mark;
7374 }
7375 { // power
7376 expr_ty power_var;
7377 if (
7378 (power_var = power_rule(p))
7379 )
7380 {
7381 res = power_var;
7382 goto done;
7383 }
7384 p->mark = mark;
7385 }
7386 res = NULL;
7387 done:
7388 _PyPegen_insert_memo(p, mark, factor_type, res);
7389 return res;
7390}
7391
7392// power: await_primary '**' factor | await_primary
7393static expr_ty
7394power_rule(Parser *p)
7395{
7396 if (p->error_indicator) {
7397 return NULL;
7398 }
7399 expr_ty res = NULL;
7400 int mark = p->mark;
7401 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7402 p->error_indicator = 1;
7403 return NULL;
7404 }
7405 int start_lineno = p->tokens[mark]->lineno;
7406 UNUSED(start_lineno); // Only used by EXTRA macro
7407 int start_col_offset = p->tokens[mark]->col_offset;
7408 UNUSED(start_col_offset); // Only used by EXTRA macro
7409 { // await_primary '**' factor
7410 expr_ty a;
7411 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007412 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007413 if (
7414 (a = await_primary_rule(p))
7415 &&
7416 (literal = _PyPegen_expect_token(p, 35))
7417 &&
7418 (b = factor_rule(p))
7419 )
7420 {
7421 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7422 if (token == NULL) {
7423 return NULL;
7424 }
7425 int end_lineno = token->end_lineno;
7426 UNUSED(end_lineno); // Only used by EXTRA macro
7427 int end_col_offset = token->end_col_offset;
7428 UNUSED(end_col_offset); // Only used by EXTRA macro
7429 res = _Py_BinOp ( a , Pow , b , EXTRA );
7430 if (res == NULL && PyErr_Occurred()) {
7431 p->error_indicator = 1;
7432 return NULL;
7433 }
7434 goto done;
7435 }
7436 p->mark = mark;
7437 }
7438 { // await_primary
7439 expr_ty await_primary_var;
7440 if (
7441 (await_primary_var = await_primary_rule(p))
7442 )
7443 {
7444 res = await_primary_var;
7445 goto done;
7446 }
7447 p->mark = mark;
7448 }
7449 res = NULL;
7450 done:
7451 return res;
7452}
7453
7454// await_primary: AWAIT primary | primary
7455static expr_ty
7456await_primary_rule(Parser *p)
7457{
7458 if (p->error_indicator) {
7459 return NULL;
7460 }
7461 expr_ty res = NULL;
7462 if (_PyPegen_is_memoized(p, await_primary_type, &res))
7463 return res;
7464 int mark = p->mark;
7465 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7466 p->error_indicator = 1;
7467 return NULL;
7468 }
7469 int start_lineno = p->tokens[mark]->lineno;
7470 UNUSED(start_lineno); // Only used by EXTRA macro
7471 int start_col_offset = p->tokens[mark]->col_offset;
7472 UNUSED(start_col_offset); // Only used by EXTRA macro
7473 { // AWAIT primary
7474 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007475 Token * await_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007476 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +01007477 (await_var = _PyPegen_expect_token(p, AWAIT))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007478 &&
7479 (a = primary_rule(p))
7480 )
7481 {
7482 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7483 if (token == NULL) {
7484 return NULL;
7485 }
7486 int end_lineno = token->end_lineno;
7487 UNUSED(end_lineno); // Only used by EXTRA macro
7488 int end_col_offset = token->end_col_offset;
7489 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007490 res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007491 if (res == NULL && PyErr_Occurred()) {
7492 p->error_indicator = 1;
7493 return NULL;
7494 }
7495 goto done;
7496 }
7497 p->mark = mark;
7498 }
7499 { // primary
7500 expr_ty primary_var;
7501 if (
7502 (primary_var = primary_rule(p))
7503 )
7504 {
7505 res = primary_var;
7506 goto done;
7507 }
7508 p->mark = mark;
7509 }
7510 res = NULL;
7511 done:
7512 _PyPegen_insert_memo(p, mark, await_primary_type, res);
7513 return res;
7514}
7515
7516// Left-recursive
7517// primary:
7518// | primary '.' NAME
7519// | primary genexp
7520// | primary '(' arguments? ')'
7521// | primary '[' slices ']'
7522// | atom
7523static expr_ty primary_raw(Parser *);
7524static expr_ty
7525primary_rule(Parser *p)
7526{
7527 expr_ty res = NULL;
7528 if (_PyPegen_is_memoized(p, primary_type, &res))
7529 return res;
7530 int mark = p->mark;
7531 int resmark = p->mark;
7532 while (1) {
7533 int tmpvar_7 = _PyPegen_update_memo(p, mark, primary_type, res);
7534 if (tmpvar_7) {
7535 return res;
7536 }
7537 p->mark = mark;
7538 void *raw = primary_raw(p);
7539 if (raw == NULL || p->mark <= resmark)
7540 break;
7541 resmark = p->mark;
7542 res = raw;
7543 }
7544 p->mark = resmark;
7545 return res;
7546}
7547static expr_ty
7548primary_raw(Parser *p)
7549{
7550 if (p->error_indicator) {
7551 return NULL;
7552 }
7553 expr_ty res = NULL;
7554 int mark = p->mark;
7555 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7556 p->error_indicator = 1;
7557 return NULL;
7558 }
7559 int start_lineno = p->tokens[mark]->lineno;
7560 UNUSED(start_lineno); // Only used by EXTRA macro
7561 int start_col_offset = p->tokens[mark]->col_offset;
7562 UNUSED(start_col_offset); // Only used by EXTRA macro
7563 { // primary '.' NAME
7564 expr_ty a;
7565 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007566 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007567 if (
7568 (a = primary_rule(p))
7569 &&
7570 (literal = _PyPegen_expect_token(p, 23))
7571 &&
7572 (b = _PyPegen_name_token(p))
7573 )
7574 {
7575 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7576 if (token == NULL) {
7577 return NULL;
7578 }
7579 int end_lineno = token->end_lineno;
7580 UNUSED(end_lineno); // Only used by EXTRA macro
7581 int end_col_offset = token->end_col_offset;
7582 UNUSED(end_col_offset); // Only used by EXTRA macro
7583 res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
7584 if (res == NULL && PyErr_Occurred()) {
7585 p->error_indicator = 1;
7586 return NULL;
7587 }
7588 goto done;
7589 }
7590 p->mark = mark;
7591 }
7592 { // primary genexp
7593 expr_ty a;
7594 expr_ty b;
7595 if (
7596 (a = primary_rule(p))
7597 &&
7598 (b = genexp_rule(p))
7599 )
7600 {
7601 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7602 if (token == NULL) {
7603 return NULL;
7604 }
7605 int end_lineno = token->end_lineno;
7606 UNUSED(end_lineno); // Only used by EXTRA macro
7607 int end_col_offset = token->end_col_offset;
7608 UNUSED(end_col_offset); // Only used by EXTRA macro
7609 res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
7610 if (res == NULL && PyErr_Occurred()) {
7611 p->error_indicator = 1;
7612 return NULL;
7613 }
7614 goto done;
7615 }
7616 p->mark = mark;
7617 }
7618 { // primary '(' arguments? ')'
7619 expr_ty a;
7620 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007621 Token * literal;
7622 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007623 if (
7624 (a = primary_rule(p))
7625 &&
7626 (literal = _PyPegen_expect_token(p, 7))
7627 &&
7628 (b = arguments_rule(p), 1)
7629 &&
7630 (literal_1 = _PyPegen_expect_token(p, 8))
7631 )
7632 {
7633 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7634 if (token == NULL) {
7635 return NULL;
7636 }
7637 int end_lineno = token->end_lineno;
7638 UNUSED(end_lineno); // Only used by EXTRA macro
7639 int end_col_offset = token->end_col_offset;
7640 UNUSED(end_col_offset); // Only used by EXTRA macro
7641 res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
7642 if (res == NULL && PyErr_Occurred()) {
7643 p->error_indicator = 1;
7644 return NULL;
7645 }
7646 goto done;
7647 }
7648 p->mark = mark;
7649 }
7650 { // primary '[' slices ']'
7651 expr_ty a;
7652 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007653 Token * literal;
7654 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007655 if (
7656 (a = primary_rule(p))
7657 &&
7658 (literal = _PyPegen_expect_token(p, 9))
7659 &&
7660 (b = slices_rule(p))
7661 &&
7662 (literal_1 = _PyPegen_expect_token(p, 10))
7663 )
7664 {
7665 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7666 if (token == NULL) {
7667 return NULL;
7668 }
7669 int end_lineno = token->end_lineno;
7670 UNUSED(end_lineno); // Only used by EXTRA macro
7671 int end_col_offset = token->end_col_offset;
7672 UNUSED(end_col_offset); // Only used by EXTRA macro
7673 res = _Py_Subscript ( a , b , Load , EXTRA );
7674 if (res == NULL && PyErr_Occurred()) {
7675 p->error_indicator = 1;
7676 return NULL;
7677 }
7678 goto done;
7679 }
7680 p->mark = mark;
7681 }
7682 { // atom
7683 expr_ty atom_var;
7684 if (
7685 (atom_var = atom_rule(p))
7686 )
7687 {
7688 res = atom_var;
7689 goto done;
7690 }
7691 p->mark = mark;
7692 }
7693 res = NULL;
7694 done:
7695 return res;
7696}
7697
7698// slices: slice !',' | ','.slice+ ','?
7699static expr_ty
7700slices_rule(Parser *p)
7701{
7702 if (p->error_indicator) {
7703 return NULL;
7704 }
7705 expr_ty res = NULL;
7706 int mark = p->mark;
7707 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7708 p->error_indicator = 1;
7709 return NULL;
7710 }
7711 int start_lineno = p->tokens[mark]->lineno;
7712 UNUSED(start_lineno); // Only used by EXTRA macro
7713 int start_col_offset = p->tokens[mark]->col_offset;
7714 UNUSED(start_col_offset); // Only used by EXTRA macro
7715 { // slice !','
7716 expr_ty a;
7717 if (
7718 (a = slice_rule(p))
7719 &&
7720 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12)
7721 )
7722 {
7723 res = a;
7724 if (res == NULL && PyErr_Occurred()) {
7725 p->error_indicator = 1;
7726 return NULL;
7727 }
7728 goto done;
7729 }
7730 p->mark = mark;
7731 }
7732 { // ','.slice+ ','?
7733 asdl_seq * a;
7734 void *opt_var;
7735 UNUSED(opt_var); // Silence compiler warnings
7736 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07007737 (a = _gather_93_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007738 &&
7739 (opt_var = _PyPegen_expect_token(p, 12), 1)
7740 )
7741 {
7742 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7743 if (token == NULL) {
7744 return NULL;
7745 }
7746 int end_lineno = token->end_lineno;
7747 UNUSED(end_lineno); // Only used by EXTRA macro
7748 int end_col_offset = token->end_col_offset;
7749 UNUSED(end_col_offset); // Only used by EXTRA macro
7750 res = _Py_Tuple ( a , Load , EXTRA );
7751 if (res == NULL && PyErr_Occurred()) {
7752 p->error_indicator = 1;
7753 return NULL;
7754 }
7755 goto done;
7756 }
7757 p->mark = mark;
7758 }
7759 res = NULL;
7760 done:
7761 return res;
7762}
7763
7764// slice: expression? ':' expression? [':' expression?] | expression
7765static expr_ty
7766slice_rule(Parser *p)
7767{
7768 if (p->error_indicator) {
7769 return NULL;
7770 }
7771 expr_ty res = NULL;
7772 int mark = p->mark;
7773 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7774 p->error_indicator = 1;
7775 return NULL;
7776 }
7777 int start_lineno = p->tokens[mark]->lineno;
7778 UNUSED(start_lineno); // Only used by EXTRA macro
7779 int start_col_offset = p->tokens[mark]->col_offset;
7780 UNUSED(start_col_offset); // Only used by EXTRA macro
7781 { // expression? ':' expression? [':' expression?]
7782 void *a;
7783 void *b;
7784 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007785 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007786 if (
7787 (a = expression_rule(p), 1)
7788 &&
7789 (literal = _PyPegen_expect_token(p, 11))
7790 &&
7791 (b = expression_rule(p), 1)
7792 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07007793 (c = _tmp_95_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007794 )
7795 {
7796 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7797 if (token == NULL) {
7798 return NULL;
7799 }
7800 int end_lineno = token->end_lineno;
7801 UNUSED(end_lineno); // Only used by EXTRA macro
7802 int end_col_offset = token->end_col_offset;
7803 UNUSED(end_col_offset); // Only used by EXTRA macro
7804 res = _Py_Slice ( a , b , c , EXTRA );
7805 if (res == NULL && PyErr_Occurred()) {
7806 p->error_indicator = 1;
7807 return NULL;
7808 }
7809 goto done;
7810 }
7811 p->mark = mark;
7812 }
7813 { // expression
7814 expr_ty a;
7815 if (
7816 (a = expression_rule(p))
7817 )
7818 {
7819 res = a;
7820 if (res == NULL && PyErr_Occurred()) {
7821 p->error_indicator = 1;
7822 return NULL;
7823 }
7824 goto done;
7825 }
7826 p->mark = mark;
7827 }
7828 res = NULL;
7829 done:
7830 return res;
7831}
7832
7833// atom:
7834// | NAME
7835// | 'True'
7836// | 'False'
7837// | 'None'
7838// | '__new_parser__'
7839// | &STRING strings
7840// | NUMBER
7841// | &'(' (tuple | group | genexp)
7842// | &'[' (list | listcomp)
7843// | &'{' (dict | set | dictcomp | setcomp)
7844// | '...'
7845static expr_ty
7846atom_rule(Parser *p)
7847{
7848 if (p->error_indicator) {
7849 return NULL;
7850 }
7851 expr_ty res = NULL;
7852 int mark = p->mark;
7853 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7854 p->error_indicator = 1;
7855 return NULL;
7856 }
7857 int start_lineno = p->tokens[mark]->lineno;
7858 UNUSED(start_lineno); // Only used by EXTRA macro
7859 int start_col_offset = p->tokens[mark]->col_offset;
7860 UNUSED(start_col_offset); // Only used by EXTRA macro
7861 { // NAME
7862 expr_ty name_var;
7863 if (
7864 (name_var = _PyPegen_name_token(p))
7865 )
7866 {
7867 res = name_var;
7868 goto done;
7869 }
7870 p->mark = mark;
7871 }
7872 { // 'True'
Pablo Galindob796b3f2020-05-01 12:32:26 +01007873 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007874 if (
7875 (keyword = _PyPegen_expect_token(p, 527))
7876 )
7877 {
7878 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7879 if (token == NULL) {
7880 return NULL;
7881 }
7882 int end_lineno = token->end_lineno;
7883 UNUSED(end_lineno); // Only used by EXTRA macro
7884 int end_col_offset = token->end_col_offset;
7885 UNUSED(end_col_offset); // Only used by EXTRA macro
7886 res = _Py_Constant ( Py_True , NULL , EXTRA );
7887 if (res == NULL && PyErr_Occurred()) {
7888 p->error_indicator = 1;
7889 return NULL;
7890 }
7891 goto done;
7892 }
7893 p->mark = mark;
7894 }
7895 { // 'False'
Pablo Galindob796b3f2020-05-01 12:32:26 +01007896 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007897 if (
7898 (keyword = _PyPegen_expect_token(p, 528))
7899 )
7900 {
7901 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7902 if (token == NULL) {
7903 return NULL;
7904 }
7905 int end_lineno = token->end_lineno;
7906 UNUSED(end_lineno); // Only used by EXTRA macro
7907 int end_col_offset = token->end_col_offset;
7908 UNUSED(end_col_offset); // Only used by EXTRA macro
7909 res = _Py_Constant ( Py_False , NULL , EXTRA );
7910 if (res == NULL && PyErr_Occurred()) {
7911 p->error_indicator = 1;
7912 return NULL;
7913 }
7914 goto done;
7915 }
7916 p->mark = mark;
7917 }
7918 { // 'None'
Pablo Galindob796b3f2020-05-01 12:32:26 +01007919 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007920 if (
7921 (keyword = _PyPegen_expect_token(p, 529))
7922 )
7923 {
7924 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7925 if (token == NULL) {
7926 return NULL;
7927 }
7928 int end_lineno = token->end_lineno;
7929 UNUSED(end_lineno); // Only used by EXTRA macro
7930 int end_col_offset = token->end_col_offset;
7931 UNUSED(end_col_offset); // Only used by EXTRA macro
7932 res = _Py_Constant ( Py_None , NULL , EXTRA );
7933 if (res == NULL && PyErr_Occurred()) {
7934 p->error_indicator = 1;
7935 return NULL;
7936 }
7937 goto done;
7938 }
7939 p->mark = mark;
7940 }
7941 { // '__new_parser__'
Pablo Galindob796b3f2020-05-01 12:32:26 +01007942 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007943 if (
7944 (keyword = _PyPegen_expect_token(p, 530))
7945 )
7946 {
7947 res = RAISE_SYNTAX_ERROR ( "You found it!" );
7948 if (res == NULL && PyErr_Occurred()) {
7949 p->error_indicator = 1;
7950 return NULL;
7951 }
7952 goto done;
7953 }
7954 p->mark = mark;
7955 }
7956 { // &STRING strings
7957 expr_ty strings_var;
7958 if (
7959 _PyPegen_lookahead(1, _PyPegen_string_token, p)
7960 &&
7961 (strings_var = strings_rule(p))
7962 )
7963 {
7964 res = strings_var;
7965 goto done;
7966 }
7967 p->mark = mark;
7968 }
7969 { // NUMBER
7970 expr_ty number_var;
7971 if (
7972 (number_var = _PyPegen_number_token(p))
7973 )
7974 {
7975 res = number_var;
7976 goto done;
7977 }
7978 p->mark = mark;
7979 }
7980 { // &'(' (tuple | group | genexp)
Guido van Rossum3941d972020-05-01 09:42:03 -07007981 void *_tmp_96_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007982 if (
Pablo Galindo2b74c832020-04-27 18:02:07 +01007983 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007984 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07007985 (_tmp_96_var = _tmp_96_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007986 )
7987 {
Guido van Rossum3941d972020-05-01 09:42:03 -07007988 res = _tmp_96_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007989 goto done;
7990 }
7991 p->mark = mark;
7992 }
Pablo Galindo2b74c832020-04-27 18:02:07 +01007993 { // &'[' (list | listcomp)
Guido van Rossum3941d972020-05-01 09:42:03 -07007994 void *_tmp_97_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007995 if (
Pablo Galindo2b74c832020-04-27 18:02:07 +01007996 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007997 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07007998 (_tmp_97_var = _tmp_97_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007999 )
8000 {
Guido van Rossum3941d972020-05-01 09:42:03 -07008001 res = _tmp_97_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008002 goto done;
8003 }
8004 p->mark = mark;
8005 }
Pablo Galindo2b74c832020-04-27 18:02:07 +01008006 { // &'{' (dict | set | dictcomp | setcomp)
Guido van Rossum3941d972020-05-01 09:42:03 -07008007 void *_tmp_98_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +01008008 if (
8009 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25)
8010 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07008011 (_tmp_98_var = _tmp_98_rule(p))
Pablo Galindo2b74c832020-04-27 18:02:07 +01008012 )
8013 {
Guido van Rossum3941d972020-05-01 09:42:03 -07008014 res = _tmp_98_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +01008015 goto done;
8016 }
8017 p->mark = mark;
8018 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008019 { // '...'
Pablo Galindob796b3f2020-05-01 12:32:26 +01008020 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008021 if (
8022 (literal = _PyPegen_expect_token(p, 52))
8023 )
8024 {
8025 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8026 if (token == NULL) {
8027 return NULL;
8028 }
8029 int end_lineno = token->end_lineno;
8030 UNUSED(end_lineno); // Only used by EXTRA macro
8031 int end_col_offset = token->end_col_offset;
8032 UNUSED(end_col_offset); // Only used by EXTRA macro
8033 res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA );
8034 if (res == NULL && PyErr_Occurred()) {
8035 p->error_indicator = 1;
8036 return NULL;
8037 }
8038 goto done;
8039 }
8040 p->mark = mark;
8041 }
8042 res = NULL;
8043 done:
8044 return res;
8045}
8046
8047// strings: STRING+
8048static expr_ty
8049strings_rule(Parser *p)
8050{
8051 if (p->error_indicator) {
8052 return NULL;
8053 }
8054 expr_ty res = NULL;
8055 if (_PyPegen_is_memoized(p, strings_type, &res))
8056 return res;
8057 int mark = p->mark;
8058 { // STRING+
8059 asdl_seq * a;
8060 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07008061 (a = _loop1_99_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008062 )
8063 {
8064 res = _PyPegen_concatenate_strings ( p , a );
8065 if (res == NULL && PyErr_Occurred()) {
8066 p->error_indicator = 1;
8067 return NULL;
8068 }
8069 goto done;
8070 }
8071 p->mark = mark;
8072 }
8073 res = NULL;
8074 done:
8075 _PyPegen_insert_memo(p, mark, strings_type, res);
8076 return res;
8077}
8078
8079// list: '[' star_named_expressions? ']'
8080static expr_ty
8081list_rule(Parser *p)
8082{
8083 if (p->error_indicator) {
8084 return NULL;
8085 }
8086 expr_ty res = NULL;
8087 int mark = p->mark;
8088 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8089 p->error_indicator = 1;
8090 return NULL;
8091 }
8092 int start_lineno = p->tokens[mark]->lineno;
8093 UNUSED(start_lineno); // Only used by EXTRA macro
8094 int start_col_offset = p->tokens[mark]->col_offset;
8095 UNUSED(start_col_offset); // Only used by EXTRA macro
8096 { // '[' star_named_expressions? ']'
8097 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008098 Token * literal;
8099 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008100 if (
8101 (literal = _PyPegen_expect_token(p, 9))
8102 &&
8103 (a = star_named_expressions_rule(p), 1)
8104 &&
8105 (literal_1 = _PyPegen_expect_token(p, 10))
8106 )
8107 {
8108 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8109 if (token == NULL) {
8110 return NULL;
8111 }
8112 int end_lineno = token->end_lineno;
8113 UNUSED(end_lineno); // Only used by EXTRA macro
8114 int end_col_offset = token->end_col_offset;
8115 UNUSED(end_col_offset); // Only used by EXTRA macro
8116 res = _Py_List ( a , Load , EXTRA );
8117 if (res == NULL && PyErr_Occurred()) {
8118 p->error_indicator = 1;
8119 return NULL;
8120 }
8121 goto done;
8122 }
8123 p->mark = mark;
8124 }
8125 res = NULL;
8126 done:
8127 return res;
8128}
8129
8130// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension
8131static expr_ty
8132listcomp_rule(Parser *p)
8133{
8134 if (p->error_indicator) {
8135 return NULL;
8136 }
8137 expr_ty res = NULL;
8138 int mark = p->mark;
8139 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8140 p->error_indicator = 1;
8141 return NULL;
8142 }
8143 int start_lineno = p->tokens[mark]->lineno;
8144 UNUSED(start_lineno); // Only used by EXTRA macro
8145 int start_col_offset = p->tokens[mark]->col_offset;
8146 UNUSED(start_col_offset); // Only used by EXTRA macro
8147 { // '[' named_expression for_if_clauses ']'
8148 expr_ty a;
8149 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008150 Token * literal;
8151 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008152 if (
8153 (literal = _PyPegen_expect_token(p, 9))
8154 &&
8155 (a = named_expression_rule(p))
8156 &&
8157 (b = for_if_clauses_rule(p))
8158 &&
8159 (literal_1 = _PyPegen_expect_token(p, 10))
8160 )
8161 {
8162 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8163 if (token == NULL) {
8164 return NULL;
8165 }
8166 int end_lineno = token->end_lineno;
8167 UNUSED(end_lineno); // Only used by EXTRA macro
8168 int end_col_offset = token->end_col_offset;
8169 UNUSED(end_col_offset); // Only used by EXTRA macro
8170 res = _Py_ListComp ( a , b , EXTRA );
8171 if (res == NULL && PyErr_Occurred()) {
8172 p->error_indicator = 1;
8173 return NULL;
8174 }
8175 goto done;
8176 }
8177 p->mark = mark;
8178 }
8179 { // invalid_comprehension
8180 void *invalid_comprehension_var;
8181 if (
8182 (invalid_comprehension_var = invalid_comprehension_rule(p))
8183 )
8184 {
8185 res = invalid_comprehension_var;
8186 goto done;
8187 }
8188 p->mark = mark;
8189 }
8190 res = NULL;
8191 done:
8192 return res;
8193}
8194
8195// tuple: '(' [star_named_expression ',' star_named_expressions?] ')'
8196static expr_ty
8197tuple_rule(Parser *p)
8198{
8199 if (p->error_indicator) {
8200 return NULL;
8201 }
8202 expr_ty res = NULL;
8203 int mark = p->mark;
8204 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8205 p->error_indicator = 1;
8206 return NULL;
8207 }
8208 int start_lineno = p->tokens[mark]->lineno;
8209 UNUSED(start_lineno); // Only used by EXTRA macro
8210 int start_col_offset = p->tokens[mark]->col_offset;
8211 UNUSED(start_col_offset); // Only used by EXTRA macro
8212 { // '(' [star_named_expression ',' star_named_expressions?] ')'
8213 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008214 Token * literal;
8215 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008216 if (
8217 (literal = _PyPegen_expect_token(p, 7))
8218 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07008219 (a = _tmp_100_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008220 &&
8221 (literal_1 = _PyPegen_expect_token(p, 8))
8222 )
8223 {
8224 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8225 if (token == NULL) {
8226 return NULL;
8227 }
8228 int end_lineno = token->end_lineno;
8229 UNUSED(end_lineno); // Only used by EXTRA macro
8230 int end_col_offset = token->end_col_offset;
8231 UNUSED(end_col_offset); // Only used by EXTRA macro
8232 res = _Py_Tuple ( a , Load , EXTRA );
8233 if (res == NULL && PyErr_Occurred()) {
8234 p->error_indicator = 1;
8235 return NULL;
8236 }
8237 goto done;
8238 }
8239 p->mark = mark;
8240 }
8241 res = NULL;
8242 done:
8243 return res;
8244}
8245
8246// group: '(' (yield_expr | named_expression) ')'
8247static expr_ty
8248group_rule(Parser *p)
8249{
8250 if (p->error_indicator) {
8251 return NULL;
8252 }
8253 expr_ty res = NULL;
8254 int mark = p->mark;
8255 { // '(' (yield_expr | named_expression) ')'
8256 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008257 Token * literal;
8258 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008259 if (
8260 (literal = _PyPegen_expect_token(p, 7))
8261 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07008262 (a = _tmp_101_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008263 &&
8264 (literal_1 = _PyPegen_expect_token(p, 8))
8265 )
8266 {
8267 res = a;
8268 if (res == NULL && PyErr_Occurred()) {
8269 p->error_indicator = 1;
8270 return NULL;
8271 }
8272 goto done;
8273 }
8274 p->mark = mark;
8275 }
8276 res = NULL;
8277 done:
8278 return res;
8279}
8280
8281// genexp: '(' expression for_if_clauses ')' | invalid_comprehension
8282static expr_ty
8283genexp_rule(Parser *p)
8284{
8285 if (p->error_indicator) {
8286 return NULL;
8287 }
8288 expr_ty res = NULL;
8289 int mark = p->mark;
8290 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8291 p->error_indicator = 1;
8292 return NULL;
8293 }
8294 int start_lineno = p->tokens[mark]->lineno;
8295 UNUSED(start_lineno); // Only used by EXTRA macro
8296 int start_col_offset = p->tokens[mark]->col_offset;
8297 UNUSED(start_col_offset); // Only used by EXTRA macro
8298 { // '(' expression for_if_clauses ')'
8299 expr_ty a;
8300 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008301 Token * literal;
8302 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008303 if (
8304 (literal = _PyPegen_expect_token(p, 7))
8305 &&
8306 (a = expression_rule(p))
8307 &&
8308 (b = for_if_clauses_rule(p))
8309 &&
8310 (literal_1 = _PyPegen_expect_token(p, 8))
8311 )
8312 {
8313 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8314 if (token == NULL) {
8315 return NULL;
8316 }
8317 int end_lineno = token->end_lineno;
8318 UNUSED(end_lineno); // Only used by EXTRA macro
8319 int end_col_offset = token->end_col_offset;
8320 UNUSED(end_col_offset); // Only used by EXTRA macro
8321 res = _Py_GeneratorExp ( a , b , EXTRA );
8322 if (res == NULL && PyErr_Occurred()) {
8323 p->error_indicator = 1;
8324 return NULL;
8325 }
8326 goto done;
8327 }
8328 p->mark = mark;
8329 }
8330 { // invalid_comprehension
8331 void *invalid_comprehension_var;
8332 if (
8333 (invalid_comprehension_var = invalid_comprehension_rule(p))
8334 )
8335 {
8336 res = invalid_comprehension_var;
8337 goto done;
8338 }
8339 p->mark = mark;
8340 }
8341 res = NULL;
8342 done:
8343 return res;
8344}
8345
8346// set: '{' expressions_list '}'
8347static expr_ty
8348set_rule(Parser *p)
8349{
8350 if (p->error_indicator) {
8351 return NULL;
8352 }
8353 expr_ty res = NULL;
8354 int mark = p->mark;
8355 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8356 p->error_indicator = 1;
8357 return NULL;
8358 }
8359 int start_lineno = p->tokens[mark]->lineno;
8360 UNUSED(start_lineno); // Only used by EXTRA macro
8361 int start_col_offset = p->tokens[mark]->col_offset;
8362 UNUSED(start_col_offset); // Only used by EXTRA macro
8363 { // '{' expressions_list '}'
8364 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008365 Token * literal;
8366 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008367 if (
8368 (literal = _PyPegen_expect_token(p, 25))
8369 &&
8370 (a = expressions_list_rule(p))
8371 &&
8372 (literal_1 = _PyPegen_expect_token(p, 26))
8373 )
8374 {
8375 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8376 if (token == NULL) {
8377 return NULL;
8378 }
8379 int end_lineno = token->end_lineno;
8380 UNUSED(end_lineno); // Only used by EXTRA macro
8381 int end_col_offset = token->end_col_offset;
8382 UNUSED(end_col_offset); // Only used by EXTRA macro
8383 res = _Py_Set ( a , EXTRA );
8384 if (res == NULL && PyErr_Occurred()) {
8385 p->error_indicator = 1;
8386 return NULL;
8387 }
8388 goto done;
8389 }
8390 p->mark = mark;
8391 }
8392 res = NULL;
8393 done:
8394 return res;
8395}
8396
8397// setcomp: '{' expression for_if_clauses '}' | invalid_comprehension
8398static expr_ty
8399setcomp_rule(Parser *p)
8400{
8401 if (p->error_indicator) {
8402 return NULL;
8403 }
8404 expr_ty res = NULL;
8405 int mark = p->mark;
8406 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8407 p->error_indicator = 1;
8408 return NULL;
8409 }
8410 int start_lineno = p->tokens[mark]->lineno;
8411 UNUSED(start_lineno); // Only used by EXTRA macro
8412 int start_col_offset = p->tokens[mark]->col_offset;
8413 UNUSED(start_col_offset); // Only used by EXTRA macro
8414 { // '{' expression for_if_clauses '}'
8415 expr_ty a;
8416 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008417 Token * literal;
8418 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008419 if (
8420 (literal = _PyPegen_expect_token(p, 25))
8421 &&
8422 (a = expression_rule(p))
8423 &&
8424 (b = for_if_clauses_rule(p))
8425 &&
8426 (literal_1 = _PyPegen_expect_token(p, 26))
8427 )
8428 {
8429 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8430 if (token == NULL) {
8431 return NULL;
8432 }
8433 int end_lineno = token->end_lineno;
8434 UNUSED(end_lineno); // Only used by EXTRA macro
8435 int end_col_offset = token->end_col_offset;
8436 UNUSED(end_col_offset); // Only used by EXTRA macro
8437 res = _Py_SetComp ( a , b , EXTRA );
8438 if (res == NULL && PyErr_Occurred()) {
8439 p->error_indicator = 1;
8440 return NULL;
8441 }
8442 goto done;
8443 }
8444 p->mark = mark;
8445 }
8446 { // invalid_comprehension
8447 void *invalid_comprehension_var;
8448 if (
8449 (invalid_comprehension_var = invalid_comprehension_rule(p))
8450 )
8451 {
8452 res = invalid_comprehension_var;
8453 goto done;
8454 }
8455 p->mark = mark;
8456 }
8457 res = NULL;
8458 done:
8459 return res;
8460}
8461
8462// dict: '{' kvpairs? '}'
8463static expr_ty
8464dict_rule(Parser *p)
8465{
8466 if (p->error_indicator) {
8467 return NULL;
8468 }
8469 expr_ty res = NULL;
8470 int mark = p->mark;
8471 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8472 p->error_indicator = 1;
8473 return NULL;
8474 }
8475 int start_lineno = p->tokens[mark]->lineno;
8476 UNUSED(start_lineno); // Only used by EXTRA macro
8477 int start_col_offset = p->tokens[mark]->col_offset;
8478 UNUSED(start_col_offset); // Only used by EXTRA macro
8479 { // '{' kvpairs? '}'
8480 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008481 Token * literal;
8482 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008483 if (
8484 (literal = _PyPegen_expect_token(p, 25))
8485 &&
8486 (a = kvpairs_rule(p), 1)
8487 &&
8488 (literal_1 = _PyPegen_expect_token(p, 26))
8489 )
8490 {
8491 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8492 if (token == NULL) {
8493 return NULL;
8494 }
8495 int end_lineno = token->end_lineno;
8496 UNUSED(end_lineno); // Only used by EXTRA macro
8497 int end_col_offset = token->end_col_offset;
8498 UNUSED(end_col_offset); // Only used by EXTRA macro
8499 res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA );
8500 if (res == NULL && PyErr_Occurred()) {
8501 p->error_indicator = 1;
8502 return NULL;
8503 }
8504 goto done;
8505 }
8506 p->mark = mark;
8507 }
8508 res = NULL;
8509 done:
8510 return res;
8511}
8512
8513// dictcomp: '{' kvpair for_if_clauses '}'
8514static expr_ty
8515dictcomp_rule(Parser *p)
8516{
8517 if (p->error_indicator) {
8518 return NULL;
8519 }
8520 expr_ty res = NULL;
8521 int mark = p->mark;
8522 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8523 p->error_indicator = 1;
8524 return NULL;
8525 }
8526 int start_lineno = p->tokens[mark]->lineno;
8527 UNUSED(start_lineno); // Only used by EXTRA macro
8528 int start_col_offset = p->tokens[mark]->col_offset;
8529 UNUSED(start_col_offset); // Only used by EXTRA macro
8530 { // '{' kvpair for_if_clauses '}'
8531 KeyValuePair* a;
8532 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008533 Token * literal;
8534 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008535 if (
8536 (literal = _PyPegen_expect_token(p, 25))
8537 &&
8538 (a = kvpair_rule(p))
8539 &&
8540 (b = for_if_clauses_rule(p))
8541 &&
8542 (literal_1 = _PyPegen_expect_token(p, 26))
8543 )
8544 {
8545 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8546 if (token == NULL) {
8547 return NULL;
8548 }
8549 int end_lineno = token->end_lineno;
8550 UNUSED(end_lineno); // Only used by EXTRA macro
8551 int end_col_offset = token->end_col_offset;
8552 UNUSED(end_col_offset); // Only used by EXTRA macro
8553 res = _Py_DictComp ( a -> key , a -> value , b , EXTRA );
8554 if (res == NULL && PyErr_Occurred()) {
8555 p->error_indicator = 1;
8556 return NULL;
8557 }
8558 goto done;
8559 }
8560 p->mark = mark;
8561 }
8562 res = NULL;
8563 done:
8564 return res;
8565}
8566
8567// kvpairs: ','.kvpair+ ','?
8568static asdl_seq*
8569kvpairs_rule(Parser *p)
8570{
8571 if (p->error_indicator) {
8572 return NULL;
8573 }
8574 asdl_seq* res = NULL;
8575 int mark = p->mark;
8576 { // ','.kvpair+ ','?
8577 asdl_seq * a;
8578 void *opt_var;
8579 UNUSED(opt_var); // Silence compiler warnings
8580 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07008581 (a = _gather_102_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008582 &&
8583 (opt_var = _PyPegen_expect_token(p, 12), 1)
8584 )
8585 {
8586 res = a;
8587 if (res == NULL && PyErr_Occurred()) {
8588 p->error_indicator = 1;
8589 return NULL;
8590 }
8591 goto done;
8592 }
8593 p->mark = mark;
8594 }
8595 res = NULL;
8596 done:
8597 return res;
8598}
8599
8600// kvpair: '**' bitwise_or | expression ':' expression
8601static KeyValuePair*
8602kvpair_rule(Parser *p)
8603{
8604 if (p->error_indicator) {
8605 return NULL;
8606 }
8607 KeyValuePair* res = NULL;
8608 int mark = p->mark;
8609 { // '**' bitwise_or
8610 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008611 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008612 if (
8613 (literal = _PyPegen_expect_token(p, 35))
8614 &&
8615 (a = bitwise_or_rule(p))
8616 )
8617 {
8618 res = _PyPegen_key_value_pair ( p , NULL , a );
8619 if (res == NULL && PyErr_Occurred()) {
8620 p->error_indicator = 1;
8621 return NULL;
8622 }
8623 goto done;
8624 }
8625 p->mark = mark;
8626 }
8627 { // expression ':' expression
8628 expr_ty a;
8629 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008630 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008631 if (
8632 (a = expression_rule(p))
8633 &&
8634 (literal = _PyPegen_expect_token(p, 11))
8635 &&
8636 (b = expression_rule(p))
8637 )
8638 {
8639 res = _PyPegen_key_value_pair ( p , a , b );
8640 if (res == NULL && PyErr_Occurred()) {
8641 p->error_indicator = 1;
8642 return NULL;
8643 }
8644 goto done;
8645 }
8646 p->mark = mark;
8647 }
8648 res = NULL;
8649 done:
8650 return res;
8651}
8652
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008653// for_if_clauses: for_if_clause+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008654static asdl_seq*
8655for_if_clauses_rule(Parser *p)
8656{
8657 if (p->error_indicator) {
8658 return NULL;
8659 }
8660 asdl_seq* res = NULL;
8661 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008662 { // for_if_clause+
Guido van Rossum3941d972020-05-01 09:42:03 -07008663 asdl_seq * _loop1_104_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008664 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07008665 (_loop1_104_var = _loop1_104_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008666 )
8667 {
Guido van Rossum3941d972020-05-01 09:42:03 -07008668 res = _loop1_104_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008669 goto done;
8670 }
8671 p->mark = mark;
8672 }
8673 res = NULL;
8674 done:
8675 return res;
8676}
8677
8678// for_if_clause:
8679// | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
8680// | 'for' star_targets 'in' disjunction (('if' disjunction))*
8681static comprehension_ty
8682for_if_clause_rule(Parser *p)
8683{
8684 if (p->error_indicator) {
8685 return NULL;
8686 }
8687 comprehension_ty res = NULL;
8688 int mark = p->mark;
8689 { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
8690 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008691 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008692 expr_ty b;
8693 asdl_seq * c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008694 Token * keyword;
8695 Token * keyword_1;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008696 if (
8697 (async_var = _PyPegen_expect_token(p, ASYNC))
8698 &&
8699 (keyword = _PyPegen_expect_token(p, 517))
8700 &&
8701 (a = star_targets_rule(p))
8702 &&
8703 (keyword_1 = _PyPegen_expect_token(p, 518))
8704 &&
8705 (b = disjunction_rule(p))
8706 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07008707 (c = _loop0_105_rule(p))
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008708 )
8709 {
8710 res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) );
8711 if (res == NULL && PyErr_Occurred()) {
8712 p->error_indicator = 1;
8713 return NULL;
8714 }
8715 goto done;
8716 }
8717 p->mark = mark;
8718 }
8719 { // 'for' star_targets 'in' disjunction (('if' disjunction))*
8720 expr_ty a;
8721 expr_ty b;
8722 asdl_seq * c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008723 Token * keyword;
8724 Token * keyword_1;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008725 if (
8726 (keyword = _PyPegen_expect_token(p, 517))
8727 &&
8728 (a = star_targets_rule(p))
8729 &&
8730 (keyword_1 = _PyPegen_expect_token(p, 518))
8731 &&
8732 (b = disjunction_rule(p))
8733 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07008734 (c = _loop0_106_rule(p))
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008735 )
8736 {
8737 res = _Py_comprehension ( a , b , c , 0 , p -> arena );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008738 if (res == NULL && PyErr_Occurred()) {
8739 p->error_indicator = 1;
8740 return NULL;
8741 }
8742 goto done;
8743 }
8744 p->mark = mark;
8745 }
8746 res = NULL;
8747 done:
8748 return res;
8749}
8750
8751// yield_expr: 'yield' 'from' expression | 'yield' star_expressions?
8752static expr_ty
8753yield_expr_rule(Parser *p)
8754{
8755 if (p->error_indicator) {
8756 return NULL;
8757 }
8758 expr_ty res = NULL;
8759 int mark = p->mark;
8760 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8761 p->error_indicator = 1;
8762 return NULL;
8763 }
8764 int start_lineno = p->tokens[mark]->lineno;
8765 UNUSED(start_lineno); // Only used by EXTRA macro
8766 int start_col_offset = p->tokens[mark]->col_offset;
8767 UNUSED(start_col_offset); // Only used by EXTRA macro
8768 { // 'yield' 'from' expression
8769 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008770 Token * keyword;
8771 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008772 if (
8773 (keyword = _PyPegen_expect_token(p, 504))
8774 &&
8775 (keyword_1 = _PyPegen_expect_token(p, 514))
8776 &&
8777 (a = expression_rule(p))
8778 )
8779 {
8780 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8781 if (token == NULL) {
8782 return NULL;
8783 }
8784 int end_lineno = token->end_lineno;
8785 UNUSED(end_lineno); // Only used by EXTRA macro
8786 int end_col_offset = token->end_col_offset;
8787 UNUSED(end_col_offset); // Only used by EXTRA macro
8788 res = _Py_YieldFrom ( a , EXTRA );
8789 if (res == NULL && PyErr_Occurred()) {
8790 p->error_indicator = 1;
8791 return NULL;
8792 }
8793 goto done;
8794 }
8795 p->mark = mark;
8796 }
8797 { // 'yield' star_expressions?
8798 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008799 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008800 if (
8801 (keyword = _PyPegen_expect_token(p, 504))
8802 &&
8803 (a = star_expressions_rule(p), 1)
8804 )
8805 {
8806 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8807 if (token == NULL) {
8808 return NULL;
8809 }
8810 int end_lineno = token->end_lineno;
8811 UNUSED(end_lineno); // Only used by EXTRA macro
8812 int end_col_offset = token->end_col_offset;
8813 UNUSED(end_col_offset); // Only used by EXTRA macro
8814 res = _Py_Yield ( a , EXTRA );
8815 if (res == NULL && PyErr_Occurred()) {
8816 p->error_indicator = 1;
8817 return NULL;
8818 }
8819 goto done;
8820 }
8821 p->mark = mark;
8822 }
8823 res = NULL;
8824 done:
8825 return res;
8826}
8827
8828// arguments: args ','? &')' | incorrect_arguments
8829static expr_ty
8830arguments_rule(Parser *p)
8831{
8832 if (p->error_indicator) {
8833 return NULL;
8834 }
8835 expr_ty res = NULL;
8836 if (_PyPegen_is_memoized(p, arguments_type, &res))
8837 return res;
8838 int mark = p->mark;
8839 { // args ','? &')'
8840 expr_ty a;
8841 void *opt_var;
8842 UNUSED(opt_var); // Silence compiler warnings
8843 if (
8844 (a = args_rule(p))
8845 &&
8846 (opt_var = _PyPegen_expect_token(p, 12), 1)
8847 &&
8848 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8)
8849 )
8850 {
8851 res = a;
8852 if (res == NULL && PyErr_Occurred()) {
8853 p->error_indicator = 1;
8854 return NULL;
8855 }
8856 goto done;
8857 }
8858 p->mark = mark;
8859 }
8860 { // incorrect_arguments
8861 void *incorrect_arguments_var;
8862 if (
8863 (incorrect_arguments_var = incorrect_arguments_rule(p))
8864 )
8865 {
8866 res = incorrect_arguments_var;
8867 goto done;
8868 }
8869 p->mark = mark;
8870 }
8871 res = NULL;
8872 done:
8873 _PyPegen_insert_memo(p, mark, arguments_type, res);
8874 return res;
8875}
8876
8877// args: starred_expression [',' args] | kwargs | named_expression [',' args]
8878static expr_ty
8879args_rule(Parser *p)
8880{
8881 if (p->error_indicator) {
8882 return NULL;
8883 }
8884 expr_ty res = NULL;
8885 int mark = p->mark;
8886 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8887 p->error_indicator = 1;
8888 return NULL;
8889 }
8890 int start_lineno = p->tokens[mark]->lineno;
8891 UNUSED(start_lineno); // Only used by EXTRA macro
8892 int start_col_offset = p->tokens[mark]->col_offset;
8893 UNUSED(start_col_offset); // Only used by EXTRA macro
8894 { // starred_expression [',' args]
8895 expr_ty a;
8896 void *b;
8897 if (
8898 (a = starred_expression_rule(p))
8899 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07008900 (b = _tmp_107_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008901 )
8902 {
8903 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8904 if (token == NULL) {
8905 return NULL;
8906 }
8907 int end_lineno = token->end_lineno;
8908 UNUSED(end_lineno); // Only used by EXTRA macro
8909 int end_col_offset = token->end_col_offset;
8910 UNUSED(end_col_offset); // Only used by EXTRA macro
8911 res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
8912 if (res == NULL && PyErr_Occurred()) {
8913 p->error_indicator = 1;
8914 return NULL;
8915 }
8916 goto done;
8917 }
8918 p->mark = mark;
8919 }
8920 { // kwargs
8921 asdl_seq* a;
8922 if (
8923 (a = kwargs_rule(p))
8924 )
8925 {
8926 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8927 if (token == NULL) {
8928 return NULL;
8929 }
8930 int end_lineno = token->end_lineno;
8931 UNUSED(end_lineno); // Only used by EXTRA macro
8932 int end_col_offset = token->end_col_offset;
8933 UNUSED(end_col_offset); // Only used by EXTRA macro
8934 res = _Py_Call ( _PyPegen_dummy_name ( p ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_extract_starred_exprs ( p , a ) ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_delete_starred_exprs ( p , a ) ) , EXTRA );
8935 if (res == NULL && PyErr_Occurred()) {
8936 p->error_indicator = 1;
8937 return NULL;
8938 }
8939 goto done;
8940 }
8941 p->mark = mark;
8942 }
8943 { // named_expression [',' args]
8944 expr_ty a;
8945 void *b;
8946 if (
8947 (a = named_expression_rule(p))
8948 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07008949 (b = _tmp_108_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008950 )
8951 {
8952 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8953 if (token == NULL) {
8954 return NULL;
8955 }
8956 int end_lineno = token->end_lineno;
8957 UNUSED(end_lineno); // Only used by EXTRA macro
8958 int end_col_offset = token->end_col_offset;
8959 UNUSED(end_col_offset); // Only used by EXTRA macro
8960 res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
8961 if (res == NULL && PyErr_Occurred()) {
8962 p->error_indicator = 1;
8963 return NULL;
8964 }
8965 goto done;
8966 }
8967 p->mark = mark;
8968 }
8969 res = NULL;
8970 done:
8971 return res;
8972}
8973
8974// kwargs:
8975// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
8976// | ','.kwarg_or_starred+
8977// | ','.kwarg_or_double_starred+
8978static asdl_seq*
8979kwargs_rule(Parser *p)
8980{
8981 if (p->error_indicator) {
8982 return NULL;
8983 }
8984 asdl_seq* res = NULL;
8985 int mark = p->mark;
8986 { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
8987 asdl_seq * a;
8988 asdl_seq * b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008989 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008990 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07008991 (a = _gather_109_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008992 &&
8993 (literal = _PyPegen_expect_token(p, 12))
8994 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07008995 (b = _gather_111_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008996 )
8997 {
8998 res = _PyPegen_join_sequences ( p , a , b );
8999 if (res == NULL && PyErr_Occurred()) {
9000 p->error_indicator = 1;
9001 return NULL;
9002 }
9003 goto done;
9004 }
9005 p->mark = mark;
9006 }
9007 { // ','.kwarg_or_starred+
Guido van Rossum3941d972020-05-01 09:42:03 -07009008 asdl_seq * _gather_113_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009009 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07009010 (_gather_113_var = _gather_113_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009011 )
9012 {
Guido van Rossum3941d972020-05-01 09:42:03 -07009013 res = _gather_113_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009014 goto done;
9015 }
9016 p->mark = mark;
9017 }
9018 { // ','.kwarg_or_double_starred+
Guido van Rossum3941d972020-05-01 09:42:03 -07009019 asdl_seq * _gather_115_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009020 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07009021 (_gather_115_var = _gather_115_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009022 )
9023 {
Guido van Rossum3941d972020-05-01 09:42:03 -07009024 res = _gather_115_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009025 goto done;
9026 }
9027 p->mark = mark;
9028 }
9029 res = NULL;
9030 done:
9031 return res;
9032}
9033
9034// starred_expression: '*' expression
9035static expr_ty
9036starred_expression_rule(Parser *p)
9037{
9038 if (p->error_indicator) {
9039 return NULL;
9040 }
9041 expr_ty res = NULL;
9042 int mark = p->mark;
9043 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9044 p->error_indicator = 1;
9045 return NULL;
9046 }
9047 int start_lineno = p->tokens[mark]->lineno;
9048 UNUSED(start_lineno); // Only used by EXTRA macro
9049 int start_col_offset = p->tokens[mark]->col_offset;
9050 UNUSED(start_col_offset); // Only used by EXTRA macro
9051 { // '*' expression
9052 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009053 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009054 if (
9055 (literal = _PyPegen_expect_token(p, 16))
9056 &&
9057 (a = expression_rule(p))
9058 )
9059 {
9060 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9061 if (token == NULL) {
9062 return NULL;
9063 }
9064 int end_lineno = token->end_lineno;
9065 UNUSED(end_lineno); // Only used by EXTRA macro
9066 int end_col_offset = token->end_col_offset;
9067 UNUSED(end_col_offset); // Only used by EXTRA macro
9068 res = _Py_Starred ( a , Load , EXTRA );
9069 if (res == NULL && PyErr_Occurred()) {
9070 p->error_indicator = 1;
9071 return NULL;
9072 }
9073 goto done;
9074 }
9075 p->mark = mark;
9076 }
9077 res = NULL;
9078 done:
9079 return res;
9080}
9081
9082// kwarg_or_starred: NAME '=' expression | starred_expression
9083static KeywordOrStarred*
9084kwarg_or_starred_rule(Parser *p)
9085{
9086 if (p->error_indicator) {
9087 return NULL;
9088 }
9089 KeywordOrStarred* res = NULL;
9090 int mark = p->mark;
9091 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9092 p->error_indicator = 1;
9093 return NULL;
9094 }
9095 int start_lineno = p->tokens[mark]->lineno;
9096 UNUSED(start_lineno); // Only used by EXTRA macro
9097 int start_col_offset = p->tokens[mark]->col_offset;
9098 UNUSED(start_col_offset); // Only used by EXTRA macro
9099 { // NAME '=' expression
9100 expr_ty a;
9101 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009102 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009103 if (
9104 (a = _PyPegen_name_token(p))
9105 &&
9106 (literal = _PyPegen_expect_token(p, 22))
9107 &&
9108 (b = expression_rule(p))
9109 )
9110 {
9111 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9112 if (token == NULL) {
9113 return NULL;
9114 }
9115 int end_lineno = token->end_lineno;
9116 UNUSED(end_lineno); // Only used by EXTRA macro
9117 int end_col_offset = token->end_col_offset;
9118 UNUSED(end_col_offset); // Only used by EXTRA macro
9119 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
9120 if (res == NULL && PyErr_Occurred()) {
9121 p->error_indicator = 1;
9122 return NULL;
9123 }
9124 goto done;
9125 }
9126 p->mark = mark;
9127 }
9128 { // starred_expression
9129 expr_ty a;
9130 if (
9131 (a = starred_expression_rule(p))
9132 )
9133 {
9134 res = _PyPegen_keyword_or_starred ( p , a , 0 );
9135 if (res == NULL && PyErr_Occurred()) {
9136 p->error_indicator = 1;
9137 return NULL;
9138 }
9139 goto done;
9140 }
9141 p->mark = mark;
9142 }
9143 res = NULL;
9144 done:
9145 return res;
9146}
9147
9148// kwarg_or_double_starred: NAME '=' expression | '**' expression
9149static KeywordOrStarred*
9150kwarg_or_double_starred_rule(Parser *p)
9151{
9152 if (p->error_indicator) {
9153 return NULL;
9154 }
9155 KeywordOrStarred* res = NULL;
9156 int mark = p->mark;
9157 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9158 p->error_indicator = 1;
9159 return NULL;
9160 }
9161 int start_lineno = p->tokens[mark]->lineno;
9162 UNUSED(start_lineno); // Only used by EXTRA macro
9163 int start_col_offset = p->tokens[mark]->col_offset;
9164 UNUSED(start_col_offset); // Only used by EXTRA macro
9165 { // NAME '=' expression
9166 expr_ty a;
9167 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009168 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009169 if (
9170 (a = _PyPegen_name_token(p))
9171 &&
9172 (literal = _PyPegen_expect_token(p, 22))
9173 &&
9174 (b = expression_rule(p))
9175 )
9176 {
9177 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9178 if (token == NULL) {
9179 return NULL;
9180 }
9181 int end_lineno = token->end_lineno;
9182 UNUSED(end_lineno); // Only used by EXTRA macro
9183 int end_col_offset = token->end_col_offset;
9184 UNUSED(end_col_offset); // Only used by EXTRA macro
9185 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
9186 if (res == NULL && PyErr_Occurred()) {
9187 p->error_indicator = 1;
9188 return NULL;
9189 }
9190 goto done;
9191 }
9192 p->mark = mark;
9193 }
9194 { // '**' expression
9195 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009196 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009197 if (
9198 (literal = _PyPegen_expect_token(p, 35))
9199 &&
9200 (a = expression_rule(p))
9201 )
9202 {
9203 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9204 if (token == NULL) {
9205 return NULL;
9206 }
9207 int end_lineno = token->end_lineno;
9208 UNUSED(end_lineno); // Only used by EXTRA macro
9209 int end_col_offset = token->end_col_offset;
9210 UNUSED(end_col_offset); // Only used by EXTRA macro
9211 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 );
9212 if (res == NULL && PyErr_Occurred()) {
9213 p->error_indicator = 1;
9214 return NULL;
9215 }
9216 goto done;
9217 }
9218 p->mark = mark;
9219 }
9220 res = NULL;
9221 done:
9222 return res;
9223}
9224
9225// star_targets: star_target !',' | star_target ((',' star_target))* ','?
9226static expr_ty
9227star_targets_rule(Parser *p)
9228{
9229 if (p->error_indicator) {
9230 return NULL;
9231 }
9232 expr_ty res = NULL;
9233 int mark = p->mark;
9234 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9235 p->error_indicator = 1;
9236 return NULL;
9237 }
9238 int start_lineno = p->tokens[mark]->lineno;
9239 UNUSED(start_lineno); // Only used by EXTRA macro
9240 int start_col_offset = p->tokens[mark]->col_offset;
9241 UNUSED(start_col_offset); // Only used by EXTRA macro
9242 { // star_target !','
9243 expr_ty a;
9244 if (
9245 (a = star_target_rule(p))
9246 &&
9247 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12)
9248 )
9249 {
9250 res = a;
9251 if (res == NULL && PyErr_Occurred()) {
9252 p->error_indicator = 1;
9253 return NULL;
9254 }
9255 goto done;
9256 }
9257 p->mark = mark;
9258 }
9259 { // star_target ((',' star_target))* ','?
9260 expr_ty a;
9261 asdl_seq * b;
9262 void *opt_var;
9263 UNUSED(opt_var); // Silence compiler warnings
9264 if (
9265 (a = star_target_rule(p))
9266 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07009267 (b = _loop0_117_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009268 &&
9269 (opt_var = _PyPegen_expect_token(p, 12), 1)
9270 )
9271 {
9272 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9273 if (token == NULL) {
9274 return NULL;
9275 }
9276 int end_lineno = token->end_lineno;
9277 UNUSED(end_lineno); // Only used by EXTRA macro
9278 int end_col_offset = token->end_col_offset;
9279 UNUSED(end_col_offset); // Only used by EXTRA macro
9280 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA );
9281 if (res == NULL && PyErr_Occurred()) {
9282 p->error_indicator = 1;
9283 return NULL;
9284 }
9285 goto done;
9286 }
9287 p->mark = mark;
9288 }
9289 res = NULL;
9290 done:
9291 return res;
9292}
9293
9294// star_targets_seq: ','.star_target+ ','?
9295static asdl_seq*
9296star_targets_seq_rule(Parser *p)
9297{
9298 if (p->error_indicator) {
9299 return NULL;
9300 }
9301 asdl_seq* res = NULL;
9302 int mark = p->mark;
9303 { // ','.star_target+ ','?
9304 asdl_seq * a;
9305 void *opt_var;
9306 UNUSED(opt_var); // Silence compiler warnings
9307 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07009308 (a = _gather_118_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009309 &&
9310 (opt_var = _PyPegen_expect_token(p, 12), 1)
9311 )
9312 {
9313 res = a;
9314 if (res == NULL && PyErr_Occurred()) {
9315 p->error_indicator = 1;
9316 return NULL;
9317 }
9318 goto done;
9319 }
9320 p->mark = mark;
9321 }
9322 res = NULL;
9323 done:
9324 return res;
9325}
9326
9327// star_target:
9328// | '*' (!'*' star_target)
9329// | t_primary '.' NAME !t_lookahead
9330// | t_primary '[' slices ']' !t_lookahead
9331// | star_atom
9332static expr_ty
9333star_target_rule(Parser *p)
9334{
9335 if (p->error_indicator) {
9336 return NULL;
9337 }
9338 expr_ty res = NULL;
9339 if (_PyPegen_is_memoized(p, star_target_type, &res))
9340 return res;
9341 int mark = p->mark;
9342 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9343 p->error_indicator = 1;
9344 return NULL;
9345 }
9346 int start_lineno = p->tokens[mark]->lineno;
9347 UNUSED(start_lineno); // Only used by EXTRA macro
9348 int start_col_offset = p->tokens[mark]->col_offset;
9349 UNUSED(start_col_offset); // Only used by EXTRA macro
9350 { // '*' (!'*' star_target)
9351 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009352 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009353 if (
9354 (literal = _PyPegen_expect_token(p, 16))
9355 &&
Guido van Rossum3941d972020-05-01 09:42:03 -07009356 (a = _tmp_120_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009357 )
9358 {
9359 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9360 if (token == NULL) {
9361 return NULL;
9362 }
9363 int end_lineno = token->end_lineno;
9364 UNUSED(end_lineno); // Only used by EXTRA macro
9365 int end_col_offset = token->end_col_offset;
9366 UNUSED(end_col_offset); // Only used by EXTRA macro
9367 res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA );
9368 if (res == NULL && PyErr_Occurred()) {
9369 p->error_indicator = 1;
9370 return NULL;
9371 }
9372 goto done;
9373 }
9374 p->mark = mark;
9375 }
9376 { // t_primary '.' NAME !t_lookahead
9377 expr_ty a;
9378 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009379 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009380 if (
9381 (a = t_primary_rule(p))
9382 &&
9383 (literal = _PyPegen_expect_token(p, 23))
9384 &&
9385 (b = _PyPegen_name_token(p))
9386 &&
9387 _PyPegen_lookahead(0, t_lookahead_rule, p)
9388 )
9389 {
9390 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9391 if (token == NULL) {
9392 return NULL;
9393 }
9394 int end_lineno = token->end_lineno;
9395 UNUSED(end_lineno); // Only used by EXTRA macro
9396 int end_col_offset = token->end_col_offset;
9397 UNUSED(end_col_offset); // Only used by EXTRA macro
9398 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
9399 if (res == NULL && PyErr_Occurred()) {
9400 p->error_indicator = 1;
9401 return NULL;
9402 }
9403 goto done;
9404 }
9405 p->mark = mark;
9406 }
9407 { // t_primary '[' slices ']' !t_lookahead
9408 expr_ty a;
9409 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009410 Token * literal;
9411 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009412 if (
9413 (a = t_primary_rule(p))
9414 &&
9415 (literal = _PyPegen_expect_token(p, 9))
9416 &&
9417 (b = slices_rule(p))
9418 &&
9419 (literal_1 = _PyPegen_expect_token(p, 10))
9420 &&
9421 _PyPegen_lookahead(0, t_lookahead_rule, p)
9422 )
9423 {
9424 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9425 if (token == NULL) {
9426 return NULL;
9427 }
9428 int end_lineno = token->end_lineno;
9429 UNUSED(end_lineno); // Only used by EXTRA macro
9430 int end_col_offset = token->end_col_offset;
9431 UNUSED(end_col_offset); // Only used by EXTRA macro
9432 res = _Py_Subscript ( a , b , Store , EXTRA );
9433 if (res == NULL && PyErr_Occurred()) {
9434 p->error_indicator = 1;
9435 return NULL;
9436 }
9437 goto done;
9438 }
9439 p->mark = mark;
9440 }
9441 { // star_atom
9442 expr_ty star_atom_var;
9443 if (
9444 (star_atom_var = star_atom_rule(p))
9445 )
9446 {
9447 res = star_atom_var;
9448 goto done;
9449 }
9450 p->mark = mark;
9451 }
9452 res = NULL;
9453 done:
9454 _PyPegen_insert_memo(p, mark, star_target_type, res);
9455 return res;
9456}
9457
9458// star_atom:
9459// | NAME
9460// | '(' star_target ')'
9461// | '(' star_targets_seq? ')'
9462// | '[' star_targets_seq? ']'
9463static expr_ty
9464star_atom_rule(Parser *p)
9465{
9466 if (p->error_indicator) {
9467 return NULL;
9468 }
9469 expr_ty res = NULL;
9470 int mark = p->mark;
9471 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9472 p->error_indicator = 1;
9473 return NULL;
9474 }
9475 int start_lineno = p->tokens[mark]->lineno;
9476 UNUSED(start_lineno); // Only used by EXTRA macro
9477 int start_col_offset = p->tokens[mark]->col_offset;
9478 UNUSED(start_col_offset); // Only used by EXTRA macro
9479 { // NAME
9480 expr_ty a;
9481 if (
9482 (a = _PyPegen_name_token(p))
9483 )
9484 {
9485 res = _PyPegen_set_expr_context ( p , a , Store );
9486 if (res == NULL && PyErr_Occurred()) {
9487 p->error_indicator = 1;
9488 return NULL;
9489 }
9490 goto done;
9491 }
9492 p->mark = mark;
9493 }
9494 { // '(' star_target ')'
9495 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009496 Token * literal;
9497 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009498 if (
9499 (literal = _PyPegen_expect_token(p, 7))
9500 &&
9501 (a = star_target_rule(p))
9502 &&
9503 (literal_1 = _PyPegen_expect_token(p, 8))
9504 )
9505 {
9506 res = _PyPegen_set_expr_context ( p , a , Store );
9507 if (res == NULL && PyErr_Occurred()) {
9508 p->error_indicator = 1;
9509 return NULL;
9510 }
9511 goto done;
9512 }
9513 p->mark = mark;
9514 }
9515 { // '(' star_targets_seq? ')'
9516 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009517 Token * literal;
9518 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009519 if (
9520 (literal = _PyPegen_expect_token(p, 7))
9521 &&
9522 (a = star_targets_seq_rule(p), 1)
9523 &&
9524 (literal_1 = _PyPegen_expect_token(p, 8))
9525 )
9526 {
9527 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9528 if (token == NULL) {
9529 return NULL;
9530 }
9531 int end_lineno = token->end_lineno;
9532 UNUSED(end_lineno); // Only used by EXTRA macro
9533 int end_col_offset = token->end_col_offset;
9534 UNUSED(end_col_offset); // Only used by EXTRA macro
9535 res = _Py_Tuple ( a , Store , EXTRA );
9536 if (res == NULL && PyErr_Occurred()) {
9537 p->error_indicator = 1;
9538 return NULL;
9539 }
9540 goto done;
9541 }
9542 p->mark = mark;
9543 }
9544 { // '[' star_targets_seq? ']'
9545 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009546 Token * literal;
9547 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009548 if (
9549 (literal = _PyPegen_expect_token(p, 9))
9550 &&
9551 (a = star_targets_seq_rule(p), 1)
9552 &&
9553 (literal_1 = _PyPegen_expect_token(p, 10))
9554 )
9555 {
9556 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9557 if (token == NULL) {
9558 return NULL;
9559 }
9560 int end_lineno = token->end_lineno;
9561 UNUSED(end_lineno); // Only used by EXTRA macro
9562 int end_col_offset = token->end_col_offset;
9563 UNUSED(end_col_offset); // Only used by EXTRA macro
9564 res = _Py_List ( a , Store , EXTRA );
9565 if (res == NULL && PyErr_Occurred()) {
9566 p->error_indicator = 1;
9567 return NULL;
9568 }
9569 goto done;
9570 }
9571 p->mark = mark;
9572 }
9573 res = NULL;
9574 done:
9575 return res;
9576}
9577
9578// inside_paren_ann_assign_target:
9579// | ann_assign_subscript_attribute_target
9580// | NAME
9581// | '(' inside_paren_ann_assign_target ')'
9582static expr_ty
9583inside_paren_ann_assign_target_rule(Parser *p)
9584{
9585 if (p->error_indicator) {
9586 return NULL;
9587 }
9588 expr_ty res = NULL;
9589 int mark = p->mark;
9590 { // ann_assign_subscript_attribute_target
9591 expr_ty ann_assign_subscript_attribute_target_var;
9592 if (
9593 (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p))
9594 )
9595 {
9596 res = ann_assign_subscript_attribute_target_var;
9597 goto done;
9598 }
9599 p->mark = mark;
9600 }
9601 { // NAME
9602 expr_ty a;
9603 if (
9604 (a = _PyPegen_name_token(p))
9605 )
9606 {
9607 res = _PyPegen_set_expr_context ( p , a , Store );
9608 if (res == NULL && PyErr_Occurred()) {
9609 p->error_indicator = 1;
9610 return NULL;
9611 }
9612 goto done;
9613 }
9614 p->mark = mark;
9615 }
9616 { // '(' inside_paren_ann_assign_target ')'
9617 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009618 Token * literal;
9619 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009620 if (
9621 (literal = _PyPegen_expect_token(p, 7))
9622 &&
9623 (a = inside_paren_ann_assign_target_rule(p))
9624 &&
9625 (literal_1 = _PyPegen_expect_token(p, 8))
9626 )
9627 {
9628 res = a;
9629 if (res == NULL && PyErr_Occurred()) {
9630 p->error_indicator = 1;
9631 return NULL;
9632 }
9633 goto done;
9634 }
9635 p->mark = mark;
9636 }
9637 res = NULL;
9638 done:
9639 return res;
9640}
9641
9642// ann_assign_subscript_attribute_target:
9643// | t_primary '.' NAME !t_lookahead
9644// | t_primary '[' slices ']' !t_lookahead
9645static expr_ty
9646ann_assign_subscript_attribute_target_rule(Parser *p)
9647{
9648 if (p->error_indicator) {
9649 return NULL;
9650 }
9651 expr_ty res = NULL;
9652 int mark = p->mark;
9653 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9654 p->error_indicator = 1;
9655 return NULL;
9656 }
9657 int start_lineno = p->tokens[mark]->lineno;
9658 UNUSED(start_lineno); // Only used by EXTRA macro
9659 int start_col_offset = p->tokens[mark]->col_offset;
9660 UNUSED(start_col_offset); // Only used by EXTRA macro
9661 { // t_primary '.' NAME !t_lookahead
9662 expr_ty a;
9663 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009664 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009665 if (
9666 (a = t_primary_rule(p))
9667 &&
9668 (literal = _PyPegen_expect_token(p, 23))
9669 &&
9670 (b = _PyPegen_name_token(p))
9671 &&
9672 _PyPegen_lookahead(0, t_lookahead_rule, p)
9673 )
9674 {
9675 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9676 if (token == NULL) {
9677 return NULL;
9678 }
9679 int end_lineno = token->end_lineno;
9680 UNUSED(end_lineno); // Only used by EXTRA macro
9681 int end_col_offset = token->end_col_offset;
9682 UNUSED(end_col_offset); // Only used by EXTRA macro
9683 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
9684 if (res == NULL && PyErr_Occurred()) {
9685 p->error_indicator = 1;
9686 return NULL;
9687 }
9688 goto done;
9689 }
9690 p->mark = mark;
9691 }
9692 { // t_primary '[' slices ']' !t_lookahead
9693 expr_ty a;
9694 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009695 Token * literal;
9696 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009697 if (
9698 (a = t_primary_rule(p))
9699 &&
9700 (literal = _PyPegen_expect_token(p, 9))
9701 &&
9702 (b = slices_rule(p))
9703 &&
9704 (literal_1 = _PyPegen_expect_token(p, 10))
9705 &&
9706 _PyPegen_lookahead(0, t_lookahead_rule, p)
9707 )
9708 {
9709 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9710 if (token == NULL) {
9711 return NULL;
9712 }
9713 int end_lineno = token->end_lineno;
9714 UNUSED(end_lineno); // Only used by EXTRA macro
9715 int end_col_offset = token->end_col_offset;
9716 UNUSED(end_col_offset); // Only used by EXTRA macro
9717 res = _Py_Subscript ( a , b , Store , EXTRA );
9718 if (res == NULL && PyErr_Occurred()) {
9719 p->error_indicator = 1;
9720 return NULL;
9721 }
9722 goto done;
9723 }
9724 p->mark = mark;
9725 }
9726 res = NULL;
9727 done:
9728 return res;
9729}
9730
9731// del_targets: ','.del_target+ ','?
9732static asdl_seq*
9733del_targets_rule(Parser *p)
9734{
9735 if (p->error_indicator) {
9736 return NULL;
9737 }
9738 asdl_seq* res = NULL;
9739 int mark = p->mark;
9740 { // ','.del_target+ ','?
9741 asdl_seq * a;
9742 void *opt_var;
9743 UNUSED(opt_var); // Silence compiler warnings
9744 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07009745 (a = _gather_121_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009746 &&
9747 (opt_var = _PyPegen_expect_token(p, 12), 1)
9748 )
9749 {
9750 res = a;
9751 if (res == NULL && PyErr_Occurred()) {
9752 p->error_indicator = 1;
9753 return NULL;
9754 }
9755 goto done;
9756 }
9757 p->mark = mark;
9758 }
9759 res = NULL;
9760 done:
9761 return res;
9762}
9763
9764// del_target:
9765// | t_primary '.' NAME !t_lookahead
9766// | t_primary '[' slices ']' !t_lookahead
9767// | del_t_atom
9768static expr_ty
9769del_target_rule(Parser *p)
9770{
9771 if (p->error_indicator) {
9772 return NULL;
9773 }
9774 expr_ty res = NULL;
9775 if (_PyPegen_is_memoized(p, del_target_type, &res))
9776 return res;
9777 int mark = p->mark;
9778 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9779 p->error_indicator = 1;
9780 return NULL;
9781 }
9782 int start_lineno = p->tokens[mark]->lineno;
9783 UNUSED(start_lineno); // Only used by EXTRA macro
9784 int start_col_offset = p->tokens[mark]->col_offset;
9785 UNUSED(start_col_offset); // Only used by EXTRA macro
9786 { // t_primary '.' NAME !t_lookahead
9787 expr_ty a;
9788 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009789 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009790 if (
9791 (a = t_primary_rule(p))
9792 &&
9793 (literal = _PyPegen_expect_token(p, 23))
9794 &&
9795 (b = _PyPegen_name_token(p))
9796 &&
9797 _PyPegen_lookahead(0, t_lookahead_rule, p)
9798 )
9799 {
9800 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9801 if (token == NULL) {
9802 return NULL;
9803 }
9804 int end_lineno = token->end_lineno;
9805 UNUSED(end_lineno); // Only used by EXTRA macro
9806 int end_col_offset = token->end_col_offset;
9807 UNUSED(end_col_offset); // Only used by EXTRA macro
9808 res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA );
9809 if (res == NULL && PyErr_Occurred()) {
9810 p->error_indicator = 1;
9811 return NULL;
9812 }
9813 goto done;
9814 }
9815 p->mark = mark;
9816 }
9817 { // t_primary '[' slices ']' !t_lookahead
9818 expr_ty a;
9819 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009820 Token * literal;
9821 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009822 if (
9823 (a = t_primary_rule(p))
9824 &&
9825 (literal = _PyPegen_expect_token(p, 9))
9826 &&
9827 (b = slices_rule(p))
9828 &&
9829 (literal_1 = _PyPegen_expect_token(p, 10))
9830 &&
9831 _PyPegen_lookahead(0, t_lookahead_rule, p)
9832 )
9833 {
9834 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9835 if (token == NULL) {
9836 return NULL;
9837 }
9838 int end_lineno = token->end_lineno;
9839 UNUSED(end_lineno); // Only used by EXTRA macro
9840 int end_col_offset = token->end_col_offset;
9841 UNUSED(end_col_offset); // Only used by EXTRA macro
9842 res = _Py_Subscript ( a , b , Del , EXTRA );
9843 if (res == NULL && PyErr_Occurred()) {
9844 p->error_indicator = 1;
9845 return NULL;
9846 }
9847 goto done;
9848 }
9849 p->mark = mark;
9850 }
9851 { // del_t_atom
9852 expr_ty del_t_atom_var;
9853 if (
9854 (del_t_atom_var = del_t_atom_rule(p))
9855 )
9856 {
9857 res = del_t_atom_var;
9858 goto done;
9859 }
9860 p->mark = mark;
9861 }
9862 res = NULL;
9863 done:
9864 _PyPegen_insert_memo(p, mark, del_target_type, res);
9865 return res;
9866}
9867
9868// del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']'
9869static expr_ty
9870del_t_atom_rule(Parser *p)
9871{
9872 if (p->error_indicator) {
9873 return NULL;
9874 }
9875 expr_ty res = NULL;
9876 int mark = p->mark;
9877 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9878 p->error_indicator = 1;
9879 return NULL;
9880 }
9881 int start_lineno = p->tokens[mark]->lineno;
9882 UNUSED(start_lineno); // Only used by EXTRA macro
9883 int start_col_offset = p->tokens[mark]->col_offset;
9884 UNUSED(start_col_offset); // Only used by EXTRA macro
9885 { // NAME
9886 expr_ty a;
9887 if (
9888 (a = _PyPegen_name_token(p))
9889 )
9890 {
9891 res = _PyPegen_set_expr_context ( p , a , Del );
9892 if (res == NULL && PyErr_Occurred()) {
9893 p->error_indicator = 1;
9894 return NULL;
9895 }
9896 goto done;
9897 }
9898 p->mark = mark;
9899 }
9900 { // '(' del_target ')'
9901 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009902 Token * literal;
9903 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009904 if (
9905 (literal = _PyPegen_expect_token(p, 7))
9906 &&
9907 (a = del_target_rule(p))
9908 &&
9909 (literal_1 = _PyPegen_expect_token(p, 8))
9910 )
9911 {
9912 res = _PyPegen_set_expr_context ( p , a , Del );
9913 if (res == NULL && PyErr_Occurred()) {
9914 p->error_indicator = 1;
9915 return NULL;
9916 }
9917 goto done;
9918 }
9919 p->mark = mark;
9920 }
9921 { // '(' del_targets? ')'
9922 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009923 Token * literal;
9924 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009925 if (
9926 (literal = _PyPegen_expect_token(p, 7))
9927 &&
9928 (a = del_targets_rule(p), 1)
9929 &&
9930 (literal_1 = _PyPegen_expect_token(p, 8))
9931 )
9932 {
9933 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9934 if (token == NULL) {
9935 return NULL;
9936 }
9937 int end_lineno = token->end_lineno;
9938 UNUSED(end_lineno); // Only used by EXTRA macro
9939 int end_col_offset = token->end_col_offset;
9940 UNUSED(end_col_offset); // Only used by EXTRA macro
9941 res = _Py_Tuple ( a , Del , EXTRA );
9942 if (res == NULL && PyErr_Occurred()) {
9943 p->error_indicator = 1;
9944 return NULL;
9945 }
9946 goto done;
9947 }
9948 p->mark = mark;
9949 }
9950 { // '[' del_targets? ']'
9951 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009952 Token * literal;
9953 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009954 if (
9955 (literal = _PyPegen_expect_token(p, 9))
9956 &&
9957 (a = del_targets_rule(p), 1)
9958 &&
9959 (literal_1 = _PyPegen_expect_token(p, 10))
9960 )
9961 {
9962 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9963 if (token == NULL) {
9964 return NULL;
9965 }
9966 int end_lineno = token->end_lineno;
9967 UNUSED(end_lineno); // Only used by EXTRA macro
9968 int end_col_offset = token->end_col_offset;
9969 UNUSED(end_col_offset); // Only used by EXTRA macro
9970 res = _Py_List ( a , Del , EXTRA );
9971 if (res == NULL && PyErr_Occurred()) {
9972 p->error_indicator = 1;
9973 return NULL;
9974 }
9975 goto done;
9976 }
9977 p->mark = mark;
9978 }
9979 res = NULL;
9980 done:
9981 return res;
9982}
9983
9984// targets: ','.target+ ','?
9985static asdl_seq*
9986targets_rule(Parser *p)
9987{
9988 if (p->error_indicator) {
9989 return NULL;
9990 }
9991 asdl_seq* res = NULL;
9992 int mark = p->mark;
9993 { // ','.target+ ','?
9994 asdl_seq * a;
9995 void *opt_var;
9996 UNUSED(opt_var); // Silence compiler warnings
9997 if (
Guido van Rossum3941d972020-05-01 09:42:03 -07009998 (a = _gather_123_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009999 &&
10000 (opt_var = _PyPegen_expect_token(p, 12), 1)
10001 )
10002 {
10003 res = a;
10004 if (res == NULL && PyErr_Occurred()) {
10005 p->error_indicator = 1;
10006 return NULL;
10007 }
10008 goto done;
10009 }
10010 p->mark = mark;
10011 }
10012 res = NULL;
10013 done:
10014 return res;
10015}
10016
10017// target:
10018// | t_primary '.' NAME !t_lookahead
10019// | t_primary '[' slices ']' !t_lookahead
10020// | t_atom
10021static expr_ty
10022target_rule(Parser *p)
10023{
10024 if (p->error_indicator) {
10025 return NULL;
10026 }
10027 expr_ty res = NULL;
10028 if (_PyPegen_is_memoized(p, target_type, &res))
10029 return res;
10030 int mark = p->mark;
10031 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
10032 p->error_indicator = 1;
10033 return NULL;
10034 }
10035 int start_lineno = p->tokens[mark]->lineno;
10036 UNUSED(start_lineno); // Only used by EXTRA macro
10037 int start_col_offset = p->tokens[mark]->col_offset;
10038 UNUSED(start_col_offset); // Only used by EXTRA macro
10039 { // t_primary '.' NAME !t_lookahead
10040 expr_ty a;
10041 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010042 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010043 if (
10044 (a = t_primary_rule(p))
10045 &&
10046 (literal = _PyPegen_expect_token(p, 23))
10047 &&
10048 (b = _PyPegen_name_token(p))
10049 &&
10050 _PyPegen_lookahead(0, t_lookahead_rule, p)
10051 )
10052 {
10053 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10054 if (token == NULL) {
10055 return NULL;
10056 }
10057 int end_lineno = token->end_lineno;
10058 UNUSED(end_lineno); // Only used by EXTRA macro
10059 int end_col_offset = token->end_col_offset;
10060 UNUSED(end_col_offset); // Only used by EXTRA macro
10061 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
10062 if (res == NULL && PyErr_Occurred()) {
10063 p->error_indicator = 1;
10064 return NULL;
10065 }
10066 goto done;
10067 }
10068 p->mark = mark;
10069 }
10070 { // t_primary '[' slices ']' !t_lookahead
10071 expr_ty a;
10072 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010073 Token * literal;
10074 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010075 if (
10076 (a = t_primary_rule(p))
10077 &&
10078 (literal = _PyPegen_expect_token(p, 9))
10079 &&
10080 (b = slices_rule(p))
10081 &&
10082 (literal_1 = _PyPegen_expect_token(p, 10))
10083 &&
10084 _PyPegen_lookahead(0, t_lookahead_rule, p)
10085 )
10086 {
10087 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10088 if (token == NULL) {
10089 return NULL;
10090 }
10091 int end_lineno = token->end_lineno;
10092 UNUSED(end_lineno); // Only used by EXTRA macro
10093 int end_col_offset = token->end_col_offset;
10094 UNUSED(end_col_offset); // Only used by EXTRA macro
10095 res = _Py_Subscript ( a , b , Store , EXTRA );
10096 if (res == NULL && PyErr_Occurred()) {
10097 p->error_indicator = 1;
10098 return NULL;
10099 }
10100 goto done;
10101 }
10102 p->mark = mark;
10103 }
10104 { // t_atom
10105 expr_ty t_atom_var;
10106 if (
10107 (t_atom_var = t_atom_rule(p))
10108 )
10109 {
10110 res = t_atom_var;
10111 goto done;
10112 }
10113 p->mark = mark;
10114 }
10115 res = NULL;
10116 done:
10117 _PyPegen_insert_memo(p, mark, target_type, res);
10118 return res;
10119}
10120
10121// Left-recursive
10122// t_primary:
10123// | t_primary '.' NAME &t_lookahead
10124// | t_primary '[' slices ']' &t_lookahead
10125// | t_primary genexp &t_lookahead
10126// | t_primary '(' arguments? ')' &t_lookahead
10127// | atom &t_lookahead
10128static expr_ty t_primary_raw(Parser *);
10129static expr_ty
10130t_primary_rule(Parser *p)
10131{
10132 expr_ty res = NULL;
10133 if (_PyPegen_is_memoized(p, t_primary_type, &res))
10134 return res;
10135 int mark = p->mark;
10136 int resmark = p->mark;
10137 while (1) {
10138 int tmpvar_8 = _PyPegen_update_memo(p, mark, t_primary_type, res);
10139 if (tmpvar_8) {
10140 return res;
10141 }
10142 p->mark = mark;
10143 void *raw = t_primary_raw(p);
10144 if (raw == NULL || p->mark <= resmark)
10145 break;
10146 resmark = p->mark;
10147 res = raw;
10148 }
10149 p->mark = resmark;
10150 return res;
10151}
10152static expr_ty
10153t_primary_raw(Parser *p)
10154{
10155 if (p->error_indicator) {
10156 return NULL;
10157 }
10158 expr_ty res = NULL;
10159 int mark = p->mark;
10160 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
10161 p->error_indicator = 1;
10162 return NULL;
10163 }
10164 int start_lineno = p->tokens[mark]->lineno;
10165 UNUSED(start_lineno); // Only used by EXTRA macro
10166 int start_col_offset = p->tokens[mark]->col_offset;
10167 UNUSED(start_col_offset); // Only used by EXTRA macro
10168 { // t_primary '.' NAME &t_lookahead
10169 expr_ty a;
10170 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010171 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010172 if (
10173 (a = t_primary_rule(p))
10174 &&
10175 (literal = _PyPegen_expect_token(p, 23))
10176 &&
10177 (b = _PyPegen_name_token(p))
10178 &&
10179 _PyPegen_lookahead(1, t_lookahead_rule, p)
10180 )
10181 {
10182 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10183 if (token == NULL) {
10184 return NULL;
10185 }
10186 int end_lineno = token->end_lineno;
10187 UNUSED(end_lineno); // Only used by EXTRA macro
10188 int end_col_offset = token->end_col_offset;
10189 UNUSED(end_col_offset); // Only used by EXTRA macro
10190 res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
10191 if (res == NULL && PyErr_Occurred()) {
10192 p->error_indicator = 1;
10193 return NULL;
10194 }
10195 goto done;
10196 }
10197 p->mark = mark;
10198 }
10199 { // t_primary '[' slices ']' &t_lookahead
10200 expr_ty a;
10201 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010202 Token * literal;
10203 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010204 if (
10205 (a = t_primary_rule(p))
10206 &&
10207 (literal = _PyPegen_expect_token(p, 9))
10208 &&
10209 (b = slices_rule(p))
10210 &&
10211 (literal_1 = _PyPegen_expect_token(p, 10))
10212 &&
10213 _PyPegen_lookahead(1, t_lookahead_rule, p)
10214 )
10215 {
10216 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10217 if (token == NULL) {
10218 return NULL;
10219 }
10220 int end_lineno = token->end_lineno;
10221 UNUSED(end_lineno); // Only used by EXTRA macro
10222 int end_col_offset = token->end_col_offset;
10223 UNUSED(end_col_offset); // Only used by EXTRA macro
10224 res = _Py_Subscript ( a , b , Load , EXTRA );
10225 if (res == NULL && PyErr_Occurred()) {
10226 p->error_indicator = 1;
10227 return NULL;
10228 }
10229 goto done;
10230 }
10231 p->mark = mark;
10232 }
10233 { // t_primary genexp &t_lookahead
10234 expr_ty a;
10235 expr_ty b;
10236 if (
10237 (a = t_primary_rule(p))
10238 &&
10239 (b = genexp_rule(p))
10240 &&
10241 _PyPegen_lookahead(1, t_lookahead_rule, p)
10242 )
10243 {
10244 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10245 if (token == NULL) {
10246 return NULL;
10247 }
10248 int end_lineno = token->end_lineno;
10249 UNUSED(end_lineno); // Only used by EXTRA macro
10250 int end_col_offset = token->end_col_offset;
10251 UNUSED(end_col_offset); // Only used by EXTRA macro
10252 res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
10253 if (res == NULL && PyErr_Occurred()) {
10254 p->error_indicator = 1;
10255 return NULL;
10256 }
10257 goto done;
10258 }
10259 p->mark = mark;
10260 }
10261 { // t_primary '(' arguments? ')' &t_lookahead
10262 expr_ty a;
10263 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010264 Token * literal;
10265 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010266 if (
10267 (a = t_primary_rule(p))
10268 &&
10269 (literal = _PyPegen_expect_token(p, 7))
10270 &&
10271 (b = arguments_rule(p), 1)
10272 &&
10273 (literal_1 = _PyPegen_expect_token(p, 8))
10274 &&
10275 _PyPegen_lookahead(1, t_lookahead_rule, p)
10276 )
10277 {
10278 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10279 if (token == NULL) {
10280 return NULL;
10281 }
10282 int end_lineno = token->end_lineno;
10283 UNUSED(end_lineno); // Only used by EXTRA macro
10284 int end_col_offset = token->end_col_offset;
10285 UNUSED(end_col_offset); // Only used by EXTRA macro
10286 res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
10287 if (res == NULL && PyErr_Occurred()) {
10288 p->error_indicator = 1;
10289 return NULL;
10290 }
10291 goto done;
10292 }
10293 p->mark = mark;
10294 }
10295 { // atom &t_lookahead
10296 expr_ty a;
10297 if (
10298 (a = atom_rule(p))
10299 &&
10300 _PyPegen_lookahead(1, t_lookahead_rule, p)
10301 )
10302 {
10303 res = a;
10304 if (res == NULL && PyErr_Occurred()) {
10305 p->error_indicator = 1;
10306 return NULL;
10307 }
10308 goto done;
10309 }
10310 p->mark = mark;
10311 }
10312 res = NULL;
10313 done:
10314 return res;
10315}
10316
10317// t_lookahead: '(' | '[' | '.'
10318static void *
10319t_lookahead_rule(Parser *p)
10320{
10321 if (p->error_indicator) {
10322 return NULL;
10323 }
10324 void * res = NULL;
10325 int mark = p->mark;
10326 { // '('
Pablo Galindob796b3f2020-05-01 12:32:26 +010010327 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010328 if (
10329 (literal = _PyPegen_expect_token(p, 7))
10330 )
10331 {
10332 res = literal;
10333 goto done;
10334 }
10335 p->mark = mark;
10336 }
10337 { // '['
Pablo Galindob796b3f2020-05-01 12:32:26 +010010338 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010339 if (
10340 (literal = _PyPegen_expect_token(p, 9))
10341 )
10342 {
10343 res = literal;
10344 goto done;
10345 }
10346 p->mark = mark;
10347 }
10348 { // '.'
Pablo Galindob796b3f2020-05-01 12:32:26 +010010349 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010350 if (
10351 (literal = _PyPegen_expect_token(p, 23))
10352 )
10353 {
10354 res = literal;
10355 goto done;
10356 }
10357 p->mark = mark;
10358 }
10359 res = NULL;
10360 done:
10361 return res;
10362}
10363
10364// t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']'
10365static expr_ty
10366t_atom_rule(Parser *p)
10367{
10368 if (p->error_indicator) {
10369 return NULL;
10370 }
10371 expr_ty res = NULL;
10372 int mark = p->mark;
10373 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
10374 p->error_indicator = 1;
10375 return NULL;
10376 }
10377 int start_lineno = p->tokens[mark]->lineno;
10378 UNUSED(start_lineno); // Only used by EXTRA macro
10379 int start_col_offset = p->tokens[mark]->col_offset;
10380 UNUSED(start_col_offset); // Only used by EXTRA macro
10381 { // NAME
10382 expr_ty a;
10383 if (
10384 (a = _PyPegen_name_token(p))
10385 )
10386 {
10387 res = _PyPegen_set_expr_context ( p , a , Store );
10388 if (res == NULL && PyErr_Occurred()) {
10389 p->error_indicator = 1;
10390 return NULL;
10391 }
10392 goto done;
10393 }
10394 p->mark = mark;
10395 }
10396 { // '(' target ')'
10397 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010398 Token * literal;
10399 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010400 if (
10401 (literal = _PyPegen_expect_token(p, 7))
10402 &&
10403 (a = target_rule(p))
10404 &&
10405 (literal_1 = _PyPegen_expect_token(p, 8))
10406 )
10407 {
10408 res = _PyPegen_set_expr_context ( p , a , Store );
10409 if (res == NULL && PyErr_Occurred()) {
10410 p->error_indicator = 1;
10411 return NULL;
10412 }
10413 goto done;
10414 }
10415 p->mark = mark;
10416 }
10417 { // '(' targets? ')'
10418 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010419 Token * literal;
10420 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010421 if (
10422 (literal = _PyPegen_expect_token(p, 7))
10423 &&
10424 (b = targets_rule(p), 1)
10425 &&
10426 (literal_1 = _PyPegen_expect_token(p, 8))
10427 )
10428 {
10429 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10430 if (token == NULL) {
10431 return NULL;
10432 }
10433 int end_lineno = token->end_lineno;
10434 UNUSED(end_lineno); // Only used by EXTRA macro
10435 int end_col_offset = token->end_col_offset;
10436 UNUSED(end_col_offset); // Only used by EXTRA macro
10437 res = _Py_Tuple ( b , Store , EXTRA );
10438 if (res == NULL && PyErr_Occurred()) {
10439 p->error_indicator = 1;
10440 return NULL;
10441 }
10442 goto done;
10443 }
10444 p->mark = mark;
10445 }
10446 { // '[' targets? ']'
10447 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010448 Token * literal;
10449 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010450 if (
10451 (literal = _PyPegen_expect_token(p, 9))
10452 &&
10453 (b = targets_rule(p), 1)
10454 &&
10455 (literal_1 = _PyPegen_expect_token(p, 10))
10456 )
10457 {
10458 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10459 if (token == NULL) {
10460 return NULL;
10461 }
10462 int end_lineno = token->end_lineno;
10463 UNUSED(end_lineno); // Only used by EXTRA macro
10464 int end_col_offset = token->end_col_offset;
10465 UNUSED(end_col_offset); // Only used by EXTRA macro
10466 res = _Py_List ( b , Store , EXTRA );
10467 if (res == NULL && PyErr_Occurred()) {
10468 p->error_indicator = 1;
10469 return NULL;
10470 }
10471 goto done;
10472 }
10473 p->mark = mark;
10474 }
10475 res = NULL;
10476 done:
10477 return res;
10478}
10479
10480// incorrect_arguments:
10481// | args ',' '*'
10482// | expression for_if_clauses ',' [args | expression for_if_clauses]
10483// | args ',' args
10484static void *
10485incorrect_arguments_rule(Parser *p)
10486{
10487 if (p->error_indicator) {
10488 return NULL;
10489 }
10490 void * res = NULL;
10491 int mark = p->mark;
10492 { // args ',' '*'
10493 expr_ty args_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010494 Token * literal;
10495 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010496 if (
10497 (args_var = args_rule(p))
10498 &&
10499 (literal = _PyPegen_expect_token(p, 12))
10500 &&
10501 (literal_1 = _PyPegen_expect_token(p, 16))
10502 )
10503 {
10504 res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" );
10505 if (res == NULL && PyErr_Occurred()) {
10506 p->error_indicator = 1;
10507 return NULL;
10508 }
10509 goto done;
10510 }
10511 p->mark = mark;
10512 }
10513 { // expression for_if_clauses ',' [args | expression for_if_clauses]
10514 expr_ty expression_var;
10515 asdl_seq* for_if_clauses_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010516 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010517 void *opt_var;
10518 UNUSED(opt_var); // Silence compiler warnings
10519 if (
10520 (expression_var = expression_rule(p))
10521 &&
10522 (for_if_clauses_var = for_if_clauses_rule(p))
10523 &&
10524 (literal = _PyPegen_expect_token(p, 12))
10525 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070010526 (opt_var = _tmp_125_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010527 )
10528 {
10529 res = RAISE_SYNTAX_ERROR ( "Generator expression must be parenthesized" );
10530 if (res == NULL && PyErr_Occurred()) {
10531 p->error_indicator = 1;
10532 return NULL;
10533 }
10534 goto done;
10535 }
10536 p->mark = mark;
10537 }
10538 { // args ',' args
10539 expr_ty a;
10540 expr_ty args_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010541 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010542 if (
10543 (a = args_rule(p))
10544 &&
10545 (literal = _PyPegen_expect_token(p, 12))
10546 &&
10547 (args_var = args_rule(p))
10548 )
10549 {
10550 res = _PyPegen_arguments_parsing_error ( p , a );
10551 if (res == NULL && PyErr_Occurred()) {
10552 p->error_indicator = 1;
10553 return NULL;
10554 }
10555 goto done;
10556 }
10557 p->mark = mark;
10558 }
10559 res = NULL;
10560 done:
10561 return res;
10562}
10563
10564// invalid_named_expression: expression ':=' expression
10565static void *
10566invalid_named_expression_rule(Parser *p)
10567{
10568 if (p->error_indicator) {
10569 return NULL;
10570 }
10571 void * res = NULL;
10572 int mark = p->mark;
10573 { // expression ':=' expression
10574 expr_ty a;
10575 expr_ty expression_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010576 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010577 if (
10578 (a = expression_rule(p))
10579 &&
10580 (literal = _PyPegen_expect_token(p, 53))
10581 &&
10582 (expression_var = expression_rule(p))
10583 )
10584 {
10585 res = RAISE_SYNTAX_ERROR ( "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) );
10586 if (res == NULL && PyErr_Occurred()) {
10587 p->error_indicator = 1;
10588 return NULL;
10589 }
10590 goto done;
10591 }
10592 p->mark = mark;
10593 }
10594 res = NULL;
10595 done:
10596 return res;
10597}
10598
10599// invalid_assignment:
10600// | list ':'
10601// | tuple ':'
10602// | expression ':' expression ['=' annotated_rhs]
10603// | expression ('=' | augassign) (yield_expr | star_expressions)
10604static void *
10605invalid_assignment_rule(Parser *p)
10606{
10607 if (p->error_indicator) {
10608 return NULL;
10609 }
10610 void * res = NULL;
10611 int mark = p->mark;
10612 { // list ':'
10613 expr_ty list_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010614 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010615 if (
10616 (list_var = list_rule(p))
10617 &&
10618 (literal = _PyPegen_expect_token(p, 11))
10619 )
10620 {
10621 res = RAISE_SYNTAX_ERROR ( "only single target (not list) can be annotated" );
10622 if (res == NULL && PyErr_Occurred()) {
10623 p->error_indicator = 1;
10624 return NULL;
10625 }
10626 goto done;
10627 }
10628 p->mark = mark;
10629 }
10630 { // tuple ':'
Pablo Galindob796b3f2020-05-01 12:32:26 +010010631 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010632 expr_ty tuple_var;
10633 if (
10634 (tuple_var = tuple_rule(p))
10635 &&
10636 (literal = _PyPegen_expect_token(p, 11))
10637 )
10638 {
10639 res = RAISE_SYNTAX_ERROR ( "only single target (not tuple) can be annotated" );
10640 if (res == NULL && PyErr_Occurred()) {
10641 p->error_indicator = 1;
10642 return NULL;
10643 }
10644 goto done;
10645 }
10646 p->mark = mark;
10647 }
10648 { // expression ':' expression ['=' annotated_rhs]
10649 expr_ty expression_var;
10650 expr_ty expression_var_1;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010651 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010652 void *opt_var;
10653 UNUSED(opt_var); // Silence compiler warnings
10654 if (
10655 (expression_var = expression_rule(p))
10656 &&
10657 (literal = _PyPegen_expect_token(p, 11))
10658 &&
10659 (expression_var_1 = expression_rule(p))
10660 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070010661 (opt_var = _tmp_126_rule(p), 1)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010662 )
10663 {
10664 res = RAISE_SYNTAX_ERROR ( "illegal target for annotation" );
10665 if (res == NULL && PyErr_Occurred()) {
10666 p->error_indicator = 1;
10667 return NULL;
10668 }
10669 goto done;
10670 }
10671 p->mark = mark;
10672 }
10673 { // expression ('=' | augassign) (yield_expr | star_expressions)
Guido van Rossum3941d972020-05-01 09:42:03 -070010674 void *_tmp_127_var;
10675 void *_tmp_128_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010676 expr_ty a;
10677 if (
10678 (a = expression_rule(p))
10679 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070010680 (_tmp_127_var = _tmp_127_rule(p))
Pablo Galindo2b74c832020-04-27 18:02:07 +010010681 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070010682 (_tmp_128_var = _tmp_128_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010683 )
10684 {
Batuhan Taskaya76c1b4d2020-05-01 16:13:43 +030010685 res = RAISE_SYNTAX_ERROR_NO_COL_OFFSET ( "cannot assign to %s" , _PyPegen_get_expr_name ( a ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010686 if (res == NULL && PyErr_Occurred()) {
10687 p->error_indicator = 1;
10688 return NULL;
10689 }
10690 goto done;
10691 }
10692 p->mark = mark;
10693 }
10694 res = NULL;
10695 done:
10696 return res;
10697}
10698
10699// invalid_block: NEWLINE !INDENT
10700static void *
10701invalid_block_rule(Parser *p)
10702{
10703 if (p->error_indicator) {
10704 return NULL;
10705 }
10706 void * res = NULL;
10707 int mark = p->mark;
10708 { // NEWLINE !INDENT
Pablo Galindob796b3f2020-05-01 12:32:26 +010010709 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010710 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +010010711 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010712 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +010010713 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010714 )
10715 {
10716 res = RAISE_INDENTATION_ERROR ( "expected an indented block" );
10717 if (res == NULL && PyErr_Occurred()) {
10718 p->error_indicator = 1;
10719 return NULL;
10720 }
10721 goto done;
10722 }
10723 p->mark = mark;
10724 }
10725 res = NULL;
10726 done:
10727 return res;
10728}
10729
10730// invalid_comprehension: ('[' | '(' | '{') '*' expression for_if_clauses
10731static void *
10732invalid_comprehension_rule(Parser *p)
10733{
10734 if (p->error_indicator) {
10735 return NULL;
10736 }
10737 void * res = NULL;
10738 int mark = p->mark;
10739 { // ('[' | '(' | '{') '*' expression for_if_clauses
Guido van Rossum3941d972020-05-01 09:42:03 -070010740 void *_tmp_129_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010741 expr_ty expression_var;
10742 asdl_seq* for_if_clauses_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010743 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010744 if (
Guido van Rossum3941d972020-05-01 09:42:03 -070010745 (_tmp_129_var = _tmp_129_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010746 &&
10747 (literal = _PyPegen_expect_token(p, 16))
10748 &&
10749 (expression_var = expression_rule(p))
10750 &&
10751 (for_if_clauses_var = for_if_clauses_rule(p))
10752 )
10753 {
10754 res = RAISE_SYNTAX_ERROR ( "iterable unpacking cannot be used in comprehension" );
10755 if (res == NULL && PyErr_Occurred()) {
10756 p->error_indicator = 1;
10757 return NULL;
10758 }
10759 goto done;
10760 }
10761 p->mark = mark;
10762 }
10763 res = NULL;
10764 done:
10765 return res;
10766}
10767
10768// invalid_parameters:
Guido van Rossumc001c092020-04-30 12:12:19 -070010769// | param_no_default* (slash_with_default | param_with_default+) param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010770static void *
10771invalid_parameters_rule(Parser *p)
10772{
10773 if (p->error_indicator) {
10774 return NULL;
10775 }
10776 void * res = NULL;
10777 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070010778 { // param_no_default* (slash_with_default | param_with_default+) param_no_default
Guido van Rossum3941d972020-05-01 09:42:03 -070010779 asdl_seq * _loop0_130_var;
10780 void *_tmp_131_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070010781 arg_ty param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010782 if (
Guido van Rossum3941d972020-05-01 09:42:03 -070010783 (_loop0_130_var = _loop0_130_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010784 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070010785 (_tmp_131_var = _tmp_131_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010786 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070010787 (param_no_default_var = param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010788 )
10789 {
10790 res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" );
10791 if (res == NULL && PyErr_Occurred()) {
10792 p->error_indicator = 1;
10793 return NULL;
10794 }
10795 goto done;
10796 }
10797 p->mark = mark;
10798 }
10799 res = NULL;
10800 done:
10801 return res;
10802}
10803
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030010804// invalid_star_etc: '*' (')' | ',' (')' | '**'))
10805static void *
10806invalid_star_etc_rule(Parser *p)
10807{
10808 if (p->error_indicator) {
10809 return NULL;
10810 }
10811 void * res = NULL;
10812 int mark = p->mark;
10813 { // '*' (')' | ',' (')' | '**'))
10814 void *_tmp_132_var;
10815 Token * literal;
10816 if (
10817 (literal = _PyPegen_expect_token(p, 16))
10818 &&
10819 (_tmp_132_var = _tmp_132_rule(p))
10820 )
10821 {
10822 res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
10823 if (res == NULL && PyErr_Occurred()) {
10824 p->error_indicator = 1;
10825 return NULL;
10826 }
10827 goto done;
10828 }
10829 p->mark = mark;
10830 }
10831 res = NULL;
10832 done:
10833 return res;
10834}
10835
10836// invalid_lambda_star_etc: '*' (':' | ',' (':' | '**'))
10837static void *
10838invalid_lambda_star_etc_rule(Parser *p)
10839{
10840 if (p->error_indicator) {
10841 return NULL;
10842 }
10843 void * res = NULL;
10844 int mark = p->mark;
10845 { // '*' (':' | ',' (':' | '**'))
10846 void *_tmp_133_var;
10847 Token * literal;
10848 if (
10849 (literal = _PyPegen_expect_token(p, 16))
10850 &&
10851 (_tmp_133_var = _tmp_133_rule(p))
10852 )
10853 {
10854 res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
10855 if (res == NULL && PyErr_Occurred()) {
10856 p->error_indicator = 1;
10857 return NULL;
10858 }
10859 goto done;
10860 }
10861 p->mark = mark;
10862 }
10863 res = NULL;
10864 done:
10865 return res;
10866}
10867
Guido van Rossumc001c092020-04-30 12:12:19 -070010868// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
10869static void *
10870invalid_double_type_comments_rule(Parser *p)
10871{
10872 if (p->error_indicator) {
10873 return NULL;
10874 }
10875 void * res = NULL;
10876 int mark = p->mark;
10877 { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
Pablo Galindob796b3f2020-05-01 12:32:26 +010010878 Token * indent_var;
10879 Token * newline_var;
10880 Token * newline_var_1;
10881 Token * type_comment_var;
10882 Token * type_comment_var_1;
Guido van Rossumc001c092020-04-30 12:12:19 -070010883 if (
10884 (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT))
10885 &&
10886 (newline_var = _PyPegen_expect_token(p, NEWLINE))
10887 &&
10888 (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT))
10889 &&
10890 (newline_var_1 = _PyPegen_expect_token(p, NEWLINE))
10891 &&
10892 (indent_var = _PyPegen_expect_token(p, INDENT))
10893 )
10894 {
10895 res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" );
10896 if (res == NULL && PyErr_Occurred()) {
10897 p->error_indicator = 1;
10898 return NULL;
10899 }
10900 goto done;
10901 }
10902 p->mark = mark;
10903 }
10904 res = NULL;
10905 done:
10906 return res;
10907}
10908
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010909// _loop0_1: NEWLINE
10910static asdl_seq *
10911_loop0_1_rule(Parser *p)
10912{
10913 if (p->error_indicator) {
10914 return NULL;
10915 }
10916 void *res = NULL;
10917 int mark = p->mark;
10918 int start_mark = p->mark;
10919 void **children = PyMem_Malloc(sizeof(void *));
10920 if (!children) {
10921 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
10922 return NULL;
10923 }
10924 ssize_t children_capacity = 1;
10925 ssize_t n = 0;
10926 { // NEWLINE
Pablo Galindob796b3f2020-05-01 12:32:26 +010010927 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010928 while (
Pablo Galindo4db245e2020-04-29 10:42:21 +010010929 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010930 )
10931 {
10932 res = newline_var;
10933 if (n == children_capacity) {
10934 children_capacity *= 2;
10935 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
10936 if (!children) {
10937 PyErr_Format(PyExc_MemoryError, "realloc None");
10938 return NULL;
10939 }
10940 }
10941 children[n++] = res;
10942 mark = p->mark;
10943 }
10944 p->mark = mark;
10945 }
10946 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
10947 if (!seq) {
10948 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1");
10949 PyMem_Free(children);
10950 return NULL;
10951 }
10952 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
10953 PyMem_Free(children);
10954 _PyPegen_insert_memo(p, start_mark, _loop0_1_type, seq);
10955 return seq;
10956}
10957
Guido van Rossumc001c092020-04-30 12:12:19 -070010958// _loop0_2: NEWLINE
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010959static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070010960_loop0_2_rule(Parser *p)
10961{
10962 if (p->error_indicator) {
10963 return NULL;
10964 }
10965 void *res = NULL;
10966 int mark = p->mark;
10967 int start_mark = p->mark;
10968 void **children = PyMem_Malloc(sizeof(void *));
10969 if (!children) {
10970 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
10971 return NULL;
10972 }
10973 ssize_t children_capacity = 1;
10974 ssize_t n = 0;
10975 { // NEWLINE
Pablo Galindob796b3f2020-05-01 12:32:26 +010010976 Token * newline_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070010977 while (
10978 (newline_var = _PyPegen_expect_token(p, NEWLINE))
10979 )
10980 {
10981 res = newline_var;
10982 if (n == children_capacity) {
10983 children_capacity *= 2;
10984 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
10985 if (!children) {
10986 PyErr_Format(PyExc_MemoryError, "realloc None");
10987 return NULL;
10988 }
10989 }
10990 children[n++] = res;
10991 mark = p->mark;
10992 }
10993 p->mark = mark;
10994 }
10995 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
10996 if (!seq) {
10997 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2");
10998 PyMem_Free(children);
10999 return NULL;
11000 }
11001 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11002 PyMem_Free(children);
11003 _PyPegen_insert_memo(p, start_mark, _loop0_2_type, seq);
11004 return seq;
11005}
11006
11007// _loop0_4: ',' expression
11008static asdl_seq *
11009_loop0_4_rule(Parser *p)
11010{
11011 if (p->error_indicator) {
11012 return NULL;
11013 }
11014 void *res = NULL;
11015 int mark = p->mark;
11016 int start_mark = p->mark;
11017 void **children = PyMem_Malloc(sizeof(void *));
11018 if (!children) {
11019 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11020 return NULL;
11021 }
11022 ssize_t children_capacity = 1;
11023 ssize_t n = 0;
11024 { // ',' expression
11025 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011026 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011027 while (
11028 (literal = _PyPegen_expect_token(p, 12))
11029 &&
11030 (elem = expression_rule(p))
11031 )
11032 {
11033 res = elem;
11034 if (res == NULL && PyErr_Occurred()) {
11035 p->error_indicator = 1;
11036 PyMem_Free(children);
11037 return NULL;
11038 }
11039 if (n == children_capacity) {
11040 children_capacity *= 2;
11041 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11042 if (!children) {
11043 PyErr_Format(PyExc_MemoryError, "realloc None");
11044 return NULL;
11045 }
11046 }
11047 children[n++] = res;
11048 mark = p->mark;
11049 }
11050 p->mark = mark;
11051 }
11052 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11053 if (!seq) {
11054 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4");
11055 PyMem_Free(children);
11056 return NULL;
11057 }
11058 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11059 PyMem_Free(children);
11060 _PyPegen_insert_memo(p, start_mark, _loop0_4_type, seq);
11061 return seq;
11062}
11063
11064// _gather_3: expression _loop0_4
11065static asdl_seq *
11066_gather_3_rule(Parser *p)
11067{
11068 if (p->error_indicator) {
11069 return NULL;
11070 }
11071 asdl_seq * res = NULL;
11072 int mark = p->mark;
11073 { // expression _loop0_4
11074 expr_ty elem;
11075 asdl_seq * seq;
11076 if (
11077 (elem = expression_rule(p))
11078 &&
11079 (seq = _loop0_4_rule(p))
11080 )
11081 {
11082 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11083 goto done;
11084 }
11085 p->mark = mark;
11086 }
11087 res = NULL;
11088 done:
11089 return res;
11090}
11091
11092// _loop0_6: ',' expression
11093static asdl_seq *
11094_loop0_6_rule(Parser *p)
11095{
11096 if (p->error_indicator) {
11097 return NULL;
11098 }
11099 void *res = NULL;
11100 int mark = p->mark;
11101 int start_mark = p->mark;
11102 void **children = PyMem_Malloc(sizeof(void *));
11103 if (!children) {
11104 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11105 return NULL;
11106 }
11107 ssize_t children_capacity = 1;
11108 ssize_t n = 0;
11109 { // ',' expression
11110 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011111 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011112 while (
11113 (literal = _PyPegen_expect_token(p, 12))
11114 &&
11115 (elem = expression_rule(p))
11116 )
11117 {
11118 res = elem;
11119 if (res == NULL && PyErr_Occurred()) {
11120 p->error_indicator = 1;
11121 PyMem_Free(children);
11122 return NULL;
11123 }
11124 if (n == children_capacity) {
11125 children_capacity *= 2;
11126 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11127 if (!children) {
11128 PyErr_Format(PyExc_MemoryError, "realloc None");
11129 return NULL;
11130 }
11131 }
11132 children[n++] = res;
11133 mark = p->mark;
11134 }
11135 p->mark = mark;
11136 }
11137 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11138 if (!seq) {
11139 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6");
11140 PyMem_Free(children);
11141 return NULL;
11142 }
11143 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11144 PyMem_Free(children);
11145 _PyPegen_insert_memo(p, start_mark, _loop0_6_type, seq);
11146 return seq;
11147}
11148
11149// _gather_5: expression _loop0_6
11150static asdl_seq *
11151_gather_5_rule(Parser *p)
11152{
11153 if (p->error_indicator) {
11154 return NULL;
11155 }
11156 asdl_seq * res = NULL;
11157 int mark = p->mark;
11158 { // expression _loop0_6
11159 expr_ty elem;
11160 asdl_seq * seq;
11161 if (
11162 (elem = expression_rule(p))
11163 &&
11164 (seq = _loop0_6_rule(p))
11165 )
11166 {
11167 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11168 goto done;
11169 }
11170 p->mark = mark;
11171 }
11172 res = NULL;
11173 done:
11174 return res;
11175}
11176
11177// _loop0_8: ',' expression
11178static asdl_seq *
11179_loop0_8_rule(Parser *p)
11180{
11181 if (p->error_indicator) {
11182 return NULL;
11183 }
11184 void *res = NULL;
11185 int mark = p->mark;
11186 int start_mark = p->mark;
11187 void **children = PyMem_Malloc(sizeof(void *));
11188 if (!children) {
11189 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11190 return NULL;
11191 }
11192 ssize_t children_capacity = 1;
11193 ssize_t n = 0;
11194 { // ',' expression
11195 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011196 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011197 while (
11198 (literal = _PyPegen_expect_token(p, 12))
11199 &&
11200 (elem = expression_rule(p))
11201 )
11202 {
11203 res = elem;
11204 if (res == NULL && PyErr_Occurred()) {
11205 p->error_indicator = 1;
11206 PyMem_Free(children);
11207 return NULL;
11208 }
11209 if (n == children_capacity) {
11210 children_capacity *= 2;
11211 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11212 if (!children) {
11213 PyErr_Format(PyExc_MemoryError, "realloc None");
11214 return NULL;
11215 }
11216 }
11217 children[n++] = res;
11218 mark = p->mark;
11219 }
11220 p->mark = mark;
11221 }
11222 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11223 if (!seq) {
11224 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8");
11225 PyMem_Free(children);
11226 return NULL;
11227 }
11228 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11229 PyMem_Free(children);
11230 _PyPegen_insert_memo(p, start_mark, _loop0_8_type, seq);
11231 return seq;
11232}
11233
11234// _gather_7: expression _loop0_8
11235static asdl_seq *
11236_gather_7_rule(Parser *p)
11237{
11238 if (p->error_indicator) {
11239 return NULL;
11240 }
11241 asdl_seq * res = NULL;
11242 int mark = p->mark;
11243 { // expression _loop0_8
11244 expr_ty elem;
11245 asdl_seq * seq;
11246 if (
11247 (elem = expression_rule(p))
11248 &&
11249 (seq = _loop0_8_rule(p))
11250 )
11251 {
11252 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11253 goto done;
11254 }
11255 p->mark = mark;
11256 }
11257 res = NULL;
11258 done:
11259 return res;
11260}
11261
11262// _loop0_10: ',' expression
11263static asdl_seq *
11264_loop0_10_rule(Parser *p)
11265{
11266 if (p->error_indicator) {
11267 return NULL;
11268 }
11269 void *res = NULL;
11270 int mark = p->mark;
11271 int start_mark = p->mark;
11272 void **children = PyMem_Malloc(sizeof(void *));
11273 if (!children) {
11274 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11275 return NULL;
11276 }
11277 ssize_t children_capacity = 1;
11278 ssize_t n = 0;
11279 { // ',' expression
11280 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011281 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011282 while (
11283 (literal = _PyPegen_expect_token(p, 12))
11284 &&
11285 (elem = expression_rule(p))
11286 )
11287 {
11288 res = elem;
11289 if (res == NULL && PyErr_Occurred()) {
11290 p->error_indicator = 1;
11291 PyMem_Free(children);
11292 return NULL;
11293 }
11294 if (n == children_capacity) {
11295 children_capacity *= 2;
11296 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11297 if (!children) {
11298 PyErr_Format(PyExc_MemoryError, "realloc None");
11299 return NULL;
11300 }
11301 }
11302 children[n++] = res;
11303 mark = p->mark;
11304 }
11305 p->mark = mark;
11306 }
11307 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11308 if (!seq) {
11309 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10");
11310 PyMem_Free(children);
11311 return NULL;
11312 }
11313 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11314 PyMem_Free(children);
11315 _PyPegen_insert_memo(p, start_mark, _loop0_10_type, seq);
11316 return seq;
11317}
11318
11319// _gather_9: expression _loop0_10
11320static asdl_seq *
11321_gather_9_rule(Parser *p)
11322{
11323 if (p->error_indicator) {
11324 return NULL;
11325 }
11326 asdl_seq * res = NULL;
11327 int mark = p->mark;
11328 { // expression _loop0_10
11329 expr_ty elem;
11330 asdl_seq * seq;
11331 if (
11332 (elem = expression_rule(p))
11333 &&
11334 (seq = _loop0_10_rule(p))
11335 )
11336 {
11337 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11338 goto done;
11339 }
11340 p->mark = mark;
11341 }
11342 res = NULL;
11343 done:
11344 return res;
11345}
11346
11347// _loop1_11: statement
11348static asdl_seq *
11349_loop1_11_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011350{
11351 if (p->error_indicator) {
11352 return NULL;
11353 }
11354 void *res = NULL;
11355 int mark = p->mark;
11356 int start_mark = p->mark;
11357 void **children = PyMem_Malloc(sizeof(void *));
11358 if (!children) {
11359 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11360 return NULL;
11361 }
11362 ssize_t children_capacity = 1;
11363 ssize_t n = 0;
11364 { // statement
11365 asdl_seq* statement_var;
11366 while (
11367 (statement_var = statement_rule(p))
11368 )
11369 {
11370 res = statement_var;
11371 if (n == children_capacity) {
11372 children_capacity *= 2;
11373 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11374 if (!children) {
11375 PyErr_Format(PyExc_MemoryError, "realloc None");
11376 return NULL;
11377 }
11378 }
11379 children[n++] = res;
11380 mark = p->mark;
11381 }
11382 p->mark = mark;
11383 }
11384 if (n == 0) {
11385 PyMem_Free(children);
11386 return NULL;
11387 }
11388 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11389 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070011390 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011391 PyMem_Free(children);
11392 return NULL;
11393 }
11394 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11395 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070011396 _PyPegen_insert_memo(p, start_mark, _loop1_11_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011397 return seq;
11398}
11399
Guido van Rossumc001c092020-04-30 12:12:19 -070011400// _loop0_13: ';' small_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011401static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011402_loop0_13_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011403{
11404 if (p->error_indicator) {
11405 return NULL;
11406 }
11407 void *res = NULL;
11408 int mark = p->mark;
11409 int start_mark = p->mark;
11410 void **children = PyMem_Malloc(sizeof(void *));
11411 if (!children) {
11412 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11413 return NULL;
11414 }
11415 ssize_t children_capacity = 1;
11416 ssize_t n = 0;
11417 { // ';' small_stmt
11418 stmt_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011419 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011420 while (
11421 (literal = _PyPegen_expect_token(p, 13))
11422 &&
11423 (elem = small_stmt_rule(p))
11424 )
11425 {
11426 res = elem;
11427 if (res == NULL && PyErr_Occurred()) {
11428 p->error_indicator = 1;
11429 PyMem_Free(children);
11430 return NULL;
11431 }
11432 if (n == children_capacity) {
11433 children_capacity *= 2;
11434 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11435 if (!children) {
11436 PyErr_Format(PyExc_MemoryError, "realloc None");
11437 return NULL;
11438 }
11439 }
11440 children[n++] = res;
11441 mark = p->mark;
11442 }
11443 p->mark = mark;
11444 }
11445 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11446 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070011447 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011448 PyMem_Free(children);
11449 return NULL;
11450 }
11451 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11452 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070011453 _PyPegen_insert_memo(p, start_mark, _loop0_13_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011454 return seq;
11455}
11456
Guido van Rossumc001c092020-04-30 12:12:19 -070011457// _gather_12: small_stmt _loop0_13
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011458static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011459_gather_12_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011460{
11461 if (p->error_indicator) {
11462 return NULL;
11463 }
11464 asdl_seq * res = NULL;
11465 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070011466 { // small_stmt _loop0_13
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011467 stmt_ty elem;
11468 asdl_seq * seq;
11469 if (
11470 (elem = small_stmt_rule(p))
11471 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070011472 (seq = _loop0_13_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011473 )
11474 {
11475 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11476 goto done;
11477 }
11478 p->mark = mark;
11479 }
11480 res = NULL;
11481 done:
11482 return res;
11483}
11484
Guido van Rossumc001c092020-04-30 12:12:19 -070011485// _tmp_14: 'import' | 'from'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011486static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011487_tmp_14_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011488{
11489 if (p->error_indicator) {
11490 return NULL;
11491 }
11492 void * res = NULL;
11493 int mark = p->mark;
11494 { // 'import'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011495 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011496 if (
11497 (keyword = _PyPegen_expect_token(p, 513))
11498 )
11499 {
11500 res = keyword;
11501 goto done;
11502 }
11503 p->mark = mark;
11504 }
11505 { // 'from'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011506 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011507 if (
11508 (keyword = _PyPegen_expect_token(p, 514))
11509 )
11510 {
11511 res = keyword;
11512 goto done;
11513 }
11514 p->mark = mark;
11515 }
11516 res = NULL;
11517 done:
11518 return res;
11519}
11520
Guido van Rossumc001c092020-04-30 12:12:19 -070011521// _tmp_15: 'def' | '@' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011522static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011523_tmp_15_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011524{
11525 if (p->error_indicator) {
11526 return NULL;
11527 }
11528 void * res = NULL;
11529 int mark = p->mark;
11530 { // 'def'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011531 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011532 if (
11533 (keyword = _PyPegen_expect_token(p, 522))
11534 )
11535 {
11536 res = keyword;
11537 goto done;
11538 }
11539 p->mark = mark;
11540 }
11541 { // '@'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011542 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011543 if (
11544 (literal = _PyPegen_expect_token(p, 49))
11545 )
11546 {
11547 res = literal;
11548 goto done;
11549 }
11550 p->mark = mark;
11551 }
11552 { // ASYNC
Pablo Galindob796b3f2020-05-01 12:32:26 +010011553 Token * async_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011554 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +010011555 (async_var = _PyPegen_expect_token(p, ASYNC))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011556 )
11557 {
11558 res = async_var;
11559 goto done;
11560 }
11561 p->mark = mark;
11562 }
11563 res = NULL;
11564 done:
11565 return res;
11566}
11567
Guido van Rossumc001c092020-04-30 12:12:19 -070011568// _tmp_16: 'class' | '@'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011569static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011570_tmp_16_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011571{
11572 if (p->error_indicator) {
11573 return NULL;
11574 }
11575 void * res = NULL;
11576 int mark = p->mark;
11577 { // 'class'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011578 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011579 if (
11580 (keyword = _PyPegen_expect_token(p, 523))
11581 )
11582 {
11583 res = keyword;
11584 goto done;
11585 }
11586 p->mark = mark;
11587 }
11588 { // '@'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011589 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011590 if (
11591 (literal = _PyPegen_expect_token(p, 49))
11592 )
11593 {
11594 res = literal;
11595 goto done;
11596 }
11597 p->mark = mark;
11598 }
11599 res = NULL;
11600 done:
11601 return res;
11602}
11603
Guido van Rossumc001c092020-04-30 12:12:19 -070011604// _tmp_17: 'with' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011605static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011606_tmp_17_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011607{
11608 if (p->error_indicator) {
11609 return NULL;
11610 }
11611 void * res = NULL;
11612 int mark = p->mark;
11613 { // 'with'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011614 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011615 if (
11616 (keyword = _PyPegen_expect_token(p, 519))
11617 )
11618 {
11619 res = keyword;
11620 goto done;
11621 }
11622 p->mark = mark;
11623 }
11624 { // ASYNC
Pablo Galindob796b3f2020-05-01 12:32:26 +010011625 Token * async_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011626 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +010011627 (async_var = _PyPegen_expect_token(p, ASYNC))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011628 )
11629 {
11630 res = async_var;
11631 goto done;
11632 }
11633 p->mark = mark;
11634 }
11635 res = NULL;
11636 done:
11637 return res;
11638}
11639
Guido van Rossumc001c092020-04-30 12:12:19 -070011640// _tmp_18: 'for' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011641static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011642_tmp_18_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011643{
11644 if (p->error_indicator) {
11645 return NULL;
11646 }
11647 void * res = NULL;
11648 int mark = p->mark;
11649 { // 'for'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011650 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011651 if (
11652 (keyword = _PyPegen_expect_token(p, 517))
11653 )
11654 {
11655 res = keyword;
11656 goto done;
11657 }
11658 p->mark = mark;
11659 }
11660 { // ASYNC
Pablo Galindob796b3f2020-05-01 12:32:26 +010011661 Token * async_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011662 if (
Pablo Galindo4db245e2020-04-29 10:42:21 +010011663 (async_var = _PyPegen_expect_token(p, ASYNC))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011664 )
11665 {
11666 res = async_var;
11667 goto done;
11668 }
11669 p->mark = mark;
11670 }
11671 res = NULL;
11672 done:
11673 return res;
11674}
11675
Guido van Rossumc001c092020-04-30 12:12:19 -070011676// _tmp_19: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011677static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011678_tmp_19_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011679{
11680 if (p->error_indicator) {
11681 return NULL;
11682 }
11683 void * res = NULL;
11684 int mark = p->mark;
11685 { // '=' annotated_rhs
11686 expr_ty d;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011687 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011688 if (
11689 (literal = _PyPegen_expect_token(p, 22))
11690 &&
11691 (d = annotated_rhs_rule(p))
11692 )
11693 {
11694 res = d;
11695 if (res == NULL && PyErr_Occurred()) {
11696 p->error_indicator = 1;
11697 return NULL;
11698 }
11699 goto done;
11700 }
11701 p->mark = mark;
11702 }
11703 res = NULL;
11704 done:
11705 return res;
11706}
11707
Guido van Rossumc001c092020-04-30 12:12:19 -070011708// _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011709static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011710_tmp_20_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011711{
11712 if (p->error_indicator) {
11713 return NULL;
11714 }
11715 void * res = NULL;
11716 int mark = p->mark;
11717 { // '(' inside_paren_ann_assign_target ')'
11718 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011719 Token * literal;
11720 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011721 if (
11722 (literal = _PyPegen_expect_token(p, 7))
11723 &&
11724 (b = inside_paren_ann_assign_target_rule(p))
11725 &&
11726 (literal_1 = _PyPegen_expect_token(p, 8))
11727 )
11728 {
11729 res = b;
11730 if (res == NULL && PyErr_Occurred()) {
11731 p->error_indicator = 1;
11732 return NULL;
11733 }
11734 goto done;
11735 }
11736 p->mark = mark;
11737 }
11738 { // ann_assign_subscript_attribute_target
11739 expr_ty ann_assign_subscript_attribute_target_var;
11740 if (
11741 (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p))
11742 )
11743 {
11744 res = ann_assign_subscript_attribute_target_var;
11745 goto done;
11746 }
11747 p->mark = mark;
11748 }
11749 res = NULL;
11750 done:
11751 return res;
11752}
11753
Guido van Rossumc001c092020-04-30 12:12:19 -070011754// _tmp_21: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011755static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011756_tmp_21_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011757{
11758 if (p->error_indicator) {
11759 return NULL;
11760 }
11761 void * res = NULL;
11762 int mark = p->mark;
11763 { // '=' annotated_rhs
11764 expr_ty d;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011765 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011766 if (
11767 (literal = _PyPegen_expect_token(p, 22))
11768 &&
11769 (d = annotated_rhs_rule(p))
11770 )
11771 {
11772 res = d;
11773 if (res == NULL && PyErr_Occurred()) {
11774 p->error_indicator = 1;
11775 return NULL;
11776 }
11777 goto done;
11778 }
11779 p->mark = mark;
11780 }
11781 res = NULL;
11782 done:
11783 return res;
11784}
11785
Guido van Rossumc001c092020-04-30 12:12:19 -070011786// _loop1_22: (star_targets '=')
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011787static asdl_seq *
11788_loop1_22_rule(Parser *p)
11789{
11790 if (p->error_indicator) {
11791 return NULL;
11792 }
11793 void *res = NULL;
11794 int mark = p->mark;
11795 int start_mark = p->mark;
11796 void **children = PyMem_Malloc(sizeof(void *));
11797 if (!children) {
11798 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11799 return NULL;
11800 }
11801 ssize_t children_capacity = 1;
11802 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070011803 { // (star_targets '=')
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030011804 void *_tmp_134_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011805 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030011806 (_tmp_134_var = _tmp_134_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011807 )
11808 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030011809 res = _tmp_134_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011810 if (n == children_capacity) {
11811 children_capacity *= 2;
11812 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11813 if (!children) {
11814 PyErr_Format(PyExc_MemoryError, "realloc None");
11815 return NULL;
11816 }
11817 }
11818 children[n++] = res;
11819 mark = p->mark;
11820 }
11821 p->mark = mark;
11822 }
11823 if (n == 0) {
11824 PyMem_Free(children);
11825 return NULL;
11826 }
11827 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11828 if (!seq) {
11829 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22");
11830 PyMem_Free(children);
11831 return NULL;
11832 }
11833 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11834 PyMem_Free(children);
11835 _PyPegen_insert_memo(p, start_mark, _loop1_22_type, seq);
11836 return seq;
11837}
11838
Guido van Rossumc001c092020-04-30 12:12:19 -070011839// _tmp_23: yield_expr | star_expressions
11840static void *
11841_tmp_23_rule(Parser *p)
11842{
11843 if (p->error_indicator) {
11844 return NULL;
11845 }
11846 void * res = NULL;
11847 int mark = p->mark;
11848 { // yield_expr
11849 expr_ty yield_expr_var;
11850 if (
11851 (yield_expr_var = yield_expr_rule(p))
11852 )
11853 {
11854 res = yield_expr_var;
11855 goto done;
11856 }
11857 p->mark = mark;
11858 }
11859 { // star_expressions
11860 expr_ty star_expressions_var;
11861 if (
11862 (star_expressions_var = star_expressions_rule(p))
11863 )
11864 {
11865 res = star_expressions_var;
11866 goto done;
11867 }
11868 p->mark = mark;
11869 }
11870 res = NULL;
11871 done:
11872 return res;
11873}
11874
11875// _tmp_24: yield_expr | star_expressions
11876static void *
11877_tmp_24_rule(Parser *p)
11878{
11879 if (p->error_indicator) {
11880 return NULL;
11881 }
11882 void * res = NULL;
11883 int mark = p->mark;
11884 { // yield_expr
11885 expr_ty yield_expr_var;
11886 if (
11887 (yield_expr_var = yield_expr_rule(p))
11888 )
11889 {
11890 res = yield_expr_var;
11891 goto done;
11892 }
11893 p->mark = mark;
11894 }
11895 { // star_expressions
11896 expr_ty star_expressions_var;
11897 if (
11898 (star_expressions_var = star_expressions_rule(p))
11899 )
11900 {
11901 res = star_expressions_var;
11902 goto done;
11903 }
11904 p->mark = mark;
11905 }
11906 res = NULL;
11907 done:
11908 return res;
11909}
11910
11911// _loop0_26: ',' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011912static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011913_loop0_26_rule(Parser *p)
11914{
11915 if (p->error_indicator) {
11916 return NULL;
11917 }
11918 void *res = NULL;
11919 int mark = p->mark;
11920 int start_mark = p->mark;
11921 void **children = PyMem_Malloc(sizeof(void *));
11922 if (!children) {
11923 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11924 return NULL;
11925 }
11926 ssize_t children_capacity = 1;
11927 ssize_t n = 0;
11928 { // ',' NAME
11929 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011930 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011931 while (
11932 (literal = _PyPegen_expect_token(p, 12))
11933 &&
11934 (elem = _PyPegen_name_token(p))
11935 )
11936 {
11937 res = elem;
11938 if (res == NULL && PyErr_Occurred()) {
11939 p->error_indicator = 1;
11940 PyMem_Free(children);
11941 return NULL;
11942 }
11943 if (n == children_capacity) {
11944 children_capacity *= 2;
11945 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11946 if (!children) {
11947 PyErr_Format(PyExc_MemoryError, "realloc None");
11948 return NULL;
11949 }
11950 }
11951 children[n++] = res;
11952 mark = p->mark;
11953 }
11954 p->mark = mark;
11955 }
11956 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11957 if (!seq) {
11958 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26");
11959 PyMem_Free(children);
11960 return NULL;
11961 }
11962 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11963 PyMem_Free(children);
11964 _PyPegen_insert_memo(p, start_mark, _loop0_26_type, seq);
11965 return seq;
11966}
11967
11968// _gather_25: NAME _loop0_26
11969static asdl_seq *
11970_gather_25_rule(Parser *p)
11971{
11972 if (p->error_indicator) {
11973 return NULL;
11974 }
11975 asdl_seq * res = NULL;
11976 int mark = p->mark;
11977 { // NAME _loop0_26
11978 expr_ty elem;
11979 asdl_seq * seq;
11980 if (
11981 (elem = _PyPegen_name_token(p))
11982 &&
11983 (seq = _loop0_26_rule(p))
11984 )
11985 {
11986 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11987 goto done;
11988 }
11989 p->mark = mark;
11990 }
11991 res = NULL;
11992 done:
11993 return res;
11994}
11995
11996// _loop0_28: ',' NAME
11997static asdl_seq *
11998_loop0_28_rule(Parser *p)
11999{
12000 if (p->error_indicator) {
12001 return NULL;
12002 }
12003 void *res = NULL;
12004 int mark = p->mark;
12005 int start_mark = p->mark;
12006 void **children = PyMem_Malloc(sizeof(void *));
12007 if (!children) {
12008 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12009 return NULL;
12010 }
12011 ssize_t children_capacity = 1;
12012 ssize_t n = 0;
12013 { // ',' NAME
12014 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012015 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070012016 while (
12017 (literal = _PyPegen_expect_token(p, 12))
12018 &&
12019 (elem = _PyPegen_name_token(p))
12020 )
12021 {
12022 res = elem;
12023 if (res == NULL && PyErr_Occurred()) {
12024 p->error_indicator = 1;
12025 PyMem_Free(children);
12026 return NULL;
12027 }
12028 if (n == children_capacity) {
12029 children_capacity *= 2;
12030 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12031 if (!children) {
12032 PyErr_Format(PyExc_MemoryError, "realloc None");
12033 return NULL;
12034 }
12035 }
12036 children[n++] = res;
12037 mark = p->mark;
12038 }
12039 p->mark = mark;
12040 }
12041 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12042 if (!seq) {
12043 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28");
12044 PyMem_Free(children);
12045 return NULL;
12046 }
12047 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12048 PyMem_Free(children);
12049 _PyPegen_insert_memo(p, start_mark, _loop0_28_type, seq);
12050 return seq;
12051}
12052
12053// _gather_27: NAME _loop0_28
12054static asdl_seq *
12055_gather_27_rule(Parser *p)
12056{
12057 if (p->error_indicator) {
12058 return NULL;
12059 }
12060 asdl_seq * res = NULL;
12061 int mark = p->mark;
12062 { // NAME _loop0_28
12063 expr_ty elem;
12064 asdl_seq * seq;
12065 if (
12066 (elem = _PyPegen_name_token(p))
12067 &&
12068 (seq = _loop0_28_rule(p))
12069 )
12070 {
12071 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12072 goto done;
12073 }
12074 p->mark = mark;
12075 }
12076 res = NULL;
12077 done:
12078 return res;
12079}
12080
12081// _tmp_29: ',' expression
12082static void *
12083_tmp_29_rule(Parser *p)
12084{
12085 if (p->error_indicator) {
12086 return NULL;
12087 }
12088 void * res = NULL;
12089 int mark = p->mark;
12090 { // ',' expression
Pablo Galindob796b3f2020-05-01 12:32:26 +010012091 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070012092 expr_ty z;
12093 if (
12094 (literal = _PyPegen_expect_token(p, 12))
12095 &&
12096 (z = expression_rule(p))
12097 )
12098 {
12099 res = z;
12100 if (res == NULL && PyErr_Occurred()) {
12101 p->error_indicator = 1;
12102 return NULL;
12103 }
12104 goto done;
12105 }
12106 p->mark = mark;
12107 }
12108 res = NULL;
12109 done:
12110 return res;
12111}
12112
12113// _loop0_30: ('.' | '...')
12114static asdl_seq *
12115_loop0_30_rule(Parser *p)
12116{
12117 if (p->error_indicator) {
12118 return NULL;
12119 }
12120 void *res = NULL;
12121 int mark = p->mark;
12122 int start_mark = p->mark;
12123 void **children = PyMem_Malloc(sizeof(void *));
12124 if (!children) {
12125 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12126 return NULL;
12127 }
12128 ssize_t children_capacity = 1;
12129 ssize_t n = 0;
12130 { // ('.' | '...')
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012131 void *_tmp_135_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070012132 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012133 (_tmp_135_var = _tmp_135_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070012134 )
12135 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012136 res = _tmp_135_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070012137 if (n == children_capacity) {
12138 children_capacity *= 2;
12139 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12140 if (!children) {
12141 PyErr_Format(PyExc_MemoryError, "realloc None");
12142 return NULL;
12143 }
12144 }
12145 children[n++] = res;
12146 mark = p->mark;
12147 }
12148 p->mark = mark;
12149 }
12150 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12151 if (!seq) {
12152 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30");
12153 PyMem_Free(children);
12154 return NULL;
12155 }
12156 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12157 PyMem_Free(children);
12158 _PyPegen_insert_memo(p, start_mark, _loop0_30_type, seq);
12159 return seq;
12160}
12161
12162// _loop1_31: ('.' | '...')
12163static asdl_seq *
12164_loop1_31_rule(Parser *p)
12165{
12166 if (p->error_indicator) {
12167 return NULL;
12168 }
12169 void *res = NULL;
12170 int mark = p->mark;
12171 int start_mark = p->mark;
12172 void **children = PyMem_Malloc(sizeof(void *));
12173 if (!children) {
12174 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12175 return NULL;
12176 }
12177 ssize_t children_capacity = 1;
12178 ssize_t n = 0;
12179 { // ('.' | '...')
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012180 void *_tmp_136_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070012181 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012182 (_tmp_136_var = _tmp_136_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070012183 )
12184 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012185 res = _tmp_136_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070012186 if (n == children_capacity) {
12187 children_capacity *= 2;
12188 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12189 if (!children) {
12190 PyErr_Format(PyExc_MemoryError, "realloc None");
12191 return NULL;
12192 }
12193 }
12194 children[n++] = res;
12195 mark = p->mark;
12196 }
12197 p->mark = mark;
12198 }
12199 if (n == 0) {
12200 PyMem_Free(children);
12201 return NULL;
12202 }
12203 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12204 if (!seq) {
12205 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31");
12206 PyMem_Free(children);
12207 return NULL;
12208 }
12209 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12210 PyMem_Free(children);
12211 _PyPegen_insert_memo(p, start_mark, _loop1_31_type, seq);
12212 return seq;
12213}
12214
12215// _loop0_33: ',' import_from_as_name
12216static asdl_seq *
12217_loop0_33_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012218{
12219 if (p->error_indicator) {
12220 return NULL;
12221 }
12222 void *res = NULL;
12223 int mark = p->mark;
12224 int start_mark = p->mark;
12225 void **children = PyMem_Malloc(sizeof(void *));
12226 if (!children) {
12227 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12228 return NULL;
12229 }
12230 ssize_t children_capacity = 1;
12231 ssize_t n = 0;
12232 { // ',' import_from_as_name
12233 alias_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012234 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012235 while (
12236 (literal = _PyPegen_expect_token(p, 12))
12237 &&
12238 (elem = import_from_as_name_rule(p))
12239 )
12240 {
12241 res = elem;
12242 if (res == NULL && PyErr_Occurred()) {
12243 p->error_indicator = 1;
12244 PyMem_Free(children);
12245 return NULL;
12246 }
12247 if (n == children_capacity) {
12248 children_capacity *= 2;
12249 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12250 if (!children) {
12251 PyErr_Format(PyExc_MemoryError, "realloc None");
12252 return NULL;
12253 }
12254 }
12255 children[n++] = res;
12256 mark = p->mark;
12257 }
12258 p->mark = mark;
12259 }
12260 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12261 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012262 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012263 PyMem_Free(children);
12264 return NULL;
12265 }
12266 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12267 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012268 _PyPegen_insert_memo(p, start_mark, _loop0_33_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012269 return seq;
12270}
12271
Guido van Rossumc001c092020-04-30 12:12:19 -070012272// _gather_32: import_from_as_name _loop0_33
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012273static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012274_gather_32_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012275{
12276 if (p->error_indicator) {
12277 return NULL;
12278 }
12279 asdl_seq * res = NULL;
12280 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012281 { // import_from_as_name _loop0_33
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012282 alias_ty elem;
12283 asdl_seq * seq;
12284 if (
12285 (elem = import_from_as_name_rule(p))
12286 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012287 (seq = _loop0_33_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012288 )
12289 {
12290 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12291 goto done;
12292 }
12293 p->mark = mark;
12294 }
12295 res = NULL;
12296 done:
12297 return res;
12298}
12299
Guido van Rossumc001c092020-04-30 12:12:19 -070012300// _tmp_34: 'as' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012301static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070012302_tmp_34_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012303{
12304 if (p->error_indicator) {
12305 return NULL;
12306 }
12307 void * res = NULL;
12308 int mark = p->mark;
12309 { // 'as' NAME
Pablo Galindob796b3f2020-05-01 12:32:26 +010012310 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012311 expr_ty z;
12312 if (
12313 (keyword = _PyPegen_expect_token(p, 531))
12314 &&
12315 (z = _PyPegen_name_token(p))
12316 )
12317 {
12318 res = z;
12319 if (res == NULL && PyErr_Occurred()) {
12320 p->error_indicator = 1;
12321 return NULL;
12322 }
12323 goto done;
12324 }
12325 p->mark = mark;
12326 }
12327 res = NULL;
12328 done:
12329 return res;
12330}
12331
Guido van Rossumc001c092020-04-30 12:12:19 -070012332// _loop0_36: ',' dotted_as_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012333static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012334_loop0_36_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012335{
12336 if (p->error_indicator) {
12337 return NULL;
12338 }
12339 void *res = NULL;
12340 int mark = p->mark;
12341 int start_mark = p->mark;
12342 void **children = PyMem_Malloc(sizeof(void *));
12343 if (!children) {
12344 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12345 return NULL;
12346 }
12347 ssize_t children_capacity = 1;
12348 ssize_t n = 0;
12349 { // ',' dotted_as_name
12350 alias_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012351 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012352 while (
12353 (literal = _PyPegen_expect_token(p, 12))
12354 &&
12355 (elem = dotted_as_name_rule(p))
12356 )
12357 {
12358 res = elem;
12359 if (res == NULL && PyErr_Occurred()) {
12360 p->error_indicator = 1;
12361 PyMem_Free(children);
12362 return NULL;
12363 }
12364 if (n == children_capacity) {
12365 children_capacity *= 2;
12366 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12367 if (!children) {
12368 PyErr_Format(PyExc_MemoryError, "realloc None");
12369 return NULL;
12370 }
12371 }
12372 children[n++] = res;
12373 mark = p->mark;
12374 }
12375 p->mark = mark;
12376 }
12377 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12378 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012379 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012380 PyMem_Free(children);
12381 return NULL;
12382 }
12383 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12384 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012385 _PyPegen_insert_memo(p, start_mark, _loop0_36_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012386 return seq;
12387}
12388
Guido van Rossumc001c092020-04-30 12:12:19 -070012389// _gather_35: dotted_as_name _loop0_36
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012390static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012391_gather_35_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012392{
12393 if (p->error_indicator) {
12394 return NULL;
12395 }
12396 asdl_seq * res = NULL;
12397 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012398 { // dotted_as_name _loop0_36
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012399 alias_ty elem;
12400 asdl_seq * seq;
12401 if (
12402 (elem = dotted_as_name_rule(p))
12403 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012404 (seq = _loop0_36_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012405 )
12406 {
12407 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12408 goto done;
12409 }
12410 p->mark = mark;
12411 }
12412 res = NULL;
12413 done:
12414 return res;
12415}
12416
Guido van Rossumc001c092020-04-30 12:12:19 -070012417// _tmp_37: 'as' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012418static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070012419_tmp_37_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012420{
12421 if (p->error_indicator) {
12422 return NULL;
12423 }
12424 void * res = NULL;
12425 int mark = p->mark;
12426 { // 'as' NAME
Pablo Galindob796b3f2020-05-01 12:32:26 +010012427 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012428 expr_ty z;
12429 if (
12430 (keyword = _PyPegen_expect_token(p, 531))
12431 &&
12432 (z = _PyPegen_name_token(p))
12433 )
12434 {
12435 res = z;
12436 if (res == NULL && PyErr_Occurred()) {
12437 p->error_indicator = 1;
12438 return NULL;
12439 }
12440 goto done;
12441 }
12442 p->mark = mark;
12443 }
12444 res = NULL;
12445 done:
12446 return res;
12447}
12448
Guido van Rossumc001c092020-04-30 12:12:19 -070012449// _loop0_39: ',' with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012450static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012451_loop0_39_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012452{
12453 if (p->error_indicator) {
12454 return NULL;
12455 }
12456 void *res = NULL;
12457 int mark = p->mark;
12458 int start_mark = p->mark;
12459 void **children = PyMem_Malloc(sizeof(void *));
12460 if (!children) {
12461 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12462 return NULL;
12463 }
12464 ssize_t children_capacity = 1;
12465 ssize_t n = 0;
12466 { // ',' with_item
12467 withitem_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012468 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012469 while (
12470 (literal = _PyPegen_expect_token(p, 12))
12471 &&
12472 (elem = with_item_rule(p))
12473 )
12474 {
12475 res = elem;
12476 if (res == NULL && PyErr_Occurred()) {
12477 p->error_indicator = 1;
12478 PyMem_Free(children);
12479 return NULL;
12480 }
12481 if (n == children_capacity) {
12482 children_capacity *= 2;
12483 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12484 if (!children) {
12485 PyErr_Format(PyExc_MemoryError, "realloc None");
12486 return NULL;
12487 }
12488 }
12489 children[n++] = res;
12490 mark = p->mark;
12491 }
12492 p->mark = mark;
12493 }
12494 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12495 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012496 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012497 PyMem_Free(children);
12498 return NULL;
12499 }
12500 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12501 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012502 _PyPegen_insert_memo(p, start_mark, _loop0_39_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012503 return seq;
12504}
12505
Guido van Rossumc001c092020-04-30 12:12:19 -070012506// _gather_38: with_item _loop0_39
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012507static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012508_gather_38_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012509{
12510 if (p->error_indicator) {
12511 return NULL;
12512 }
12513 asdl_seq * res = NULL;
12514 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012515 { // with_item _loop0_39
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012516 withitem_ty elem;
12517 asdl_seq * seq;
12518 if (
12519 (elem = with_item_rule(p))
12520 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012521 (seq = _loop0_39_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012522 )
12523 {
12524 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12525 goto done;
12526 }
12527 p->mark = mark;
12528 }
12529 res = NULL;
12530 done:
12531 return res;
12532}
12533
Guido van Rossumc001c092020-04-30 12:12:19 -070012534// _loop0_41: ',' with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012535static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012536_loop0_41_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012537{
12538 if (p->error_indicator) {
12539 return NULL;
12540 }
12541 void *res = NULL;
12542 int mark = p->mark;
12543 int start_mark = p->mark;
12544 void **children = PyMem_Malloc(sizeof(void *));
12545 if (!children) {
12546 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12547 return NULL;
12548 }
12549 ssize_t children_capacity = 1;
12550 ssize_t n = 0;
12551 { // ',' with_item
12552 withitem_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012553 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012554 while (
12555 (literal = _PyPegen_expect_token(p, 12))
12556 &&
12557 (elem = with_item_rule(p))
12558 )
12559 {
12560 res = elem;
12561 if (res == NULL && PyErr_Occurred()) {
12562 p->error_indicator = 1;
12563 PyMem_Free(children);
12564 return NULL;
12565 }
12566 if (n == children_capacity) {
12567 children_capacity *= 2;
12568 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12569 if (!children) {
12570 PyErr_Format(PyExc_MemoryError, "realloc None");
12571 return NULL;
12572 }
12573 }
12574 children[n++] = res;
12575 mark = p->mark;
12576 }
12577 p->mark = mark;
12578 }
12579 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12580 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012581 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012582 PyMem_Free(children);
12583 return NULL;
12584 }
12585 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12586 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012587 _PyPegen_insert_memo(p, start_mark, _loop0_41_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012588 return seq;
12589}
12590
Guido van Rossumc001c092020-04-30 12:12:19 -070012591// _gather_40: with_item _loop0_41
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012592static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012593_gather_40_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012594{
12595 if (p->error_indicator) {
12596 return NULL;
12597 }
12598 asdl_seq * res = NULL;
12599 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012600 { // with_item _loop0_41
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012601 withitem_ty elem;
12602 asdl_seq * seq;
12603 if (
12604 (elem = with_item_rule(p))
12605 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012606 (seq = _loop0_41_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012607 )
12608 {
12609 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12610 goto done;
12611 }
12612 p->mark = mark;
12613 }
12614 res = NULL;
12615 done:
12616 return res;
12617}
12618
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012619// _loop0_43: ',' with_item
12620static asdl_seq *
12621_loop0_43_rule(Parser *p)
12622{
12623 if (p->error_indicator) {
12624 return NULL;
12625 }
12626 void *res = NULL;
12627 int mark = p->mark;
12628 int start_mark = p->mark;
12629 void **children = PyMem_Malloc(sizeof(void *));
12630 if (!children) {
12631 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12632 return NULL;
12633 }
12634 ssize_t children_capacity = 1;
12635 ssize_t n = 0;
12636 { // ',' with_item
12637 withitem_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012638 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012639 while (
12640 (literal = _PyPegen_expect_token(p, 12))
12641 &&
12642 (elem = with_item_rule(p))
12643 )
12644 {
12645 res = elem;
12646 if (res == NULL && PyErr_Occurred()) {
12647 p->error_indicator = 1;
12648 PyMem_Free(children);
12649 return NULL;
12650 }
12651 if (n == children_capacity) {
12652 children_capacity *= 2;
12653 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12654 if (!children) {
12655 PyErr_Format(PyExc_MemoryError, "realloc None");
12656 return NULL;
12657 }
12658 }
12659 children[n++] = res;
12660 mark = p->mark;
12661 }
12662 p->mark = mark;
12663 }
12664 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12665 if (!seq) {
12666 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43");
12667 PyMem_Free(children);
12668 return NULL;
12669 }
12670 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12671 PyMem_Free(children);
12672 _PyPegen_insert_memo(p, start_mark, _loop0_43_type, seq);
12673 return seq;
12674}
12675
12676// _gather_42: with_item _loop0_43
12677static asdl_seq *
12678_gather_42_rule(Parser *p)
12679{
12680 if (p->error_indicator) {
12681 return NULL;
12682 }
12683 asdl_seq * res = NULL;
12684 int mark = p->mark;
12685 { // with_item _loop0_43
12686 withitem_ty elem;
12687 asdl_seq * seq;
12688 if (
12689 (elem = with_item_rule(p))
12690 &&
12691 (seq = _loop0_43_rule(p))
12692 )
12693 {
12694 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12695 goto done;
12696 }
12697 p->mark = mark;
12698 }
12699 res = NULL;
12700 done:
12701 return res;
12702}
12703
12704// _loop0_45: ',' with_item
12705static asdl_seq *
12706_loop0_45_rule(Parser *p)
12707{
12708 if (p->error_indicator) {
12709 return NULL;
12710 }
12711 void *res = NULL;
12712 int mark = p->mark;
12713 int start_mark = p->mark;
12714 void **children = PyMem_Malloc(sizeof(void *));
12715 if (!children) {
12716 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12717 return NULL;
12718 }
12719 ssize_t children_capacity = 1;
12720 ssize_t n = 0;
12721 { // ',' with_item
12722 withitem_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012723 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012724 while (
12725 (literal = _PyPegen_expect_token(p, 12))
12726 &&
12727 (elem = with_item_rule(p))
12728 )
12729 {
12730 res = elem;
12731 if (res == NULL && PyErr_Occurred()) {
12732 p->error_indicator = 1;
12733 PyMem_Free(children);
12734 return NULL;
12735 }
12736 if (n == children_capacity) {
12737 children_capacity *= 2;
12738 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12739 if (!children) {
12740 PyErr_Format(PyExc_MemoryError, "realloc None");
12741 return NULL;
12742 }
12743 }
12744 children[n++] = res;
12745 mark = p->mark;
12746 }
12747 p->mark = mark;
12748 }
12749 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12750 if (!seq) {
12751 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45");
12752 PyMem_Free(children);
12753 return NULL;
12754 }
12755 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12756 PyMem_Free(children);
12757 _PyPegen_insert_memo(p, start_mark, _loop0_45_type, seq);
12758 return seq;
12759}
12760
12761// _gather_44: with_item _loop0_45
12762static asdl_seq *
12763_gather_44_rule(Parser *p)
12764{
12765 if (p->error_indicator) {
12766 return NULL;
12767 }
12768 asdl_seq * res = NULL;
12769 int mark = p->mark;
12770 { // with_item _loop0_45
12771 withitem_ty elem;
12772 asdl_seq * seq;
12773 if (
12774 (elem = with_item_rule(p))
12775 &&
12776 (seq = _loop0_45_rule(p))
12777 )
12778 {
12779 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12780 goto done;
12781 }
12782 p->mark = mark;
12783 }
12784 res = NULL;
12785 done:
12786 return res;
12787}
12788
12789// _tmp_46: 'as' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012790static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012791_tmp_46_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012792{
12793 if (p->error_indicator) {
12794 return NULL;
12795 }
12796 void * res = NULL;
12797 int mark = p->mark;
12798 { // 'as' target
Pablo Galindob796b3f2020-05-01 12:32:26 +010012799 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012800 expr_ty t;
12801 if (
12802 (keyword = _PyPegen_expect_token(p, 531))
12803 &&
12804 (t = target_rule(p))
12805 )
12806 {
12807 res = t;
12808 if (res == NULL && PyErr_Occurred()) {
12809 p->error_indicator = 1;
12810 return NULL;
12811 }
12812 goto done;
12813 }
12814 p->mark = mark;
12815 }
12816 res = NULL;
12817 done:
12818 return res;
12819}
12820
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012821// _loop1_47: except_block
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012822static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012823_loop1_47_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012824{
12825 if (p->error_indicator) {
12826 return NULL;
12827 }
12828 void *res = NULL;
12829 int mark = p->mark;
12830 int start_mark = p->mark;
12831 void **children = PyMem_Malloc(sizeof(void *));
12832 if (!children) {
12833 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12834 return NULL;
12835 }
12836 ssize_t children_capacity = 1;
12837 ssize_t n = 0;
12838 { // except_block
12839 excepthandler_ty except_block_var;
12840 while (
12841 (except_block_var = except_block_rule(p))
12842 )
12843 {
12844 res = except_block_var;
12845 if (n == children_capacity) {
12846 children_capacity *= 2;
12847 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12848 if (!children) {
12849 PyErr_Format(PyExc_MemoryError, "realloc None");
12850 return NULL;
12851 }
12852 }
12853 children[n++] = res;
12854 mark = p->mark;
12855 }
12856 p->mark = mark;
12857 }
12858 if (n == 0) {
12859 PyMem_Free(children);
12860 return NULL;
12861 }
12862 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12863 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012864 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012865 PyMem_Free(children);
12866 return NULL;
12867 }
12868 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12869 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012870 _PyPegen_insert_memo(p, start_mark, _loop1_47_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012871 return seq;
12872}
12873
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012874// _tmp_48: 'as' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012875static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012876_tmp_48_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012877{
12878 if (p->error_indicator) {
12879 return NULL;
12880 }
12881 void * res = NULL;
12882 int mark = p->mark;
12883 { // 'as' target
Pablo Galindob796b3f2020-05-01 12:32:26 +010012884 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012885 expr_ty z;
12886 if (
12887 (keyword = _PyPegen_expect_token(p, 531))
12888 &&
12889 (z = target_rule(p))
12890 )
12891 {
12892 res = z;
12893 if (res == NULL && PyErr_Occurred()) {
12894 p->error_indicator = 1;
12895 return NULL;
12896 }
12897 goto done;
12898 }
12899 p->mark = mark;
12900 }
12901 res = NULL;
12902 done:
12903 return res;
12904}
12905
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012906// _tmp_49: 'from' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012907static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012908_tmp_49_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012909{
12910 if (p->error_indicator) {
12911 return NULL;
12912 }
12913 void * res = NULL;
12914 int mark = p->mark;
12915 { // 'from' expression
Pablo Galindob796b3f2020-05-01 12:32:26 +010012916 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012917 expr_ty z;
12918 if (
12919 (keyword = _PyPegen_expect_token(p, 514))
12920 &&
12921 (z = expression_rule(p))
12922 )
12923 {
12924 res = z;
12925 if (res == NULL && PyErr_Occurred()) {
12926 p->error_indicator = 1;
12927 return NULL;
12928 }
12929 goto done;
12930 }
12931 p->mark = mark;
12932 }
12933 res = NULL;
12934 done:
12935 return res;
12936}
12937
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012938// _tmp_50: '->' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012939static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012940_tmp_50_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012941{
12942 if (p->error_indicator) {
12943 return NULL;
12944 }
12945 void * res = NULL;
12946 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012947 { // '->' expression
Pablo Galindob796b3f2020-05-01 12:32:26 +010012948 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070012949 expr_ty z;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012950 if (
Guido van Rossumc001c092020-04-30 12:12:19 -070012951 (literal = _PyPegen_expect_token(p, 51))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012952 &&
Guido van Rossumc001c092020-04-30 12:12:19 -070012953 (z = expression_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012954 )
12955 {
Guido van Rossumc001c092020-04-30 12:12:19 -070012956 res = z;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012957 if (res == NULL && PyErr_Occurred()) {
12958 p->error_indicator = 1;
12959 return NULL;
12960 }
12961 goto done;
12962 }
12963 p->mark = mark;
12964 }
12965 res = NULL;
12966 done:
12967 return res;
12968}
12969
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012970// _tmp_51: '->' expression
Guido van Rossumc001c092020-04-30 12:12:19 -070012971static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012972_tmp_51_rule(Parser *p)
12973{
12974 if (p->error_indicator) {
12975 return NULL;
12976 }
12977 void * res = NULL;
12978 int mark = p->mark;
12979 { // '->' expression
Pablo Galindob796b3f2020-05-01 12:32:26 +010012980 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012981 expr_ty z;
12982 if (
12983 (literal = _PyPegen_expect_token(p, 51))
12984 &&
12985 (z = expression_rule(p))
12986 )
12987 {
12988 res = z;
12989 if (res == NULL && PyErr_Occurred()) {
12990 p->error_indicator = 1;
12991 return NULL;
12992 }
12993 goto done;
12994 }
12995 p->mark = mark;
12996 }
12997 res = NULL;
12998 done:
12999 return res;
13000}
13001
13002// _tmp_52: NEWLINE INDENT
13003static void *
13004_tmp_52_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013005{
13006 if (p->error_indicator) {
13007 return NULL;
13008 }
13009 void * res = NULL;
13010 int mark = p->mark;
13011 { // NEWLINE INDENT
Pablo Galindob796b3f2020-05-01 12:32:26 +010013012 Token * indent_var;
13013 Token * newline_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013014 if (
13015 (newline_var = _PyPegen_expect_token(p, NEWLINE))
13016 &&
13017 (indent_var = _PyPegen_expect_token(p, INDENT))
13018 )
13019 {
13020 res = _PyPegen_dummy_name(p, newline_var, indent_var);
13021 goto done;
13022 }
13023 p->mark = mark;
13024 }
13025 res = NULL;
13026 done:
13027 return res;
13028}
13029
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013030// _loop0_53: param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013031static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013032_loop0_53_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013033{
13034 if (p->error_indicator) {
13035 return NULL;
13036 }
13037 void *res = NULL;
13038 int mark = p->mark;
13039 int start_mark = p->mark;
13040 void **children = PyMem_Malloc(sizeof(void *));
13041 if (!children) {
13042 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13043 return NULL;
13044 }
13045 ssize_t children_capacity = 1;
13046 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013047 { // param_no_default
13048 arg_ty param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013049 while (
Guido van Rossumc001c092020-04-30 12:12:19 -070013050 (param_no_default_var = param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013051 )
13052 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013053 res = param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013054 if (n == children_capacity) {
13055 children_capacity *= 2;
13056 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13057 if (!children) {
13058 PyErr_Format(PyExc_MemoryError, "realloc None");
13059 return NULL;
13060 }
13061 }
13062 children[n++] = res;
13063 mark = p->mark;
13064 }
13065 p->mark = mark;
13066 }
13067 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13068 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013069 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013070 PyMem_Free(children);
13071 return NULL;
13072 }
13073 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13074 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013075 _PyPegen_insert_memo(p, start_mark, _loop0_53_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013076 return seq;
13077}
13078
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013079// _loop0_54: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013080static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013081_loop0_54_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013082{
13083 if (p->error_indicator) {
13084 return NULL;
13085 }
13086 void *res = NULL;
13087 int mark = p->mark;
13088 int start_mark = p->mark;
13089 void **children = PyMem_Malloc(sizeof(void *));
13090 if (!children) {
13091 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13092 return NULL;
13093 }
13094 ssize_t children_capacity = 1;
13095 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013096 { // param_with_default
13097 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013098 while (
Guido van Rossumc001c092020-04-30 12:12:19 -070013099 (param_with_default_var = param_with_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013100 )
13101 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013102 res = param_with_default_var;
13103 if (n == children_capacity) {
13104 children_capacity *= 2;
13105 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13106 if (!children) {
13107 PyErr_Format(PyExc_MemoryError, "realloc None");
13108 return NULL;
13109 }
13110 }
13111 children[n++] = res;
13112 mark = p->mark;
13113 }
13114 p->mark = mark;
13115 }
13116 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13117 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013118 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54");
Guido van Rossumc001c092020-04-30 12:12:19 -070013119 PyMem_Free(children);
13120 return NULL;
13121 }
13122 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13123 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013124 _PyPegen_insert_memo(p, start_mark, _loop0_54_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013125 return seq;
13126}
13127
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013128// _loop0_55: param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013129static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013130_loop0_55_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013131{
13132 if (p->error_indicator) {
13133 return NULL;
13134 }
13135 void *res = NULL;
13136 int mark = p->mark;
13137 int start_mark = p->mark;
13138 void **children = PyMem_Malloc(sizeof(void *));
13139 if (!children) {
13140 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13141 return NULL;
13142 }
13143 ssize_t children_capacity = 1;
13144 ssize_t n = 0;
13145 { // param_with_default
13146 NameDefaultPair* param_with_default_var;
13147 while (
13148 (param_with_default_var = param_with_default_rule(p))
13149 )
13150 {
13151 res = param_with_default_var;
13152 if (n == children_capacity) {
13153 children_capacity *= 2;
13154 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13155 if (!children) {
13156 PyErr_Format(PyExc_MemoryError, "realloc None");
13157 return NULL;
13158 }
13159 }
13160 children[n++] = res;
13161 mark = p->mark;
13162 }
13163 p->mark = mark;
13164 }
13165 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13166 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013167 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55");
Guido van Rossumc001c092020-04-30 12:12:19 -070013168 PyMem_Free(children);
13169 return NULL;
13170 }
13171 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13172 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013173 _PyPegen_insert_memo(p, start_mark, _loop0_55_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013174 return seq;
13175}
13176
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013177// _loop1_56: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013178static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013179_loop1_56_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013180{
13181 if (p->error_indicator) {
13182 return NULL;
13183 }
13184 void *res = NULL;
13185 int mark = p->mark;
13186 int start_mark = p->mark;
13187 void **children = PyMem_Malloc(sizeof(void *));
13188 if (!children) {
13189 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13190 return NULL;
13191 }
13192 ssize_t children_capacity = 1;
13193 ssize_t n = 0;
13194 { // param_no_default
13195 arg_ty param_no_default_var;
13196 while (
13197 (param_no_default_var = param_no_default_rule(p))
13198 )
13199 {
13200 res = param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013201 if (n == children_capacity) {
13202 children_capacity *= 2;
13203 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13204 if (!children) {
13205 PyErr_Format(PyExc_MemoryError, "realloc None");
13206 return NULL;
13207 }
13208 }
13209 children[n++] = res;
13210 mark = p->mark;
13211 }
13212 p->mark = mark;
13213 }
13214 if (n == 0) {
13215 PyMem_Free(children);
13216 return NULL;
13217 }
13218 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13219 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013220 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013221 PyMem_Free(children);
13222 return NULL;
13223 }
13224 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13225 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013226 _PyPegen_insert_memo(p, start_mark, _loop1_56_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013227 return seq;
13228}
13229
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013230// _loop0_57: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013231static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013232_loop0_57_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013233{
13234 if (p->error_indicator) {
13235 return NULL;
13236 }
13237 void *res = NULL;
13238 int mark = p->mark;
13239 int start_mark = p->mark;
13240 void **children = PyMem_Malloc(sizeof(void *));
13241 if (!children) {
13242 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13243 return NULL;
13244 }
13245 ssize_t children_capacity = 1;
13246 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013247 { // param_with_default
13248 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013249 while (
Guido van Rossumc001c092020-04-30 12:12:19 -070013250 (param_with_default_var = param_with_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013251 )
13252 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013253 res = param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013254 if (n == children_capacity) {
13255 children_capacity *= 2;
13256 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13257 if (!children) {
13258 PyErr_Format(PyExc_MemoryError, "realloc None");
13259 return NULL;
13260 }
13261 }
13262 children[n++] = res;
13263 mark = p->mark;
13264 }
13265 p->mark = mark;
13266 }
13267 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13268 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013269 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013270 PyMem_Free(children);
13271 return NULL;
13272 }
13273 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13274 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013275 _PyPegen_insert_memo(p, start_mark, _loop0_57_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013276 return seq;
13277}
13278
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013279// _loop1_58: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013280static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013281_loop1_58_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013282{
13283 if (p->error_indicator) {
13284 return NULL;
13285 }
13286 void *res = NULL;
13287 int mark = p->mark;
13288 int start_mark = p->mark;
13289 void **children = PyMem_Malloc(sizeof(void *));
13290 if (!children) {
13291 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13292 return NULL;
13293 }
13294 ssize_t children_capacity = 1;
13295 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013296 { // param_with_default
13297 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013298 while (
Guido van Rossumc001c092020-04-30 12:12:19 -070013299 (param_with_default_var = param_with_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013300 )
13301 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013302 res = param_with_default_var;
13303 if (n == children_capacity) {
13304 children_capacity *= 2;
13305 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13306 if (!children) {
13307 PyErr_Format(PyExc_MemoryError, "realloc None");
13308 return NULL;
13309 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013310 }
Guido van Rossumc001c092020-04-30 12:12:19 -070013311 children[n++] = res;
13312 mark = p->mark;
13313 }
13314 p->mark = mark;
13315 }
13316 if (n == 0) {
13317 PyMem_Free(children);
13318 return NULL;
13319 }
13320 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13321 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013322 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58");
Guido van Rossumc001c092020-04-30 12:12:19 -070013323 PyMem_Free(children);
13324 return NULL;
13325 }
13326 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13327 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013328 _PyPegen_insert_memo(p, start_mark, _loop1_58_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013329 return seq;
13330}
13331
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013332// _loop1_59: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013333static asdl_seq *
13334_loop1_59_rule(Parser *p)
13335{
13336 if (p->error_indicator) {
13337 return NULL;
13338 }
13339 void *res = NULL;
13340 int mark = p->mark;
13341 int start_mark = p->mark;
13342 void **children = PyMem_Malloc(sizeof(void *));
13343 if (!children) {
13344 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13345 return NULL;
13346 }
13347 ssize_t children_capacity = 1;
13348 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013349 { // param_no_default
13350 arg_ty param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013351 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013352 (param_no_default_var = param_no_default_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070013353 )
13354 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013355 res = param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013356 if (n == children_capacity) {
13357 children_capacity *= 2;
13358 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13359 if (!children) {
13360 PyErr_Format(PyExc_MemoryError, "realloc None");
13361 return NULL;
13362 }
13363 }
13364 children[n++] = res;
13365 mark = p->mark;
13366 }
13367 p->mark = mark;
13368 }
13369 if (n == 0) {
13370 PyMem_Free(children);
13371 return NULL;
13372 }
13373 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13374 if (!seq) {
13375 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59");
13376 PyMem_Free(children);
13377 return NULL;
13378 }
13379 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13380 PyMem_Free(children);
13381 _PyPegen_insert_memo(p, start_mark, _loop1_59_type, seq);
13382 return seq;
13383}
13384
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013385// _loop1_60: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013386static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013387_loop1_60_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013388{
13389 if (p->error_indicator) {
13390 return NULL;
13391 }
13392 void *res = NULL;
13393 int mark = p->mark;
13394 int start_mark = p->mark;
13395 void **children = PyMem_Malloc(sizeof(void *));
13396 if (!children) {
13397 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13398 return NULL;
13399 }
13400 ssize_t children_capacity = 1;
13401 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013402 { // param_no_default
13403 arg_ty param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013404 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013405 (param_no_default_var = param_no_default_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070013406 )
13407 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013408 res = param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013409 if (n == children_capacity) {
13410 children_capacity *= 2;
13411 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13412 if (!children) {
13413 PyErr_Format(PyExc_MemoryError, "realloc None");
13414 return NULL;
13415 }
13416 }
13417 children[n++] = res;
13418 mark = p->mark;
13419 }
13420 p->mark = mark;
13421 }
13422 if (n == 0) {
13423 PyMem_Free(children);
13424 return NULL;
13425 }
13426 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13427 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013428 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60");
Guido van Rossumc001c092020-04-30 12:12:19 -070013429 PyMem_Free(children);
13430 return NULL;
13431 }
13432 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13433 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013434 _PyPegen_insert_memo(p, start_mark, _loop1_60_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013435 return seq;
13436}
13437
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013438// _loop0_61: param_no_default
13439static asdl_seq *
13440_loop0_61_rule(Parser *p)
13441{
13442 if (p->error_indicator) {
13443 return NULL;
13444 }
13445 void *res = NULL;
13446 int mark = p->mark;
13447 int start_mark = p->mark;
13448 void **children = PyMem_Malloc(sizeof(void *));
13449 if (!children) {
13450 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13451 return NULL;
13452 }
13453 ssize_t children_capacity = 1;
13454 ssize_t n = 0;
13455 { // param_no_default
13456 arg_ty param_no_default_var;
13457 while (
13458 (param_no_default_var = param_no_default_rule(p))
13459 )
13460 {
13461 res = param_no_default_var;
13462 if (n == children_capacity) {
13463 children_capacity *= 2;
13464 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13465 if (!children) {
13466 PyErr_Format(PyExc_MemoryError, "realloc None");
13467 return NULL;
13468 }
13469 }
13470 children[n++] = res;
13471 mark = p->mark;
13472 }
13473 p->mark = mark;
13474 }
13475 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13476 if (!seq) {
13477 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61");
13478 PyMem_Free(children);
13479 return NULL;
13480 }
13481 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13482 PyMem_Free(children);
13483 _PyPegen_insert_memo(p, start_mark, _loop0_61_type, seq);
13484 return seq;
13485}
13486
13487// _loop1_62: param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013488static asdl_seq *
13489_loop1_62_rule(Parser *p)
13490{
13491 if (p->error_indicator) {
13492 return NULL;
13493 }
13494 void *res = NULL;
13495 int mark = p->mark;
13496 int start_mark = p->mark;
13497 void **children = PyMem_Malloc(sizeof(void *));
13498 if (!children) {
13499 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13500 return NULL;
13501 }
13502 ssize_t children_capacity = 1;
13503 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013504 { // param_with_default
13505 NameDefaultPair* param_with_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013506 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013507 (param_with_default_var = param_with_default_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070013508 )
13509 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013510 res = param_with_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013511 if (n == children_capacity) {
13512 children_capacity *= 2;
13513 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13514 if (!children) {
13515 PyErr_Format(PyExc_MemoryError, "realloc None");
13516 return NULL;
13517 }
13518 }
13519 children[n++] = res;
13520 mark = p->mark;
13521 }
13522 p->mark = mark;
13523 }
13524 if (n == 0) {
13525 PyMem_Free(children);
13526 return NULL;
13527 }
13528 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13529 if (!seq) {
13530 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62");
13531 PyMem_Free(children);
13532 return NULL;
13533 }
13534 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13535 PyMem_Free(children);
13536 _PyPegen_insert_memo(p, start_mark, _loop1_62_type, seq);
13537 return seq;
13538}
13539
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013540// _loop0_63: param_no_default
13541static asdl_seq *
13542_loop0_63_rule(Parser *p)
13543{
13544 if (p->error_indicator) {
13545 return NULL;
13546 }
13547 void *res = NULL;
13548 int mark = p->mark;
13549 int start_mark = p->mark;
13550 void **children = PyMem_Malloc(sizeof(void *));
13551 if (!children) {
13552 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13553 return NULL;
13554 }
13555 ssize_t children_capacity = 1;
13556 ssize_t n = 0;
13557 { // param_no_default
13558 arg_ty param_no_default_var;
13559 while (
13560 (param_no_default_var = param_no_default_rule(p))
13561 )
13562 {
13563 res = param_no_default_var;
13564 if (n == children_capacity) {
13565 children_capacity *= 2;
13566 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13567 if (!children) {
13568 PyErr_Format(PyExc_MemoryError, "realloc None");
13569 return NULL;
13570 }
13571 }
13572 children[n++] = res;
13573 mark = p->mark;
13574 }
13575 p->mark = mark;
13576 }
13577 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13578 if (!seq) {
13579 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63");
13580 PyMem_Free(children);
13581 return NULL;
13582 }
13583 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13584 PyMem_Free(children);
13585 _PyPegen_insert_memo(p, start_mark, _loop0_63_type, seq);
13586 return seq;
13587}
13588
13589// _loop1_64: param_with_default
13590static asdl_seq *
13591_loop1_64_rule(Parser *p)
13592{
13593 if (p->error_indicator) {
13594 return NULL;
13595 }
13596 void *res = NULL;
13597 int mark = p->mark;
13598 int start_mark = p->mark;
13599 void **children = PyMem_Malloc(sizeof(void *));
13600 if (!children) {
13601 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13602 return NULL;
13603 }
13604 ssize_t children_capacity = 1;
13605 ssize_t n = 0;
13606 { // param_with_default
13607 NameDefaultPair* param_with_default_var;
13608 while (
13609 (param_with_default_var = param_with_default_rule(p))
13610 )
13611 {
13612 res = param_with_default_var;
13613 if (n == children_capacity) {
13614 children_capacity *= 2;
13615 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13616 if (!children) {
13617 PyErr_Format(PyExc_MemoryError, "realloc None");
13618 return NULL;
13619 }
13620 }
13621 children[n++] = res;
13622 mark = p->mark;
13623 }
13624 p->mark = mark;
13625 }
13626 if (n == 0) {
13627 PyMem_Free(children);
13628 return NULL;
13629 }
13630 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13631 if (!seq) {
13632 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64");
13633 PyMem_Free(children);
13634 return NULL;
13635 }
13636 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13637 PyMem_Free(children);
13638 _PyPegen_insert_memo(p, start_mark, _loop1_64_type, seq);
13639 return seq;
13640}
13641
13642// _loop0_65: param_maybe_default
13643static asdl_seq *
13644_loop0_65_rule(Parser *p)
13645{
13646 if (p->error_indicator) {
13647 return NULL;
13648 }
13649 void *res = NULL;
13650 int mark = p->mark;
13651 int start_mark = p->mark;
13652 void **children = PyMem_Malloc(sizeof(void *));
13653 if (!children) {
13654 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13655 return NULL;
13656 }
13657 ssize_t children_capacity = 1;
13658 ssize_t n = 0;
13659 { // param_maybe_default
13660 NameDefaultPair* param_maybe_default_var;
13661 while (
13662 (param_maybe_default_var = param_maybe_default_rule(p))
13663 )
13664 {
13665 res = param_maybe_default_var;
13666 if (n == children_capacity) {
13667 children_capacity *= 2;
13668 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13669 if (!children) {
13670 PyErr_Format(PyExc_MemoryError, "realloc None");
13671 return NULL;
13672 }
13673 }
13674 children[n++] = res;
13675 mark = p->mark;
13676 }
13677 p->mark = mark;
13678 }
13679 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13680 if (!seq) {
13681 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65");
13682 PyMem_Free(children);
13683 return NULL;
13684 }
13685 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13686 PyMem_Free(children);
13687 _PyPegen_insert_memo(p, start_mark, _loop0_65_type, seq);
13688 return seq;
13689}
13690
13691// _loop1_66: param_maybe_default
13692static asdl_seq *
13693_loop1_66_rule(Parser *p)
13694{
13695 if (p->error_indicator) {
13696 return NULL;
13697 }
13698 void *res = NULL;
13699 int mark = p->mark;
13700 int start_mark = p->mark;
13701 void **children = PyMem_Malloc(sizeof(void *));
13702 if (!children) {
13703 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13704 return NULL;
13705 }
13706 ssize_t children_capacity = 1;
13707 ssize_t n = 0;
13708 { // param_maybe_default
13709 NameDefaultPair* param_maybe_default_var;
13710 while (
13711 (param_maybe_default_var = param_maybe_default_rule(p))
13712 )
13713 {
13714 res = param_maybe_default_var;
13715 if (n == children_capacity) {
13716 children_capacity *= 2;
13717 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13718 if (!children) {
13719 PyErr_Format(PyExc_MemoryError, "realloc None");
13720 return NULL;
13721 }
13722 }
13723 children[n++] = res;
13724 mark = p->mark;
13725 }
13726 p->mark = mark;
13727 }
13728 if (n == 0) {
13729 PyMem_Free(children);
13730 return NULL;
13731 }
13732 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13733 if (!seq) {
13734 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66");
13735 PyMem_Free(children);
13736 return NULL;
13737 }
13738 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13739 PyMem_Free(children);
13740 _PyPegen_insert_memo(p, start_mark, _loop1_66_type, seq);
13741 return seq;
13742}
13743
13744// _loop1_67: ('@' named_expression NEWLINE)
13745static asdl_seq *
13746_loop1_67_rule(Parser *p)
13747{
13748 if (p->error_indicator) {
13749 return NULL;
13750 }
13751 void *res = NULL;
13752 int mark = p->mark;
13753 int start_mark = p->mark;
13754 void **children = PyMem_Malloc(sizeof(void *));
13755 if (!children) {
13756 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13757 return NULL;
13758 }
13759 ssize_t children_capacity = 1;
13760 ssize_t n = 0;
13761 { // ('@' named_expression NEWLINE)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013762 void *_tmp_137_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013763 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013764 (_tmp_137_var = _tmp_137_rule(p))
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013765 )
13766 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013767 res = _tmp_137_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013768 if (n == children_capacity) {
13769 children_capacity *= 2;
13770 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13771 if (!children) {
13772 PyErr_Format(PyExc_MemoryError, "realloc None");
13773 return NULL;
13774 }
13775 }
13776 children[n++] = res;
13777 mark = p->mark;
13778 }
13779 p->mark = mark;
13780 }
13781 if (n == 0) {
13782 PyMem_Free(children);
13783 return NULL;
13784 }
13785 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13786 if (!seq) {
13787 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67");
13788 PyMem_Free(children);
13789 return NULL;
13790 }
13791 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13792 PyMem_Free(children);
13793 _PyPegen_insert_memo(p, start_mark, _loop1_67_type, seq);
13794 return seq;
13795}
13796
13797// _tmp_68: '(' arguments? ')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013798static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013799_tmp_68_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013800{
13801 if (p->error_indicator) {
13802 return NULL;
13803 }
13804 void * res = NULL;
13805 int mark = p->mark;
13806 { // '(' arguments? ')'
Pablo Galindob796b3f2020-05-01 12:32:26 +010013807 Token * literal;
13808 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013809 void *z;
13810 if (
13811 (literal = _PyPegen_expect_token(p, 7))
13812 &&
13813 (z = arguments_rule(p), 1)
13814 &&
13815 (literal_1 = _PyPegen_expect_token(p, 8))
13816 )
13817 {
13818 res = z;
13819 if (res == NULL && PyErr_Occurred()) {
13820 p->error_indicator = 1;
13821 return NULL;
13822 }
13823 goto done;
13824 }
13825 p->mark = mark;
13826 }
13827 res = NULL;
13828 done:
13829 return res;
13830}
13831
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013832// _loop0_70: ',' star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013833static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013834_loop0_70_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013835{
13836 if (p->error_indicator) {
13837 return NULL;
13838 }
13839 void *res = NULL;
13840 int mark = p->mark;
13841 int start_mark = p->mark;
13842 void **children = PyMem_Malloc(sizeof(void *));
13843 if (!children) {
13844 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13845 return NULL;
13846 }
13847 ssize_t children_capacity = 1;
13848 ssize_t n = 0;
13849 { // ',' star_expression
13850 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010013851 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013852 while (
13853 (literal = _PyPegen_expect_token(p, 12))
13854 &&
13855 (elem = star_expression_rule(p))
13856 )
13857 {
13858 res = elem;
13859 if (res == NULL && PyErr_Occurred()) {
13860 p->error_indicator = 1;
13861 PyMem_Free(children);
13862 return NULL;
13863 }
13864 if (n == children_capacity) {
13865 children_capacity *= 2;
13866 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13867 if (!children) {
13868 PyErr_Format(PyExc_MemoryError, "realloc None");
13869 return NULL;
13870 }
13871 }
13872 children[n++] = res;
13873 mark = p->mark;
13874 }
13875 p->mark = mark;
13876 }
13877 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13878 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013879 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013880 PyMem_Free(children);
13881 return NULL;
13882 }
13883 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13884 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013885 _PyPegen_insert_memo(p, start_mark, _loop0_70_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013886 return seq;
13887}
13888
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013889// _gather_69: star_expression _loop0_70
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013890static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013891_gather_69_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013892{
13893 if (p->error_indicator) {
13894 return NULL;
13895 }
13896 asdl_seq * res = NULL;
13897 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013898 { // star_expression _loop0_70
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013899 expr_ty elem;
13900 asdl_seq * seq;
13901 if (
13902 (elem = star_expression_rule(p))
13903 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013904 (seq = _loop0_70_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013905 )
13906 {
13907 res = _PyPegen_seq_insert_in_front(p, elem, seq);
13908 goto done;
13909 }
13910 p->mark = mark;
13911 }
13912 res = NULL;
13913 done:
13914 return res;
13915}
13916
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013917// _loop1_71: (',' star_expression)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013918static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013919_loop1_71_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013920{
13921 if (p->error_indicator) {
13922 return NULL;
13923 }
13924 void *res = NULL;
13925 int mark = p->mark;
13926 int start_mark = p->mark;
13927 void **children = PyMem_Malloc(sizeof(void *));
13928 if (!children) {
13929 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13930 return NULL;
13931 }
13932 ssize_t children_capacity = 1;
13933 ssize_t n = 0;
13934 { // (',' star_expression)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013935 void *_tmp_138_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013936 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013937 (_tmp_138_var = _tmp_138_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013938 )
13939 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013940 res = _tmp_138_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013941 if (n == children_capacity) {
13942 children_capacity *= 2;
13943 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13944 if (!children) {
13945 PyErr_Format(PyExc_MemoryError, "realloc None");
13946 return NULL;
13947 }
13948 }
13949 children[n++] = res;
13950 mark = p->mark;
13951 }
13952 p->mark = mark;
13953 }
13954 if (n == 0) {
13955 PyMem_Free(children);
13956 return NULL;
13957 }
13958 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13959 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013960 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013961 PyMem_Free(children);
13962 return NULL;
13963 }
13964 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13965 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013966 _PyPegen_insert_memo(p, start_mark, _loop1_71_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013967 return seq;
13968}
13969
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013970// _loop0_73: ',' star_named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013971static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013972_loop0_73_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013973{
13974 if (p->error_indicator) {
13975 return NULL;
13976 }
13977 void *res = NULL;
13978 int mark = p->mark;
13979 int start_mark = p->mark;
13980 void **children = PyMem_Malloc(sizeof(void *));
13981 if (!children) {
13982 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13983 return NULL;
13984 }
13985 ssize_t children_capacity = 1;
13986 ssize_t n = 0;
13987 { // ',' star_named_expression
13988 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010013989 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013990 while (
13991 (literal = _PyPegen_expect_token(p, 12))
13992 &&
13993 (elem = star_named_expression_rule(p))
13994 )
13995 {
13996 res = elem;
13997 if (res == NULL && PyErr_Occurred()) {
13998 p->error_indicator = 1;
13999 PyMem_Free(children);
14000 return NULL;
14001 }
14002 if (n == children_capacity) {
14003 children_capacity *= 2;
14004 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14005 if (!children) {
14006 PyErr_Format(PyExc_MemoryError, "realloc None");
14007 return NULL;
14008 }
14009 }
14010 children[n++] = res;
14011 mark = p->mark;
14012 }
14013 p->mark = mark;
14014 }
14015 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14016 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014017 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014018 PyMem_Free(children);
14019 return NULL;
14020 }
14021 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14022 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014023 _PyPegen_insert_memo(p, start_mark, _loop0_73_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014024 return seq;
14025}
14026
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014027// _gather_72: star_named_expression _loop0_73
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014028static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014029_gather_72_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014030{
14031 if (p->error_indicator) {
14032 return NULL;
14033 }
14034 asdl_seq * res = NULL;
14035 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014036 { // star_named_expression _loop0_73
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014037 expr_ty elem;
14038 asdl_seq * seq;
14039 if (
14040 (elem = star_named_expression_rule(p))
14041 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014042 (seq = _loop0_73_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014043 )
14044 {
14045 res = _PyPegen_seq_insert_in_front(p, elem, seq);
14046 goto done;
14047 }
14048 p->mark = mark;
14049 }
14050 res = NULL;
14051 done:
14052 return res;
14053}
14054
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014055// _loop1_74: (',' expression)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014056static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014057_loop1_74_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014058{
14059 if (p->error_indicator) {
14060 return NULL;
14061 }
14062 void *res = NULL;
14063 int mark = p->mark;
14064 int start_mark = p->mark;
14065 void **children = PyMem_Malloc(sizeof(void *));
14066 if (!children) {
14067 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14068 return NULL;
14069 }
14070 ssize_t children_capacity = 1;
14071 ssize_t n = 0;
14072 { // (',' expression)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014073 void *_tmp_139_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014074 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014075 (_tmp_139_var = _tmp_139_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014076 )
14077 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014078 res = _tmp_139_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014079 if (n == children_capacity) {
14080 children_capacity *= 2;
14081 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14082 if (!children) {
14083 PyErr_Format(PyExc_MemoryError, "realloc None");
14084 return NULL;
14085 }
14086 }
14087 children[n++] = res;
14088 mark = p->mark;
14089 }
14090 p->mark = mark;
14091 }
14092 if (n == 0) {
14093 PyMem_Free(children);
14094 return NULL;
14095 }
14096 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14097 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014098 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014099 PyMem_Free(children);
14100 return NULL;
14101 }
14102 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14103 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014104 _PyPegen_insert_memo(p, start_mark, _loop1_74_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014105 return seq;
14106}
14107
Guido van Rossum3941d972020-05-01 09:42:03 -070014108// _loop0_75: lambda_param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014109static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014110_loop0_75_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014111{
14112 if (p->error_indicator) {
14113 return NULL;
14114 }
14115 void *res = NULL;
14116 int mark = p->mark;
14117 int start_mark = p->mark;
14118 void **children = PyMem_Malloc(sizeof(void *));
14119 if (!children) {
14120 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14121 return NULL;
14122 }
14123 ssize_t children_capacity = 1;
14124 ssize_t n = 0;
Guido van Rossum3941d972020-05-01 09:42:03 -070014125 { // lambda_param_no_default
14126 arg_ty lambda_param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014127 while (
Guido van Rossum3941d972020-05-01 09:42:03 -070014128 (lambda_param_no_default_var = lambda_param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014129 )
14130 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014131 res = lambda_param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014132 if (n == children_capacity) {
14133 children_capacity *= 2;
14134 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14135 if (!children) {
14136 PyErr_Format(PyExc_MemoryError, "realloc None");
14137 return NULL;
14138 }
14139 }
14140 children[n++] = res;
14141 mark = p->mark;
14142 }
14143 p->mark = mark;
14144 }
14145 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14146 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014147 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014148 PyMem_Free(children);
14149 return NULL;
14150 }
14151 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14152 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014153 _PyPegen_insert_memo(p, start_mark, _loop0_75_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014154 return seq;
14155}
14156
Guido van Rossum3941d972020-05-01 09:42:03 -070014157// _loop0_76: lambda_param_with_default
14158static asdl_seq *
14159_loop0_76_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014160{
14161 if (p->error_indicator) {
14162 return NULL;
14163 }
Guido van Rossum3941d972020-05-01 09:42:03 -070014164 void *res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014165 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070014166 int start_mark = p->mark;
14167 void **children = PyMem_Malloc(sizeof(void *));
14168 if (!children) {
14169 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14170 return NULL;
14171 }
14172 ssize_t children_capacity = 1;
14173 ssize_t n = 0;
14174 { // lambda_param_with_default
14175 NameDefaultPair* lambda_param_with_default_var;
14176 while (
14177 (lambda_param_with_default_var = lambda_param_with_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014178 )
14179 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014180 res = lambda_param_with_default_var;
14181 if (n == children_capacity) {
14182 children_capacity *= 2;
14183 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14184 if (!children) {
14185 PyErr_Format(PyExc_MemoryError, "realloc None");
14186 return NULL;
14187 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014188 }
Guido van Rossum3941d972020-05-01 09:42:03 -070014189 children[n++] = res;
14190 mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014191 }
14192 p->mark = mark;
14193 }
Guido van Rossum3941d972020-05-01 09:42:03 -070014194 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14195 if (!seq) {
14196 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76");
14197 PyMem_Free(children);
14198 return NULL;
14199 }
14200 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14201 PyMem_Free(children);
14202 _PyPegen_insert_memo(p, start_mark, _loop0_76_type, seq);
14203 return seq;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014204}
14205
Guido van Rossum3941d972020-05-01 09:42:03 -070014206// _loop0_77: lambda_param_with_default
14207static asdl_seq *
14208_loop0_77_rule(Parser *p)
14209{
14210 if (p->error_indicator) {
14211 return NULL;
14212 }
14213 void *res = NULL;
14214 int mark = p->mark;
14215 int start_mark = p->mark;
14216 void **children = PyMem_Malloc(sizeof(void *));
14217 if (!children) {
14218 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14219 return NULL;
14220 }
14221 ssize_t children_capacity = 1;
14222 ssize_t n = 0;
14223 { // lambda_param_with_default
14224 NameDefaultPair* lambda_param_with_default_var;
14225 while (
14226 (lambda_param_with_default_var = lambda_param_with_default_rule(p))
14227 )
14228 {
14229 res = lambda_param_with_default_var;
14230 if (n == children_capacity) {
14231 children_capacity *= 2;
14232 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14233 if (!children) {
14234 PyErr_Format(PyExc_MemoryError, "realloc None");
14235 return NULL;
14236 }
14237 }
14238 children[n++] = res;
14239 mark = p->mark;
14240 }
14241 p->mark = mark;
14242 }
14243 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14244 if (!seq) {
14245 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77");
14246 PyMem_Free(children);
14247 return NULL;
14248 }
14249 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14250 PyMem_Free(children);
14251 _PyPegen_insert_memo(p, start_mark, _loop0_77_type, seq);
14252 return seq;
14253}
14254
14255// _loop1_78: lambda_param_no_default
14256static asdl_seq *
14257_loop1_78_rule(Parser *p)
14258{
14259 if (p->error_indicator) {
14260 return NULL;
14261 }
14262 void *res = NULL;
14263 int mark = p->mark;
14264 int start_mark = p->mark;
14265 void **children = PyMem_Malloc(sizeof(void *));
14266 if (!children) {
14267 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14268 return NULL;
14269 }
14270 ssize_t children_capacity = 1;
14271 ssize_t n = 0;
14272 { // lambda_param_no_default
14273 arg_ty lambda_param_no_default_var;
14274 while (
14275 (lambda_param_no_default_var = lambda_param_no_default_rule(p))
14276 )
14277 {
14278 res = lambda_param_no_default_var;
14279 if (n == children_capacity) {
14280 children_capacity *= 2;
14281 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14282 if (!children) {
14283 PyErr_Format(PyExc_MemoryError, "realloc None");
14284 return NULL;
14285 }
14286 }
14287 children[n++] = res;
14288 mark = p->mark;
14289 }
14290 p->mark = mark;
14291 }
14292 if (n == 0) {
14293 PyMem_Free(children);
14294 return NULL;
14295 }
14296 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14297 if (!seq) {
14298 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78");
14299 PyMem_Free(children);
14300 return NULL;
14301 }
14302 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14303 PyMem_Free(children);
14304 _PyPegen_insert_memo(p, start_mark, _loop1_78_type, seq);
14305 return seq;
14306}
14307
14308// _loop0_79: lambda_param_with_default
14309static asdl_seq *
14310_loop0_79_rule(Parser *p)
14311{
14312 if (p->error_indicator) {
14313 return NULL;
14314 }
14315 void *res = NULL;
14316 int mark = p->mark;
14317 int start_mark = p->mark;
14318 void **children = PyMem_Malloc(sizeof(void *));
14319 if (!children) {
14320 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14321 return NULL;
14322 }
14323 ssize_t children_capacity = 1;
14324 ssize_t n = 0;
14325 { // lambda_param_with_default
14326 NameDefaultPair* lambda_param_with_default_var;
14327 while (
14328 (lambda_param_with_default_var = lambda_param_with_default_rule(p))
14329 )
14330 {
14331 res = lambda_param_with_default_var;
14332 if (n == children_capacity) {
14333 children_capacity *= 2;
14334 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14335 if (!children) {
14336 PyErr_Format(PyExc_MemoryError, "realloc None");
14337 return NULL;
14338 }
14339 }
14340 children[n++] = res;
14341 mark = p->mark;
14342 }
14343 p->mark = mark;
14344 }
14345 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14346 if (!seq) {
14347 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79");
14348 PyMem_Free(children);
14349 return NULL;
14350 }
14351 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14352 PyMem_Free(children);
14353 _PyPegen_insert_memo(p, start_mark, _loop0_79_type, seq);
14354 return seq;
14355}
14356
14357// _loop1_80: lambda_param_with_default
14358static asdl_seq *
14359_loop1_80_rule(Parser *p)
14360{
14361 if (p->error_indicator) {
14362 return NULL;
14363 }
14364 void *res = NULL;
14365 int mark = p->mark;
14366 int start_mark = p->mark;
14367 void **children = PyMem_Malloc(sizeof(void *));
14368 if (!children) {
14369 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14370 return NULL;
14371 }
14372 ssize_t children_capacity = 1;
14373 ssize_t n = 0;
14374 { // lambda_param_with_default
14375 NameDefaultPair* lambda_param_with_default_var;
14376 while (
14377 (lambda_param_with_default_var = lambda_param_with_default_rule(p))
14378 )
14379 {
14380 res = lambda_param_with_default_var;
14381 if (n == children_capacity) {
14382 children_capacity *= 2;
14383 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14384 if (!children) {
14385 PyErr_Format(PyExc_MemoryError, "realloc None");
14386 return NULL;
14387 }
14388 }
14389 children[n++] = res;
14390 mark = p->mark;
14391 }
14392 p->mark = mark;
14393 }
14394 if (n == 0) {
14395 PyMem_Free(children);
14396 return NULL;
14397 }
14398 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14399 if (!seq) {
14400 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80");
14401 PyMem_Free(children);
14402 return NULL;
14403 }
14404 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14405 PyMem_Free(children);
14406 _PyPegen_insert_memo(p, start_mark, _loop1_80_type, seq);
14407 return seq;
14408}
14409
14410// _loop1_81: lambda_param_no_default
14411static asdl_seq *
14412_loop1_81_rule(Parser *p)
14413{
14414 if (p->error_indicator) {
14415 return NULL;
14416 }
14417 void *res = NULL;
14418 int mark = p->mark;
14419 int start_mark = p->mark;
14420 void **children = PyMem_Malloc(sizeof(void *));
14421 if (!children) {
14422 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14423 return NULL;
14424 }
14425 ssize_t children_capacity = 1;
14426 ssize_t n = 0;
14427 { // lambda_param_no_default
14428 arg_ty lambda_param_no_default_var;
14429 while (
14430 (lambda_param_no_default_var = lambda_param_no_default_rule(p))
14431 )
14432 {
14433 res = lambda_param_no_default_var;
14434 if (n == children_capacity) {
14435 children_capacity *= 2;
14436 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14437 if (!children) {
14438 PyErr_Format(PyExc_MemoryError, "realloc None");
14439 return NULL;
14440 }
14441 }
14442 children[n++] = res;
14443 mark = p->mark;
14444 }
14445 p->mark = mark;
14446 }
14447 if (n == 0) {
14448 PyMem_Free(children);
14449 return NULL;
14450 }
14451 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14452 if (!seq) {
14453 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81");
14454 PyMem_Free(children);
14455 return NULL;
14456 }
14457 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14458 PyMem_Free(children);
14459 _PyPegen_insert_memo(p, start_mark, _loop1_81_type, seq);
14460 return seq;
14461}
14462
14463// _loop1_82: lambda_param_no_default
14464static asdl_seq *
14465_loop1_82_rule(Parser *p)
14466{
14467 if (p->error_indicator) {
14468 return NULL;
14469 }
14470 void *res = NULL;
14471 int mark = p->mark;
14472 int start_mark = p->mark;
14473 void **children = PyMem_Malloc(sizeof(void *));
14474 if (!children) {
14475 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14476 return NULL;
14477 }
14478 ssize_t children_capacity = 1;
14479 ssize_t n = 0;
14480 { // lambda_param_no_default
14481 arg_ty lambda_param_no_default_var;
14482 while (
14483 (lambda_param_no_default_var = lambda_param_no_default_rule(p))
14484 )
14485 {
14486 res = lambda_param_no_default_var;
14487 if (n == children_capacity) {
14488 children_capacity *= 2;
14489 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14490 if (!children) {
14491 PyErr_Format(PyExc_MemoryError, "realloc None");
14492 return NULL;
14493 }
14494 }
14495 children[n++] = res;
14496 mark = p->mark;
14497 }
14498 p->mark = mark;
14499 }
14500 if (n == 0) {
14501 PyMem_Free(children);
14502 return NULL;
14503 }
14504 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14505 if (!seq) {
14506 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82");
14507 PyMem_Free(children);
14508 return NULL;
14509 }
14510 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14511 PyMem_Free(children);
14512 _PyPegen_insert_memo(p, start_mark, _loop1_82_type, seq);
14513 return seq;
14514}
14515
14516// _loop0_83: lambda_param_no_default
14517static asdl_seq *
14518_loop0_83_rule(Parser *p)
14519{
14520 if (p->error_indicator) {
14521 return NULL;
14522 }
14523 void *res = NULL;
14524 int mark = p->mark;
14525 int start_mark = p->mark;
14526 void **children = PyMem_Malloc(sizeof(void *));
14527 if (!children) {
14528 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14529 return NULL;
14530 }
14531 ssize_t children_capacity = 1;
14532 ssize_t n = 0;
14533 { // lambda_param_no_default
14534 arg_ty lambda_param_no_default_var;
14535 while (
14536 (lambda_param_no_default_var = lambda_param_no_default_rule(p))
14537 )
14538 {
14539 res = lambda_param_no_default_var;
14540 if (n == children_capacity) {
14541 children_capacity *= 2;
14542 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14543 if (!children) {
14544 PyErr_Format(PyExc_MemoryError, "realloc None");
14545 return NULL;
14546 }
14547 }
14548 children[n++] = res;
14549 mark = p->mark;
14550 }
14551 p->mark = mark;
14552 }
14553 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14554 if (!seq) {
14555 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83");
14556 PyMem_Free(children);
14557 return NULL;
14558 }
14559 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14560 PyMem_Free(children);
14561 _PyPegen_insert_memo(p, start_mark, _loop0_83_type, seq);
14562 return seq;
14563}
14564
14565// _loop1_84: lambda_param_with_default
14566static asdl_seq *
14567_loop1_84_rule(Parser *p)
14568{
14569 if (p->error_indicator) {
14570 return NULL;
14571 }
14572 void *res = NULL;
14573 int mark = p->mark;
14574 int start_mark = p->mark;
14575 void **children = PyMem_Malloc(sizeof(void *));
14576 if (!children) {
14577 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14578 return NULL;
14579 }
14580 ssize_t children_capacity = 1;
14581 ssize_t n = 0;
14582 { // lambda_param_with_default
14583 NameDefaultPair* lambda_param_with_default_var;
14584 while (
14585 (lambda_param_with_default_var = lambda_param_with_default_rule(p))
14586 )
14587 {
14588 res = lambda_param_with_default_var;
14589 if (n == children_capacity) {
14590 children_capacity *= 2;
14591 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14592 if (!children) {
14593 PyErr_Format(PyExc_MemoryError, "realloc None");
14594 return NULL;
14595 }
14596 }
14597 children[n++] = res;
14598 mark = p->mark;
14599 }
14600 p->mark = mark;
14601 }
14602 if (n == 0) {
14603 PyMem_Free(children);
14604 return NULL;
14605 }
14606 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14607 if (!seq) {
14608 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84");
14609 PyMem_Free(children);
14610 return NULL;
14611 }
14612 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14613 PyMem_Free(children);
14614 _PyPegen_insert_memo(p, start_mark, _loop1_84_type, seq);
14615 return seq;
14616}
14617
14618// _loop0_85: lambda_param_no_default
14619static asdl_seq *
14620_loop0_85_rule(Parser *p)
14621{
14622 if (p->error_indicator) {
14623 return NULL;
14624 }
14625 void *res = NULL;
14626 int mark = p->mark;
14627 int start_mark = p->mark;
14628 void **children = PyMem_Malloc(sizeof(void *));
14629 if (!children) {
14630 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14631 return NULL;
14632 }
14633 ssize_t children_capacity = 1;
14634 ssize_t n = 0;
14635 { // lambda_param_no_default
14636 arg_ty lambda_param_no_default_var;
14637 while (
14638 (lambda_param_no_default_var = lambda_param_no_default_rule(p))
14639 )
14640 {
14641 res = lambda_param_no_default_var;
14642 if (n == children_capacity) {
14643 children_capacity *= 2;
14644 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14645 if (!children) {
14646 PyErr_Format(PyExc_MemoryError, "realloc None");
14647 return NULL;
14648 }
14649 }
14650 children[n++] = res;
14651 mark = p->mark;
14652 }
14653 p->mark = mark;
14654 }
14655 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14656 if (!seq) {
14657 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85");
14658 PyMem_Free(children);
14659 return NULL;
14660 }
14661 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14662 PyMem_Free(children);
14663 _PyPegen_insert_memo(p, start_mark, _loop0_85_type, seq);
14664 return seq;
14665}
14666
14667// _loop1_86: lambda_param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014668static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014669_loop1_86_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014670{
14671 if (p->error_indicator) {
14672 return NULL;
14673 }
14674 void *res = NULL;
14675 int mark = p->mark;
14676 int start_mark = p->mark;
14677 void **children = PyMem_Malloc(sizeof(void *));
14678 if (!children) {
14679 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14680 return NULL;
14681 }
14682 ssize_t children_capacity = 1;
14683 ssize_t n = 0;
Guido van Rossum3941d972020-05-01 09:42:03 -070014684 { // lambda_param_with_default
14685 NameDefaultPair* lambda_param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014686 while (
Guido van Rossum3941d972020-05-01 09:42:03 -070014687 (lambda_param_with_default_var = lambda_param_with_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014688 )
14689 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014690 res = lambda_param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014691 if (n == children_capacity) {
14692 children_capacity *= 2;
14693 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14694 if (!children) {
14695 PyErr_Format(PyExc_MemoryError, "realloc None");
14696 return NULL;
14697 }
14698 }
14699 children[n++] = res;
14700 mark = p->mark;
14701 }
14702 p->mark = mark;
14703 }
14704 if (n == 0) {
14705 PyMem_Free(children);
14706 return NULL;
14707 }
14708 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14709 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014710 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014711 PyMem_Free(children);
14712 return NULL;
14713 }
14714 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14715 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014716 _PyPegen_insert_memo(p, start_mark, _loop1_86_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014717 return seq;
14718}
14719
Guido van Rossum3941d972020-05-01 09:42:03 -070014720// _loop0_87: lambda_param_maybe_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014721static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014722_loop0_87_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014723{
14724 if (p->error_indicator) {
14725 return NULL;
14726 }
14727 void *res = NULL;
14728 int mark = p->mark;
14729 int start_mark = p->mark;
14730 void **children = PyMem_Malloc(sizeof(void *));
14731 if (!children) {
14732 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14733 return NULL;
14734 }
14735 ssize_t children_capacity = 1;
14736 ssize_t n = 0;
Guido van Rossum3941d972020-05-01 09:42:03 -070014737 { // lambda_param_maybe_default
14738 NameDefaultPair* lambda_param_maybe_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014739 while (
Guido van Rossum3941d972020-05-01 09:42:03 -070014740 (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014741 )
14742 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014743 res = lambda_param_maybe_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014744 if (n == children_capacity) {
14745 children_capacity *= 2;
14746 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14747 if (!children) {
14748 PyErr_Format(PyExc_MemoryError, "realloc None");
14749 return NULL;
14750 }
14751 }
14752 children[n++] = res;
14753 mark = p->mark;
14754 }
14755 p->mark = mark;
14756 }
14757 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14758 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014759 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014760 PyMem_Free(children);
14761 return NULL;
14762 }
14763 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14764 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014765 _PyPegen_insert_memo(p, start_mark, _loop0_87_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014766 return seq;
14767}
14768
Guido van Rossum3941d972020-05-01 09:42:03 -070014769// _loop1_88: lambda_param_maybe_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014770static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014771_loop1_88_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014772{
14773 if (p->error_indicator) {
14774 return NULL;
14775 }
14776 void *res = NULL;
14777 int mark = p->mark;
14778 int start_mark = p->mark;
14779 void **children = PyMem_Malloc(sizeof(void *));
14780 if (!children) {
14781 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14782 return NULL;
14783 }
14784 ssize_t children_capacity = 1;
14785 ssize_t n = 0;
Guido van Rossum3941d972020-05-01 09:42:03 -070014786 { // lambda_param_maybe_default
14787 NameDefaultPair* lambda_param_maybe_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014788 while (
Guido van Rossum3941d972020-05-01 09:42:03 -070014789 (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014790 )
14791 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014792 res = lambda_param_maybe_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014793 if (n == children_capacity) {
14794 children_capacity *= 2;
14795 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14796 if (!children) {
14797 PyErr_Format(PyExc_MemoryError, "realloc None");
14798 return NULL;
14799 }
14800 }
14801 children[n++] = res;
14802 mark = p->mark;
14803 }
14804 p->mark = mark;
14805 }
Guido van Rossum3941d972020-05-01 09:42:03 -070014806 if (n == 0) {
14807 PyMem_Free(children);
14808 return NULL;
14809 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014810 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14811 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014812 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014813 PyMem_Free(children);
14814 return NULL;
14815 }
14816 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14817 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014818 _PyPegen_insert_memo(p, start_mark, _loop1_88_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014819 return seq;
14820}
14821
Guido van Rossum3941d972020-05-01 09:42:03 -070014822// _loop1_89: ('or' conjunction)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014823static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014824_loop1_89_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014825{
14826 if (p->error_indicator) {
14827 return NULL;
14828 }
14829 void *res = NULL;
14830 int mark = p->mark;
14831 int start_mark = p->mark;
14832 void **children = PyMem_Malloc(sizeof(void *));
14833 if (!children) {
14834 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14835 return NULL;
14836 }
14837 ssize_t children_capacity = 1;
14838 ssize_t n = 0;
14839 { // ('or' conjunction)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014840 void *_tmp_140_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014841 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014842 (_tmp_140_var = _tmp_140_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014843 )
14844 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014845 res = _tmp_140_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014846 if (n == children_capacity) {
14847 children_capacity *= 2;
14848 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14849 if (!children) {
14850 PyErr_Format(PyExc_MemoryError, "realloc None");
14851 return NULL;
14852 }
14853 }
14854 children[n++] = res;
14855 mark = p->mark;
14856 }
14857 p->mark = mark;
14858 }
14859 if (n == 0) {
14860 PyMem_Free(children);
14861 return NULL;
14862 }
14863 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14864 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014865 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014866 PyMem_Free(children);
14867 return NULL;
14868 }
14869 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14870 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014871 _PyPegen_insert_memo(p, start_mark, _loop1_89_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014872 return seq;
14873}
14874
Guido van Rossum3941d972020-05-01 09:42:03 -070014875// _loop1_90: ('and' inversion)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014876static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014877_loop1_90_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014878{
14879 if (p->error_indicator) {
14880 return NULL;
14881 }
14882 void *res = NULL;
14883 int mark = p->mark;
14884 int start_mark = p->mark;
14885 void **children = PyMem_Malloc(sizeof(void *));
14886 if (!children) {
14887 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14888 return NULL;
14889 }
14890 ssize_t children_capacity = 1;
14891 ssize_t n = 0;
14892 { // ('and' inversion)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014893 void *_tmp_141_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014894 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014895 (_tmp_141_var = _tmp_141_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014896 )
14897 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014898 res = _tmp_141_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014899 if (n == children_capacity) {
14900 children_capacity *= 2;
14901 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14902 if (!children) {
14903 PyErr_Format(PyExc_MemoryError, "realloc None");
14904 return NULL;
14905 }
14906 }
14907 children[n++] = res;
14908 mark = p->mark;
14909 }
14910 p->mark = mark;
14911 }
14912 if (n == 0) {
14913 PyMem_Free(children);
14914 return NULL;
14915 }
14916 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14917 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014918 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014919 PyMem_Free(children);
14920 return NULL;
14921 }
14922 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14923 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014924 _PyPegen_insert_memo(p, start_mark, _loop1_90_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014925 return seq;
14926}
14927
Guido van Rossum3941d972020-05-01 09:42:03 -070014928// _loop1_91: compare_op_bitwise_or_pair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014929static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014930_loop1_91_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014931{
14932 if (p->error_indicator) {
14933 return NULL;
14934 }
14935 void *res = NULL;
14936 int mark = p->mark;
14937 int start_mark = p->mark;
14938 void **children = PyMem_Malloc(sizeof(void *));
14939 if (!children) {
14940 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14941 return NULL;
14942 }
14943 ssize_t children_capacity = 1;
14944 ssize_t n = 0;
14945 { // compare_op_bitwise_or_pair
14946 CmpopExprPair* compare_op_bitwise_or_pair_var;
14947 while (
14948 (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p))
14949 )
14950 {
14951 res = compare_op_bitwise_or_pair_var;
14952 if (n == children_capacity) {
14953 children_capacity *= 2;
14954 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14955 if (!children) {
14956 PyErr_Format(PyExc_MemoryError, "realloc None");
14957 return NULL;
14958 }
14959 }
14960 children[n++] = res;
14961 mark = p->mark;
14962 }
14963 p->mark = mark;
14964 }
14965 if (n == 0) {
14966 PyMem_Free(children);
14967 return NULL;
14968 }
14969 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14970 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014971 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014972 PyMem_Free(children);
14973 return NULL;
14974 }
14975 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14976 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014977 _PyPegen_insert_memo(p, start_mark, _loop1_91_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014978 return seq;
14979}
14980
Guido van Rossum3941d972020-05-01 09:42:03 -070014981// _tmp_92: '!='
Pablo Galindo2b74c832020-04-27 18:02:07 +010014982static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070014983_tmp_92_rule(Parser *p)
Pablo Galindo2b74c832020-04-27 18:02:07 +010014984{
14985 if (p->error_indicator) {
14986 return NULL;
14987 }
14988 void * res = NULL;
14989 int mark = p->mark;
14990 { // '!='
Pablo Galindob796b3f2020-05-01 12:32:26 +010014991 Token * tok;
Pablo Galindo2b74c832020-04-27 18:02:07 +010014992 if (
14993 (tok = _PyPegen_expect_token(p, 28))
14994 )
14995 {
14996 res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok;
14997 if (res == NULL && PyErr_Occurred()) {
14998 p->error_indicator = 1;
14999 return NULL;
15000 }
15001 goto done;
15002 }
15003 p->mark = mark;
15004 }
15005 res = NULL;
15006 done:
15007 return res;
15008}
15009
Guido van Rossum3941d972020-05-01 09:42:03 -070015010// _loop0_94: ',' slice
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015011static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015012_loop0_94_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015013{
15014 if (p->error_indicator) {
15015 return NULL;
15016 }
15017 void *res = NULL;
15018 int mark = p->mark;
15019 int start_mark = p->mark;
15020 void **children = PyMem_Malloc(sizeof(void *));
15021 if (!children) {
15022 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15023 return NULL;
15024 }
15025 ssize_t children_capacity = 1;
15026 ssize_t n = 0;
15027 { // ',' slice
15028 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015029 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015030 while (
15031 (literal = _PyPegen_expect_token(p, 12))
15032 &&
15033 (elem = slice_rule(p))
15034 )
15035 {
15036 res = elem;
15037 if (res == NULL && PyErr_Occurred()) {
15038 p->error_indicator = 1;
15039 PyMem_Free(children);
15040 return NULL;
15041 }
15042 if (n == children_capacity) {
15043 children_capacity *= 2;
15044 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15045 if (!children) {
15046 PyErr_Format(PyExc_MemoryError, "realloc None");
15047 return NULL;
15048 }
15049 }
15050 children[n++] = res;
15051 mark = p->mark;
15052 }
15053 p->mark = mark;
15054 }
15055 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15056 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015057 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015058 PyMem_Free(children);
15059 return NULL;
15060 }
15061 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15062 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015063 _PyPegen_insert_memo(p, start_mark, _loop0_94_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015064 return seq;
15065}
15066
Guido van Rossum3941d972020-05-01 09:42:03 -070015067// _gather_93: slice _loop0_94
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015068static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015069_gather_93_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015070{
15071 if (p->error_indicator) {
15072 return NULL;
15073 }
15074 asdl_seq * res = NULL;
15075 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070015076 { // slice _loop0_94
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015077 expr_ty elem;
15078 asdl_seq * seq;
15079 if (
15080 (elem = slice_rule(p))
15081 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070015082 (seq = _loop0_94_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015083 )
15084 {
15085 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15086 goto done;
15087 }
15088 p->mark = mark;
15089 }
15090 res = NULL;
15091 done:
15092 return res;
15093}
15094
Guido van Rossum3941d972020-05-01 09:42:03 -070015095// _tmp_95: ':' expression?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015096static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015097_tmp_95_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015098{
15099 if (p->error_indicator) {
15100 return NULL;
15101 }
15102 void * res = NULL;
15103 int mark = p->mark;
15104 { // ':' expression?
15105 void *d;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015106 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015107 if (
15108 (literal = _PyPegen_expect_token(p, 11))
15109 &&
15110 (d = expression_rule(p), 1)
15111 )
15112 {
15113 res = d;
15114 if (res == NULL && PyErr_Occurred()) {
15115 p->error_indicator = 1;
15116 return NULL;
15117 }
15118 goto done;
15119 }
15120 p->mark = mark;
15121 }
15122 res = NULL;
15123 done:
15124 return res;
15125}
15126
Guido van Rossum3941d972020-05-01 09:42:03 -070015127// _tmp_96: tuple | group | genexp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015128static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015129_tmp_96_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015130{
15131 if (p->error_indicator) {
15132 return NULL;
15133 }
15134 void * res = NULL;
15135 int mark = p->mark;
15136 { // tuple
15137 expr_ty tuple_var;
15138 if (
15139 (tuple_var = tuple_rule(p))
15140 )
15141 {
15142 res = tuple_var;
15143 goto done;
15144 }
15145 p->mark = mark;
15146 }
15147 { // group
15148 expr_ty group_var;
15149 if (
15150 (group_var = group_rule(p))
15151 )
15152 {
15153 res = group_var;
15154 goto done;
15155 }
15156 p->mark = mark;
15157 }
15158 { // genexp
15159 expr_ty genexp_var;
15160 if (
15161 (genexp_var = genexp_rule(p))
15162 )
15163 {
15164 res = genexp_var;
15165 goto done;
15166 }
15167 p->mark = mark;
15168 }
15169 res = NULL;
15170 done:
15171 return res;
15172}
15173
Guido van Rossum3941d972020-05-01 09:42:03 -070015174// _tmp_97: list | listcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015175static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015176_tmp_97_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015177{
15178 if (p->error_indicator) {
15179 return NULL;
15180 }
15181 void * res = NULL;
15182 int mark = p->mark;
15183 { // list
15184 expr_ty list_var;
15185 if (
15186 (list_var = list_rule(p))
15187 )
15188 {
15189 res = list_var;
15190 goto done;
15191 }
15192 p->mark = mark;
15193 }
15194 { // listcomp
15195 expr_ty listcomp_var;
15196 if (
15197 (listcomp_var = listcomp_rule(p))
15198 )
15199 {
15200 res = listcomp_var;
15201 goto done;
15202 }
15203 p->mark = mark;
15204 }
15205 res = NULL;
15206 done:
15207 return res;
15208}
15209
Guido van Rossum3941d972020-05-01 09:42:03 -070015210// _tmp_98: dict | set | dictcomp | setcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015211static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015212_tmp_98_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015213{
15214 if (p->error_indicator) {
15215 return NULL;
15216 }
15217 void * res = NULL;
15218 int mark = p->mark;
15219 { // dict
15220 expr_ty dict_var;
15221 if (
15222 (dict_var = dict_rule(p))
15223 )
15224 {
15225 res = dict_var;
15226 goto done;
15227 }
15228 p->mark = mark;
15229 }
15230 { // set
15231 expr_ty set_var;
15232 if (
15233 (set_var = set_rule(p))
15234 )
15235 {
15236 res = set_var;
15237 goto done;
15238 }
15239 p->mark = mark;
15240 }
15241 { // dictcomp
15242 expr_ty dictcomp_var;
15243 if (
15244 (dictcomp_var = dictcomp_rule(p))
15245 )
15246 {
15247 res = dictcomp_var;
15248 goto done;
15249 }
15250 p->mark = mark;
15251 }
15252 { // setcomp
15253 expr_ty setcomp_var;
15254 if (
15255 (setcomp_var = setcomp_rule(p))
15256 )
15257 {
15258 res = setcomp_var;
15259 goto done;
15260 }
15261 p->mark = mark;
15262 }
15263 res = NULL;
15264 done:
15265 return res;
15266}
15267
Guido van Rossum3941d972020-05-01 09:42:03 -070015268// _loop1_99: STRING
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015269static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015270_loop1_99_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015271{
15272 if (p->error_indicator) {
15273 return NULL;
15274 }
15275 void *res = NULL;
15276 int mark = p->mark;
15277 int start_mark = p->mark;
15278 void **children = PyMem_Malloc(sizeof(void *));
15279 if (!children) {
15280 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15281 return NULL;
15282 }
15283 ssize_t children_capacity = 1;
15284 ssize_t n = 0;
15285 { // STRING
15286 expr_ty string_var;
15287 while (
15288 (string_var = _PyPegen_string_token(p))
15289 )
15290 {
15291 res = string_var;
15292 if (n == children_capacity) {
15293 children_capacity *= 2;
15294 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15295 if (!children) {
15296 PyErr_Format(PyExc_MemoryError, "realloc None");
15297 return NULL;
15298 }
15299 }
15300 children[n++] = res;
15301 mark = p->mark;
15302 }
15303 p->mark = mark;
15304 }
15305 if (n == 0) {
15306 PyMem_Free(children);
15307 return NULL;
15308 }
15309 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15310 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015311 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015312 PyMem_Free(children);
15313 return NULL;
15314 }
15315 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15316 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015317 _PyPegen_insert_memo(p, start_mark, _loop1_99_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015318 return seq;
15319}
15320
Guido van Rossum3941d972020-05-01 09:42:03 -070015321// _tmp_100: star_named_expression ',' star_named_expressions?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015322static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015323_tmp_100_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015324{
15325 if (p->error_indicator) {
15326 return NULL;
15327 }
15328 void * res = NULL;
15329 int mark = p->mark;
15330 { // star_named_expression ',' star_named_expressions?
Pablo Galindob796b3f2020-05-01 12:32:26 +010015331 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015332 expr_ty y;
15333 void *z;
15334 if (
15335 (y = star_named_expression_rule(p))
15336 &&
15337 (literal = _PyPegen_expect_token(p, 12))
15338 &&
15339 (z = star_named_expressions_rule(p), 1)
15340 )
15341 {
15342 res = _PyPegen_seq_insert_in_front ( p , y , z );
15343 if (res == NULL && PyErr_Occurred()) {
15344 p->error_indicator = 1;
15345 return NULL;
15346 }
15347 goto done;
15348 }
15349 p->mark = mark;
15350 }
15351 res = NULL;
15352 done:
15353 return res;
15354}
15355
Guido van Rossum3941d972020-05-01 09:42:03 -070015356// _tmp_101: yield_expr | named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015357static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015358_tmp_101_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015359{
15360 if (p->error_indicator) {
15361 return NULL;
15362 }
15363 void * res = NULL;
15364 int mark = p->mark;
15365 { // yield_expr
15366 expr_ty yield_expr_var;
15367 if (
15368 (yield_expr_var = yield_expr_rule(p))
15369 )
15370 {
15371 res = yield_expr_var;
15372 goto done;
15373 }
15374 p->mark = mark;
15375 }
15376 { // named_expression
15377 expr_ty named_expression_var;
15378 if (
15379 (named_expression_var = named_expression_rule(p))
15380 )
15381 {
15382 res = named_expression_var;
15383 goto done;
15384 }
15385 p->mark = mark;
15386 }
15387 res = NULL;
15388 done:
15389 return res;
15390}
15391
Guido van Rossum3941d972020-05-01 09:42:03 -070015392// _loop0_103: ',' kvpair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015393static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015394_loop0_103_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015395{
15396 if (p->error_indicator) {
15397 return NULL;
15398 }
15399 void *res = NULL;
15400 int mark = p->mark;
15401 int start_mark = p->mark;
15402 void **children = PyMem_Malloc(sizeof(void *));
15403 if (!children) {
15404 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15405 return NULL;
15406 }
15407 ssize_t children_capacity = 1;
15408 ssize_t n = 0;
15409 { // ',' kvpair
15410 KeyValuePair* elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015411 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015412 while (
15413 (literal = _PyPegen_expect_token(p, 12))
15414 &&
15415 (elem = kvpair_rule(p))
15416 )
15417 {
15418 res = elem;
15419 if (res == NULL && PyErr_Occurred()) {
15420 p->error_indicator = 1;
15421 PyMem_Free(children);
15422 return NULL;
15423 }
15424 if (n == children_capacity) {
15425 children_capacity *= 2;
15426 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15427 if (!children) {
15428 PyErr_Format(PyExc_MemoryError, "realloc None");
15429 return NULL;
15430 }
15431 }
15432 children[n++] = res;
15433 mark = p->mark;
15434 }
15435 p->mark = mark;
15436 }
15437 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15438 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015439 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015440 PyMem_Free(children);
15441 return NULL;
15442 }
15443 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15444 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015445 _PyPegen_insert_memo(p, start_mark, _loop0_103_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015446 return seq;
15447}
15448
Guido van Rossum3941d972020-05-01 09:42:03 -070015449// _gather_102: kvpair _loop0_103
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015450static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015451_gather_102_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015452{
15453 if (p->error_indicator) {
15454 return NULL;
15455 }
15456 asdl_seq * res = NULL;
15457 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070015458 { // kvpair _loop0_103
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015459 KeyValuePair* elem;
15460 asdl_seq * seq;
15461 if (
15462 (elem = kvpair_rule(p))
15463 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070015464 (seq = _loop0_103_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015465 )
15466 {
15467 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15468 goto done;
15469 }
15470 p->mark = mark;
15471 }
15472 res = NULL;
15473 done:
15474 return res;
15475}
15476
Guido van Rossum3941d972020-05-01 09:42:03 -070015477// _loop1_104: for_if_clause
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015478static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015479_loop1_104_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015480{
15481 if (p->error_indicator) {
15482 return NULL;
15483 }
15484 void *res = NULL;
15485 int mark = p->mark;
15486 int start_mark = p->mark;
15487 void **children = PyMem_Malloc(sizeof(void *));
15488 if (!children) {
15489 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15490 return NULL;
15491 }
15492 ssize_t children_capacity = 1;
15493 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015494 { // for_if_clause
15495 comprehension_ty for_if_clause_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015496 while (
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015497 (for_if_clause_var = for_if_clause_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015498 )
15499 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015500 res = for_if_clause_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015501 if (n == children_capacity) {
15502 children_capacity *= 2;
15503 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15504 if (!children) {
15505 PyErr_Format(PyExc_MemoryError, "realloc None");
15506 return NULL;
15507 }
15508 }
15509 children[n++] = res;
15510 mark = p->mark;
15511 }
15512 p->mark = mark;
15513 }
15514 if (n == 0) {
15515 PyMem_Free(children);
15516 return NULL;
15517 }
15518 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15519 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015520 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015521 PyMem_Free(children);
15522 return NULL;
15523 }
15524 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15525 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015526 _PyPegen_insert_memo(p, start_mark, _loop1_104_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015527 return seq;
15528}
15529
Guido van Rossum3941d972020-05-01 09:42:03 -070015530// _loop0_105: ('if' disjunction)
Pablo Galindo2b74c832020-04-27 18:02:07 +010015531static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015532_loop0_105_rule(Parser *p)
Pablo Galindo2b74c832020-04-27 18:02:07 +010015533{
15534 if (p->error_indicator) {
15535 return NULL;
15536 }
15537 void *res = NULL;
15538 int mark = p->mark;
15539 int start_mark = p->mark;
15540 void **children = PyMem_Malloc(sizeof(void *));
15541 if (!children) {
15542 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15543 return NULL;
15544 }
15545 ssize_t children_capacity = 1;
15546 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015547 { // ('if' disjunction)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015548 void *_tmp_142_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +010015549 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015550 (_tmp_142_var = _tmp_142_rule(p))
Pablo Galindo2b74c832020-04-27 18:02:07 +010015551 )
15552 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015553 res = _tmp_142_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +010015554 if (n == children_capacity) {
15555 children_capacity *= 2;
15556 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15557 if (!children) {
15558 PyErr_Format(PyExc_MemoryError, "realloc None");
15559 return NULL;
15560 }
15561 }
15562 children[n++] = res;
15563 mark = p->mark;
15564 }
15565 p->mark = mark;
15566 }
15567 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15568 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015569 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105");
Pablo Galindo2b74c832020-04-27 18:02:07 +010015570 PyMem_Free(children);
15571 return NULL;
15572 }
15573 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15574 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015575 _PyPegen_insert_memo(p, start_mark, _loop0_105_type, seq);
Pablo Galindo2b74c832020-04-27 18:02:07 +010015576 return seq;
15577}
15578
Guido van Rossum3941d972020-05-01 09:42:03 -070015579// _loop0_106: ('if' disjunction)
Guido van Rossumc001c092020-04-30 12:12:19 -070015580static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015581_loop0_106_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015582{
15583 if (p->error_indicator) {
15584 return NULL;
15585 }
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015586 void *res = NULL;
Guido van Rossumc001c092020-04-30 12:12:19 -070015587 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015588 int start_mark = p->mark;
15589 void **children = PyMem_Malloc(sizeof(void *));
15590 if (!children) {
15591 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15592 return NULL;
15593 }
15594 ssize_t children_capacity = 1;
15595 ssize_t n = 0;
15596 { // ('if' disjunction)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015597 void *_tmp_143_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015598 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015599 (_tmp_143_var = _tmp_143_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070015600 )
15601 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015602 res = _tmp_143_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015603 if (n == children_capacity) {
15604 children_capacity *= 2;
15605 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15606 if (!children) {
15607 PyErr_Format(PyExc_MemoryError, "realloc None");
15608 return NULL;
15609 }
15610 }
15611 children[n++] = res;
15612 mark = p->mark;
15613 }
15614 p->mark = mark;
15615 }
15616 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15617 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015618 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106");
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015619 PyMem_Free(children);
15620 return NULL;
15621 }
15622 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15623 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015624 _PyPegen_insert_memo(p, start_mark, _loop0_106_type, seq);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015625 return seq;
15626}
15627
Guido van Rossum3941d972020-05-01 09:42:03 -070015628// _tmp_107: ',' args
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015629static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015630_tmp_107_rule(Parser *p)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015631{
15632 if (p->error_indicator) {
15633 return NULL;
15634 }
15635 void * res = NULL;
15636 int mark = p->mark;
15637 { // ',' args
15638 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015639 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015640 if (
15641 (literal = _PyPegen_expect_token(p, 12))
15642 &&
15643 (c = args_rule(p))
15644 )
15645 {
15646 res = c;
15647 if (res == NULL && PyErr_Occurred()) {
15648 p->error_indicator = 1;
15649 return NULL;
15650 }
Guido van Rossumc001c092020-04-30 12:12:19 -070015651 goto done;
15652 }
15653 p->mark = mark;
15654 }
15655 res = NULL;
15656 done:
15657 return res;
15658}
15659
Guido van Rossum3941d972020-05-01 09:42:03 -070015660// _tmp_108: ',' args
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015661static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015662_tmp_108_rule(Parser *p)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015663{
15664 if (p->error_indicator) {
15665 return NULL;
15666 }
15667 void * res = NULL;
15668 int mark = p->mark;
15669 { // ',' args
15670 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015671 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015672 if (
15673 (literal = _PyPegen_expect_token(p, 12))
15674 &&
15675 (c = args_rule(p))
15676 )
15677 {
15678 res = c;
15679 if (res == NULL && PyErr_Occurred()) {
15680 p->error_indicator = 1;
15681 return NULL;
15682 }
15683 goto done;
15684 }
15685 p->mark = mark;
15686 }
15687 res = NULL;
15688 done:
15689 return res;
15690}
15691
Guido van Rossum3941d972020-05-01 09:42:03 -070015692// _loop0_110: ',' kwarg_or_starred
15693static asdl_seq *
15694_loop0_110_rule(Parser *p)
15695{
15696 if (p->error_indicator) {
15697 return NULL;
15698 }
15699 void *res = NULL;
15700 int mark = p->mark;
15701 int start_mark = p->mark;
15702 void **children = PyMem_Malloc(sizeof(void *));
15703 if (!children) {
15704 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15705 return NULL;
15706 }
15707 ssize_t children_capacity = 1;
15708 ssize_t n = 0;
15709 { // ',' kwarg_or_starred
15710 KeywordOrStarred* elem;
15711 Token * literal;
15712 while (
15713 (literal = _PyPegen_expect_token(p, 12))
15714 &&
15715 (elem = kwarg_or_starred_rule(p))
15716 )
15717 {
15718 res = elem;
15719 if (res == NULL && PyErr_Occurred()) {
15720 p->error_indicator = 1;
15721 PyMem_Free(children);
15722 return NULL;
15723 }
15724 if (n == children_capacity) {
15725 children_capacity *= 2;
15726 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15727 if (!children) {
15728 PyErr_Format(PyExc_MemoryError, "realloc None");
15729 return NULL;
15730 }
15731 }
15732 children[n++] = res;
15733 mark = p->mark;
15734 }
15735 p->mark = mark;
15736 }
15737 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15738 if (!seq) {
15739 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110");
15740 PyMem_Free(children);
15741 return NULL;
15742 }
15743 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15744 PyMem_Free(children);
15745 _PyPegen_insert_memo(p, start_mark, _loop0_110_type, seq);
15746 return seq;
15747}
15748
15749// _gather_109: kwarg_or_starred _loop0_110
15750static asdl_seq *
15751_gather_109_rule(Parser *p)
15752{
15753 if (p->error_indicator) {
15754 return NULL;
15755 }
15756 asdl_seq * res = NULL;
15757 int mark = p->mark;
15758 { // kwarg_or_starred _loop0_110
15759 KeywordOrStarred* elem;
15760 asdl_seq * seq;
15761 if (
15762 (elem = kwarg_or_starred_rule(p))
15763 &&
15764 (seq = _loop0_110_rule(p))
15765 )
15766 {
15767 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15768 goto done;
15769 }
15770 p->mark = mark;
15771 }
15772 res = NULL;
15773 done:
15774 return res;
15775}
15776
15777// _loop0_112: ',' kwarg_or_double_starred
15778static asdl_seq *
15779_loop0_112_rule(Parser *p)
15780{
15781 if (p->error_indicator) {
15782 return NULL;
15783 }
15784 void *res = NULL;
15785 int mark = p->mark;
15786 int start_mark = p->mark;
15787 void **children = PyMem_Malloc(sizeof(void *));
15788 if (!children) {
15789 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15790 return NULL;
15791 }
15792 ssize_t children_capacity = 1;
15793 ssize_t n = 0;
15794 { // ',' kwarg_or_double_starred
15795 KeywordOrStarred* elem;
15796 Token * literal;
15797 while (
15798 (literal = _PyPegen_expect_token(p, 12))
15799 &&
15800 (elem = kwarg_or_double_starred_rule(p))
15801 )
15802 {
15803 res = elem;
15804 if (res == NULL && PyErr_Occurred()) {
15805 p->error_indicator = 1;
15806 PyMem_Free(children);
15807 return NULL;
15808 }
15809 if (n == children_capacity) {
15810 children_capacity *= 2;
15811 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15812 if (!children) {
15813 PyErr_Format(PyExc_MemoryError, "realloc None");
15814 return NULL;
15815 }
15816 }
15817 children[n++] = res;
15818 mark = p->mark;
15819 }
15820 p->mark = mark;
15821 }
15822 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15823 if (!seq) {
15824 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112");
15825 PyMem_Free(children);
15826 return NULL;
15827 }
15828 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15829 PyMem_Free(children);
15830 _PyPegen_insert_memo(p, start_mark, _loop0_112_type, seq);
15831 return seq;
15832}
15833
15834// _gather_111: kwarg_or_double_starred _loop0_112
15835static asdl_seq *
15836_gather_111_rule(Parser *p)
15837{
15838 if (p->error_indicator) {
15839 return NULL;
15840 }
15841 asdl_seq * res = NULL;
15842 int mark = p->mark;
15843 { // kwarg_or_double_starred _loop0_112
15844 KeywordOrStarred* elem;
15845 asdl_seq * seq;
15846 if (
15847 (elem = kwarg_or_double_starred_rule(p))
15848 &&
15849 (seq = _loop0_112_rule(p))
15850 )
15851 {
15852 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15853 goto done;
15854 }
15855 p->mark = mark;
15856 }
15857 res = NULL;
15858 done:
15859 return res;
15860}
15861
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015862// _loop0_114: ',' kwarg_or_starred
Pablo Galindo2b74c832020-04-27 18:02:07 +010015863static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015864_loop0_114_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015865{
15866 if (p->error_indicator) {
15867 return NULL;
15868 }
15869 void *res = NULL;
15870 int mark = p->mark;
15871 int start_mark = p->mark;
15872 void **children = PyMem_Malloc(sizeof(void *));
15873 if (!children) {
15874 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15875 return NULL;
15876 }
15877 ssize_t children_capacity = 1;
15878 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070015879 { // ',' kwarg_or_starred
15880 KeywordOrStarred* elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015881 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070015882 while (
15883 (literal = _PyPegen_expect_token(p, 12))
15884 &&
15885 (elem = kwarg_or_starred_rule(p))
15886 )
15887 {
15888 res = elem;
15889 if (res == NULL && PyErr_Occurred()) {
15890 p->error_indicator = 1;
15891 PyMem_Free(children);
15892 return NULL;
15893 }
15894 if (n == children_capacity) {
15895 children_capacity *= 2;
15896 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15897 if (!children) {
15898 PyErr_Format(PyExc_MemoryError, "realloc None");
15899 return NULL;
15900 }
15901 }
15902 children[n++] = res;
15903 mark = p->mark;
15904 }
15905 p->mark = mark;
15906 }
15907 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15908 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015909 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114");
Guido van Rossumc001c092020-04-30 12:12:19 -070015910 PyMem_Free(children);
15911 return NULL;
15912 }
15913 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15914 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015915 _PyPegen_insert_memo(p, start_mark, _loop0_114_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070015916 return seq;
15917}
15918
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015919// _gather_113: kwarg_or_starred _loop0_114
Guido van Rossumc001c092020-04-30 12:12:19 -070015920static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015921_gather_113_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015922{
15923 if (p->error_indicator) {
15924 return NULL;
15925 }
15926 asdl_seq * res = NULL;
15927 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015928 { // kwarg_or_starred _loop0_114
Guido van Rossumc001c092020-04-30 12:12:19 -070015929 KeywordOrStarred* elem;
15930 asdl_seq * seq;
15931 if (
15932 (elem = kwarg_or_starred_rule(p))
15933 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015934 (seq = _loop0_114_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070015935 )
15936 {
15937 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15938 goto done;
15939 }
15940 p->mark = mark;
15941 }
15942 res = NULL;
15943 done:
15944 return res;
15945}
15946
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015947// _loop0_116: ',' kwarg_or_double_starred
Guido van Rossumc001c092020-04-30 12:12:19 -070015948static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015949_loop0_116_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015950{
15951 if (p->error_indicator) {
15952 return NULL;
15953 }
15954 void *res = NULL;
15955 int mark = p->mark;
15956 int start_mark = p->mark;
15957 void **children = PyMem_Malloc(sizeof(void *));
15958 if (!children) {
15959 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15960 return NULL;
15961 }
15962 ssize_t children_capacity = 1;
15963 ssize_t n = 0;
15964 { // ',' kwarg_or_double_starred
15965 KeywordOrStarred* elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015966 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070015967 while (
15968 (literal = _PyPegen_expect_token(p, 12))
15969 &&
15970 (elem = kwarg_or_double_starred_rule(p))
15971 )
15972 {
15973 res = elem;
15974 if (res == NULL && PyErr_Occurred()) {
15975 p->error_indicator = 1;
15976 PyMem_Free(children);
15977 return NULL;
15978 }
15979 if (n == children_capacity) {
15980 children_capacity *= 2;
15981 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15982 if (!children) {
15983 PyErr_Format(PyExc_MemoryError, "realloc None");
15984 return NULL;
15985 }
15986 }
15987 children[n++] = res;
15988 mark = p->mark;
15989 }
15990 p->mark = mark;
15991 }
15992 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15993 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015994 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116");
Guido van Rossumc001c092020-04-30 12:12:19 -070015995 PyMem_Free(children);
15996 return NULL;
15997 }
15998 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15999 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016000 _PyPegen_insert_memo(p, start_mark, _loop0_116_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070016001 return seq;
16002}
16003
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016004// _gather_115: kwarg_or_double_starred _loop0_116
Guido van Rossumc001c092020-04-30 12:12:19 -070016005static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016006_gather_115_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070016007{
16008 if (p->error_indicator) {
16009 return NULL;
16010 }
16011 asdl_seq * res = NULL;
16012 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016013 { // kwarg_or_double_starred _loop0_116
Guido van Rossumc001c092020-04-30 12:12:19 -070016014 KeywordOrStarred* elem;
16015 asdl_seq * seq;
16016 if (
16017 (elem = kwarg_or_double_starred_rule(p))
16018 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016019 (seq = _loop0_116_rule(p))
Guido van Rossumc001c092020-04-30 12:12:19 -070016020 )
16021 {
16022 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16023 goto done;
16024 }
16025 p->mark = mark;
16026 }
16027 res = NULL;
16028 done:
16029 return res;
16030}
16031
Guido van Rossum3941d972020-05-01 09:42:03 -070016032// _loop0_117: (',' star_target)
Guido van Rossumc001c092020-04-30 12:12:19 -070016033static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016034_loop0_117_rule(Parser *p)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016035{
16036 if (p->error_indicator) {
16037 return NULL;
16038 }
16039 void *res = NULL;
16040 int mark = p->mark;
16041 int start_mark = p->mark;
16042 void **children = PyMem_Malloc(sizeof(void *));
16043 if (!children) {
16044 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16045 return NULL;
16046 }
16047 ssize_t children_capacity = 1;
16048 ssize_t n = 0;
16049 { // (',' star_target)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016050 void *_tmp_144_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016051 while (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016052 (_tmp_144_var = _tmp_144_rule(p))
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016053 )
16054 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016055 res = _tmp_144_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016056 if (n == children_capacity) {
16057 children_capacity *= 2;
16058 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16059 if (!children) {
16060 PyErr_Format(PyExc_MemoryError, "realloc None");
16061 return NULL;
16062 }
16063 }
16064 children[n++] = res;
16065 mark = p->mark;
16066 }
16067 p->mark = mark;
16068 }
16069 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16070 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016071 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117");
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016072 PyMem_Free(children);
16073 return NULL;
16074 }
16075 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16076 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016077 _PyPegen_insert_memo(p, start_mark, _loop0_117_type, seq);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016078 return seq;
16079}
16080
Guido van Rossum3941d972020-05-01 09:42:03 -070016081// _loop0_119: ',' star_target
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016082static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016083_loop0_119_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070016084{
16085 if (p->error_indicator) {
16086 return NULL;
16087 }
16088 void *res = NULL;
16089 int mark = p->mark;
16090 int start_mark = p->mark;
16091 void **children = PyMem_Malloc(sizeof(void *));
16092 if (!children) {
16093 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16094 return NULL;
16095 }
16096 ssize_t children_capacity = 1;
16097 ssize_t n = 0;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016098 { // ',' star_target
16099 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016100 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016101 while (
16102 (literal = _PyPegen_expect_token(p, 12))
16103 &&
16104 (elem = star_target_rule(p))
16105 )
16106 {
16107 res = elem;
16108 if (res == NULL && PyErr_Occurred()) {
16109 p->error_indicator = 1;
16110 PyMem_Free(children);
16111 return NULL;
16112 }
16113 if (n == children_capacity) {
16114 children_capacity *= 2;
16115 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16116 if (!children) {
16117 PyErr_Format(PyExc_MemoryError, "realloc None");
16118 return NULL;
16119 }
16120 }
16121 children[n++] = res;
16122 mark = p->mark;
16123 }
16124 p->mark = mark;
16125 }
16126 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16127 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016128 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016129 PyMem_Free(children);
16130 return NULL;
16131 }
16132 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16133 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016134 _PyPegen_insert_memo(p, start_mark, _loop0_119_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016135 return seq;
16136}
16137
Guido van Rossum3941d972020-05-01 09:42:03 -070016138// _gather_118: star_target _loop0_119
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016139static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016140_gather_118_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016141{
16142 if (p->error_indicator) {
16143 return NULL;
16144 }
16145 asdl_seq * res = NULL;
16146 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070016147 { // star_target _loop0_119
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016148 expr_ty elem;
16149 asdl_seq * seq;
16150 if (
16151 (elem = star_target_rule(p))
16152 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070016153 (seq = _loop0_119_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016154 )
16155 {
16156 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16157 goto done;
16158 }
16159 p->mark = mark;
16160 }
16161 res = NULL;
16162 done:
16163 return res;
16164}
16165
Guido van Rossum3941d972020-05-01 09:42:03 -070016166// _tmp_120: !'*' star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016167static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016168_tmp_120_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016169{
16170 if (p->error_indicator) {
16171 return NULL;
16172 }
16173 void * res = NULL;
16174 int mark = p->mark;
16175 { // !'*' star_target
16176 expr_ty star_target_var;
16177 if (
16178 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16)
16179 &&
16180 (star_target_var = star_target_rule(p))
16181 )
16182 {
16183 res = star_target_var;
16184 goto done;
16185 }
16186 p->mark = mark;
16187 }
16188 res = NULL;
16189 done:
16190 return res;
16191}
16192
Guido van Rossum3941d972020-05-01 09:42:03 -070016193// _loop0_122: ',' del_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016194static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016195_loop0_122_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016196{
16197 if (p->error_indicator) {
16198 return NULL;
16199 }
16200 void *res = NULL;
16201 int mark = p->mark;
16202 int start_mark = p->mark;
16203 void **children = PyMem_Malloc(sizeof(void *));
16204 if (!children) {
16205 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16206 return NULL;
16207 }
16208 ssize_t children_capacity = 1;
16209 ssize_t n = 0;
16210 { // ',' del_target
16211 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016212 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016213 while (
16214 (literal = _PyPegen_expect_token(p, 12))
16215 &&
16216 (elem = del_target_rule(p))
16217 )
16218 {
16219 res = elem;
16220 if (res == NULL && PyErr_Occurred()) {
16221 p->error_indicator = 1;
16222 PyMem_Free(children);
16223 return NULL;
16224 }
16225 if (n == children_capacity) {
16226 children_capacity *= 2;
16227 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16228 if (!children) {
16229 PyErr_Format(PyExc_MemoryError, "realloc None");
16230 return NULL;
16231 }
16232 }
16233 children[n++] = res;
16234 mark = p->mark;
16235 }
16236 p->mark = mark;
16237 }
16238 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16239 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016240 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016241 PyMem_Free(children);
16242 return NULL;
16243 }
16244 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16245 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016246 _PyPegen_insert_memo(p, start_mark, _loop0_122_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016247 return seq;
16248}
16249
Guido van Rossum3941d972020-05-01 09:42:03 -070016250// _gather_121: del_target _loop0_122
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016251static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016252_gather_121_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016253{
16254 if (p->error_indicator) {
16255 return NULL;
16256 }
16257 asdl_seq * res = NULL;
16258 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070016259 { // del_target _loop0_122
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016260 expr_ty elem;
16261 asdl_seq * seq;
16262 if (
16263 (elem = del_target_rule(p))
16264 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070016265 (seq = _loop0_122_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016266 )
16267 {
16268 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16269 goto done;
16270 }
16271 p->mark = mark;
16272 }
16273 res = NULL;
16274 done:
16275 return res;
16276}
16277
Guido van Rossum3941d972020-05-01 09:42:03 -070016278// _loop0_124: ',' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016279static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016280_loop0_124_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016281{
16282 if (p->error_indicator) {
16283 return NULL;
16284 }
16285 void *res = NULL;
16286 int mark = p->mark;
16287 int start_mark = p->mark;
16288 void **children = PyMem_Malloc(sizeof(void *));
16289 if (!children) {
16290 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16291 return NULL;
16292 }
16293 ssize_t children_capacity = 1;
16294 ssize_t n = 0;
16295 { // ',' target
16296 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016297 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016298 while (
16299 (literal = _PyPegen_expect_token(p, 12))
16300 &&
16301 (elem = target_rule(p))
16302 )
16303 {
16304 res = elem;
16305 if (res == NULL && PyErr_Occurred()) {
16306 p->error_indicator = 1;
16307 PyMem_Free(children);
16308 return NULL;
16309 }
16310 if (n == children_capacity) {
16311 children_capacity *= 2;
16312 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16313 if (!children) {
16314 PyErr_Format(PyExc_MemoryError, "realloc None");
16315 return NULL;
16316 }
16317 }
16318 children[n++] = res;
16319 mark = p->mark;
16320 }
16321 p->mark = mark;
16322 }
16323 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16324 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016325 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016326 PyMem_Free(children);
16327 return NULL;
16328 }
16329 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16330 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016331 _PyPegen_insert_memo(p, start_mark, _loop0_124_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016332 return seq;
16333}
16334
Guido van Rossum3941d972020-05-01 09:42:03 -070016335// _gather_123: target _loop0_124
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016336static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016337_gather_123_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016338{
16339 if (p->error_indicator) {
16340 return NULL;
16341 }
16342 asdl_seq * res = NULL;
16343 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070016344 { // target _loop0_124
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016345 expr_ty elem;
16346 asdl_seq * seq;
16347 if (
16348 (elem = target_rule(p))
16349 &&
Guido van Rossum3941d972020-05-01 09:42:03 -070016350 (seq = _loop0_124_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016351 )
16352 {
16353 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16354 goto done;
16355 }
16356 p->mark = mark;
16357 }
16358 res = NULL;
16359 done:
16360 return res;
16361}
16362
Guido van Rossum3941d972020-05-01 09:42:03 -070016363// _tmp_125: args | expression for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016364static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016365_tmp_125_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016366{
16367 if (p->error_indicator) {
16368 return NULL;
16369 }
16370 void * res = NULL;
16371 int mark = p->mark;
16372 { // args
16373 expr_ty args_var;
16374 if (
16375 (args_var = args_rule(p))
16376 )
16377 {
16378 res = args_var;
16379 goto done;
16380 }
16381 p->mark = mark;
16382 }
16383 { // expression for_if_clauses
16384 expr_ty expression_var;
16385 asdl_seq* for_if_clauses_var;
16386 if (
16387 (expression_var = expression_rule(p))
16388 &&
16389 (for_if_clauses_var = for_if_clauses_rule(p))
16390 )
16391 {
16392 res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var);
16393 goto done;
16394 }
16395 p->mark = mark;
16396 }
16397 res = NULL;
16398 done:
16399 return res;
16400}
16401
Guido van Rossum3941d972020-05-01 09:42:03 -070016402// _tmp_126: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016403static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016404_tmp_126_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016405{
16406 if (p->error_indicator) {
16407 return NULL;
16408 }
16409 void * res = NULL;
16410 int mark = p->mark;
16411 { // '=' annotated_rhs
16412 expr_ty annotated_rhs_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016413 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016414 if (
16415 (literal = _PyPegen_expect_token(p, 22))
16416 &&
16417 (annotated_rhs_var = annotated_rhs_rule(p))
16418 )
16419 {
16420 res = _PyPegen_dummy_name(p, literal, annotated_rhs_var);
16421 goto done;
16422 }
16423 p->mark = mark;
16424 }
16425 res = NULL;
16426 done:
16427 return res;
16428}
16429
Guido van Rossum3941d972020-05-01 09:42:03 -070016430// _tmp_127: '=' | augassign
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016431static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016432_tmp_127_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016433{
16434 if (p->error_indicator) {
16435 return NULL;
16436 }
16437 void * res = NULL;
16438 int mark = p->mark;
16439 { // '='
Pablo Galindob796b3f2020-05-01 12:32:26 +010016440 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016441 if (
16442 (literal = _PyPegen_expect_token(p, 22))
16443 )
16444 {
16445 res = literal;
16446 goto done;
16447 }
16448 p->mark = mark;
16449 }
16450 { // augassign
16451 AugOperator* augassign_var;
16452 if (
16453 (augassign_var = augassign_rule(p))
16454 )
16455 {
16456 res = augassign_var;
16457 goto done;
16458 }
16459 p->mark = mark;
16460 }
16461 res = NULL;
16462 done:
16463 return res;
16464}
16465
Guido van Rossum3941d972020-05-01 09:42:03 -070016466// _tmp_128: yield_expr | star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016467static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016468_tmp_128_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016469{
16470 if (p->error_indicator) {
16471 return NULL;
16472 }
16473 void * res = NULL;
16474 int mark = p->mark;
16475 { // yield_expr
16476 expr_ty yield_expr_var;
16477 if (
16478 (yield_expr_var = yield_expr_rule(p))
16479 )
16480 {
16481 res = yield_expr_var;
16482 goto done;
16483 }
16484 p->mark = mark;
16485 }
16486 { // star_expressions
16487 expr_ty star_expressions_var;
16488 if (
16489 (star_expressions_var = star_expressions_rule(p))
16490 )
16491 {
16492 res = star_expressions_var;
16493 goto done;
16494 }
16495 p->mark = mark;
16496 }
16497 res = NULL;
16498 done:
16499 return res;
16500}
16501
Guido van Rossum3941d972020-05-01 09:42:03 -070016502// _tmp_129: '[' | '(' | '{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016503static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016504_tmp_129_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016505{
16506 if (p->error_indicator) {
16507 return NULL;
16508 }
16509 void * res = NULL;
16510 int mark = p->mark;
16511 { // '['
Pablo Galindob796b3f2020-05-01 12:32:26 +010016512 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016513 if (
16514 (literal = _PyPegen_expect_token(p, 9))
16515 )
16516 {
16517 res = literal;
16518 goto done;
16519 }
16520 p->mark = mark;
16521 }
16522 { // '('
Pablo Galindob796b3f2020-05-01 12:32:26 +010016523 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016524 if (
16525 (literal = _PyPegen_expect_token(p, 7))
16526 )
16527 {
16528 res = literal;
16529 goto done;
16530 }
16531 p->mark = mark;
16532 }
16533 { // '{'
Pablo Galindob796b3f2020-05-01 12:32:26 +010016534 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016535 if (
16536 (literal = _PyPegen_expect_token(p, 25))
16537 )
16538 {
16539 res = literal;
16540 goto done;
16541 }
16542 p->mark = mark;
16543 }
16544 res = NULL;
16545 done:
16546 return res;
16547}
16548
Guido van Rossum3941d972020-05-01 09:42:03 -070016549// _loop0_130: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070016550static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016551_loop0_130_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016552{
16553 if (p->error_indicator) {
16554 return NULL;
16555 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016556 void *res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016557 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070016558 int start_mark = p->mark;
16559 void **children = PyMem_Malloc(sizeof(void *));
16560 if (!children) {
16561 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16562 return NULL;
16563 }
16564 ssize_t children_capacity = 1;
16565 ssize_t n = 0;
16566 { // param_no_default
16567 arg_ty param_no_default_var;
16568 while (
16569 (param_no_default_var = param_no_default_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016570 )
16571 {
Guido van Rossumc001c092020-04-30 12:12:19 -070016572 res = param_no_default_var;
16573 if (n == children_capacity) {
16574 children_capacity *= 2;
16575 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16576 if (!children) {
16577 PyErr_Format(PyExc_MemoryError, "realloc None");
16578 return NULL;
16579 }
16580 }
16581 children[n++] = res;
16582 mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016583 }
16584 p->mark = mark;
16585 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016586 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16587 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016588 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_130");
Guido van Rossumc001c092020-04-30 12:12:19 -070016589 PyMem_Free(children);
16590 return NULL;
16591 }
16592 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16593 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016594 _PyPegen_insert_memo(p, start_mark, _loop0_130_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070016595 return seq;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016596}
16597
Guido van Rossum3941d972020-05-01 09:42:03 -070016598// _tmp_131: slash_with_default | param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016599static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016600_tmp_131_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016601{
16602 if (p->error_indicator) {
16603 return NULL;
16604 }
16605 void * res = NULL;
16606 int mark = p->mark;
16607 { // slash_with_default
16608 SlashWithDefault* slash_with_default_var;
16609 if (
16610 (slash_with_default_var = slash_with_default_rule(p))
16611 )
16612 {
16613 res = slash_with_default_var;
16614 goto done;
16615 }
16616 p->mark = mark;
16617 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016618 { // param_with_default+
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016619 asdl_seq * _loop1_145_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016620 if (
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016621 (_loop1_145_var = _loop1_145_rule(p))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016622 )
16623 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016624 res = _loop1_145_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016625 goto done;
16626 }
16627 p->mark = mark;
16628 }
16629 res = NULL;
16630 done:
16631 return res;
16632}
16633
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016634// _tmp_132: ')' | ',' (')' | '**')
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016635static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016636_tmp_132_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016637{
16638 if (p->error_indicator) {
16639 return NULL;
16640 }
16641 void * res = NULL;
16642 int mark = p->mark;
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016643 { // ')'
16644 Token * literal;
16645 if (
16646 (literal = _PyPegen_expect_token(p, 8))
16647 )
16648 {
16649 res = literal;
16650 goto done;
16651 }
16652 p->mark = mark;
16653 }
16654 { // ',' (')' | '**')
16655 void *_tmp_146_var;
16656 Token * literal;
16657 if (
16658 (literal = _PyPegen_expect_token(p, 12))
16659 &&
16660 (_tmp_146_var = _tmp_146_rule(p))
16661 )
16662 {
16663 res = _PyPegen_dummy_name(p, literal, _tmp_146_var);
16664 goto done;
16665 }
16666 p->mark = mark;
16667 }
16668 res = NULL;
16669 done:
16670 return res;
16671}
16672
16673// _tmp_133: ':' | ',' (':' | '**')
16674static void *
16675_tmp_133_rule(Parser *p)
16676{
16677 if (p->error_indicator) {
16678 return NULL;
16679 }
16680 void * res = NULL;
16681 int mark = p->mark;
16682 { // ':'
16683 Token * literal;
16684 if (
16685 (literal = _PyPegen_expect_token(p, 11))
16686 )
16687 {
16688 res = literal;
16689 goto done;
16690 }
16691 p->mark = mark;
16692 }
16693 { // ',' (':' | '**')
16694 void *_tmp_147_var;
16695 Token * literal;
16696 if (
16697 (literal = _PyPegen_expect_token(p, 12))
16698 &&
16699 (_tmp_147_var = _tmp_147_rule(p))
16700 )
16701 {
16702 res = _PyPegen_dummy_name(p, literal, _tmp_147_var);
16703 goto done;
16704 }
16705 p->mark = mark;
16706 }
16707 res = NULL;
16708 done:
16709 return res;
16710}
16711
16712// _tmp_134: star_targets '='
16713static void *
16714_tmp_134_rule(Parser *p)
16715{
16716 if (p->error_indicator) {
16717 return NULL;
16718 }
16719 void * res = NULL;
16720 int mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016721 { // star_targets '='
Pablo Galindob796b3f2020-05-01 12:32:26 +010016722 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016723 expr_ty z;
16724 if (
16725 (z = star_targets_rule(p))
16726 &&
16727 (literal = _PyPegen_expect_token(p, 22))
16728 )
16729 {
16730 res = z;
16731 if (res == NULL && PyErr_Occurred()) {
16732 p->error_indicator = 1;
16733 return NULL;
16734 }
16735 goto done;
16736 }
16737 p->mark = mark;
16738 }
16739 res = NULL;
16740 done:
16741 return res;
16742}
16743
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016744// _tmp_135: '.' | '...'
Pablo Galindo2b74c832020-04-27 18:02:07 +010016745static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016746_tmp_135_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016747{
16748 if (p->error_indicator) {
16749 return NULL;
16750 }
16751 void * res = NULL;
16752 int mark = p->mark;
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016753 { // '.'
16754 Token * literal;
16755 if (
16756 (literal = _PyPegen_expect_token(p, 23))
16757 )
16758 {
16759 res = literal;
16760 goto done;
16761 }
16762 p->mark = mark;
16763 }
16764 { // '...'
16765 Token * literal;
16766 if (
16767 (literal = _PyPegen_expect_token(p, 52))
16768 )
16769 {
16770 res = literal;
16771 goto done;
16772 }
16773 p->mark = mark;
16774 }
16775 res = NULL;
16776 done:
16777 return res;
16778}
16779
16780// _tmp_136: '.' | '...'
16781static void *
16782_tmp_136_rule(Parser *p)
16783{
16784 if (p->error_indicator) {
16785 return NULL;
16786 }
16787 void * res = NULL;
16788 int mark = p->mark;
16789 { // '.'
16790 Token * literal;
16791 if (
16792 (literal = _PyPegen_expect_token(p, 23))
16793 )
16794 {
16795 res = literal;
16796 goto done;
16797 }
16798 p->mark = mark;
16799 }
16800 { // '...'
16801 Token * literal;
16802 if (
16803 (literal = _PyPegen_expect_token(p, 52))
16804 )
16805 {
16806 res = literal;
16807 goto done;
16808 }
16809 p->mark = mark;
16810 }
16811 res = NULL;
16812 done:
16813 return res;
16814}
16815
16816// _tmp_137: '@' named_expression NEWLINE
16817static void *
16818_tmp_137_rule(Parser *p)
16819{
16820 if (p->error_indicator) {
16821 return NULL;
16822 }
16823 void * res = NULL;
16824 int mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016825 { // '@' named_expression NEWLINE
16826 expr_ty f;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016827 Token * literal;
16828 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016829 if (
16830 (literal = _PyPegen_expect_token(p, 49))
16831 &&
16832 (f = named_expression_rule(p))
16833 &&
Pablo Galindo4db245e2020-04-29 10:42:21 +010016834 (newline_var = _PyPegen_expect_token(p, NEWLINE))
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016835 )
16836 {
16837 res = f;
16838 if (res == NULL && PyErr_Occurred()) {
16839 p->error_indicator = 1;
16840 return NULL;
16841 }
16842 goto done;
16843 }
16844 p->mark = mark;
16845 }
16846 res = NULL;
16847 done:
16848 return res;
16849}
16850
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016851// _tmp_138: ',' star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016852static void *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016853_tmp_138_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016854{
16855 if (p->error_indicator) {
16856 return NULL;
16857 }
16858 void * res = NULL;
16859 int mark = p->mark;
16860 { // ',' star_expression
16861 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016862 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016863 if (
16864 (literal = _PyPegen_expect_token(p, 12))
16865 &&
16866 (c = star_expression_rule(p))
16867 )
16868 {
16869 res = c;
16870 if (res == NULL && PyErr_Occurred()) {
16871 p->error_indicator = 1;
16872 return NULL;
16873 }
16874 goto done;
16875 }
16876 p->mark = mark;
16877 }
16878 res = NULL;
16879 done:
16880 return res;
16881}
16882
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016883// _tmp_139: ',' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016884static void *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016885_tmp_139_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016886{
16887 if (p->error_indicator) {
16888 return NULL;
16889 }
16890 void * res = NULL;
16891 int mark = p->mark;
16892 { // ',' expression
16893 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016894 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016895 if (
16896 (literal = _PyPegen_expect_token(p, 12))
16897 &&
16898 (c = expression_rule(p))
16899 )
16900 {
16901 res = c;
16902 if (res == NULL && PyErr_Occurred()) {
16903 p->error_indicator = 1;
16904 return NULL;
16905 }
16906 goto done;
16907 }
16908 p->mark = mark;
16909 }
16910 res = NULL;
16911 done:
16912 return res;
16913}
16914
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016915// _tmp_140: 'or' conjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016916static void *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016917_tmp_140_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016918{
16919 if (p->error_indicator) {
16920 return NULL;
16921 }
16922 void * res = NULL;
16923 int mark = p->mark;
16924 { // 'or' conjunction
16925 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016926 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016927 if (
16928 (keyword = _PyPegen_expect_token(p, 532))
16929 &&
16930 (c = conjunction_rule(p))
16931 )
16932 {
16933 res = c;
16934 if (res == NULL && PyErr_Occurred()) {
16935 p->error_indicator = 1;
16936 return NULL;
16937 }
16938 goto done;
16939 }
16940 p->mark = mark;
16941 }
16942 res = NULL;
16943 done:
16944 return res;
16945}
16946
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016947// _tmp_141: 'and' inversion
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016948static void *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016949_tmp_141_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016950{
16951 if (p->error_indicator) {
16952 return NULL;
16953 }
16954 void * res = NULL;
16955 int mark = p->mark;
16956 { // 'and' inversion
16957 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016958 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016959 if (
16960 (keyword = _PyPegen_expect_token(p, 533))
16961 &&
16962 (c = inversion_rule(p))
16963 )
16964 {
16965 res = c;
16966 if (res == NULL && PyErr_Occurred()) {
16967 p->error_indicator = 1;
16968 return NULL;
16969 }
16970 goto done;
16971 }
16972 p->mark = mark;
16973 }
16974 res = NULL;
16975 done:
16976 return res;
16977}
16978
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016979// _tmp_142: 'if' disjunction
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016980static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016981_tmp_142_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016982{
16983 if (p->error_indicator) {
16984 return NULL;
16985 }
16986 void * res = NULL;
16987 int mark = p->mark;
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016988 { // 'if' disjunction
16989 Token * keyword;
16990 expr_ty z;
16991 if (
16992 (keyword = _PyPegen_expect_token(p, 510))
16993 &&
16994 (z = disjunction_rule(p))
16995 )
16996 {
16997 res = z;
16998 if (res == NULL && PyErr_Occurred()) {
16999 p->error_indicator = 1;
17000 return NULL;
17001 }
17002 goto done;
17003 }
17004 p->mark = mark;
17005 }
17006 res = NULL;
17007 done:
17008 return res;
17009}
17010
17011// _tmp_143: 'if' disjunction
17012static void *
17013_tmp_143_rule(Parser *p)
17014{
17015 if (p->error_indicator) {
17016 return NULL;
17017 }
17018 void * res = NULL;
17019 int mark = p->mark;
17020 { // 'if' disjunction
17021 Token * keyword;
17022 expr_ty z;
17023 if (
17024 (keyword = _PyPegen_expect_token(p, 510))
17025 &&
17026 (z = disjunction_rule(p))
17027 )
17028 {
17029 res = z;
17030 if (res == NULL && PyErr_Occurred()) {
17031 p->error_indicator = 1;
17032 return NULL;
17033 }
17034 goto done;
17035 }
17036 p->mark = mark;
17037 }
17038 res = NULL;
17039 done:
17040 return res;
17041}
17042
17043// _tmp_144: ',' star_target
17044static void *
17045_tmp_144_rule(Parser *p)
17046{
17047 if (p->error_indicator) {
17048 return NULL;
17049 }
17050 void * res = NULL;
17051 int mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017052 { // ',' star_target
17053 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010017054 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017055 if (
17056 (literal = _PyPegen_expect_token(p, 12))
17057 &&
17058 (c = star_target_rule(p))
17059 )
17060 {
17061 res = c;
17062 if (res == NULL && PyErr_Occurred()) {
17063 p->error_indicator = 1;
17064 return NULL;
17065 }
17066 goto done;
17067 }
17068 p->mark = mark;
17069 }
17070 res = NULL;
17071 done:
17072 return res;
17073}
17074
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017075// _loop1_145: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017076static asdl_seq *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017077_loop1_145_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070017078{
17079 if (p->error_indicator) {
17080 return NULL;
17081 }
17082 void *res = NULL;
17083 int mark = p->mark;
17084 int start_mark = p->mark;
17085 void **children = PyMem_Malloc(sizeof(void *));
17086 if (!children) {
17087 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
17088 return NULL;
17089 }
17090 ssize_t children_capacity = 1;
17091 ssize_t n = 0;
17092 { // param_with_default
17093 NameDefaultPair* param_with_default_var;
17094 while (
17095 (param_with_default_var = param_with_default_rule(p))
17096 )
17097 {
17098 res = param_with_default_var;
17099 if (n == children_capacity) {
17100 children_capacity *= 2;
17101 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
17102 if (!children) {
17103 PyErr_Format(PyExc_MemoryError, "realloc None");
17104 return NULL;
17105 }
17106 }
17107 children[n++] = res;
17108 mark = p->mark;
17109 }
17110 p->mark = mark;
17111 }
17112 if (n == 0) {
17113 PyMem_Free(children);
17114 return NULL;
17115 }
17116 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
17117 if (!seq) {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017118 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_145");
Guido van Rossumc001c092020-04-30 12:12:19 -070017119 PyMem_Free(children);
17120 return NULL;
17121 }
17122 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
17123 PyMem_Free(children);
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017124 _PyPegen_insert_memo(p, start_mark, _loop1_145_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070017125 return seq;
17126}
17127
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017128// _tmp_146: ')' | '**'
17129static void *
17130_tmp_146_rule(Parser *p)
17131{
17132 if (p->error_indicator) {
17133 return NULL;
17134 }
17135 void * res = NULL;
17136 int mark = p->mark;
17137 { // ')'
17138 Token * literal;
17139 if (
17140 (literal = _PyPegen_expect_token(p, 8))
17141 )
17142 {
17143 res = literal;
17144 goto done;
17145 }
17146 p->mark = mark;
17147 }
17148 { // '**'
17149 Token * literal;
17150 if (
17151 (literal = _PyPegen_expect_token(p, 35))
17152 )
17153 {
17154 res = literal;
17155 goto done;
17156 }
17157 p->mark = mark;
17158 }
17159 res = NULL;
17160 done:
17161 return res;
17162}
17163
17164// _tmp_147: ':' | '**'
17165static void *
17166_tmp_147_rule(Parser *p)
17167{
17168 if (p->error_indicator) {
17169 return NULL;
17170 }
17171 void * res = NULL;
17172 int mark = p->mark;
17173 { // ':'
17174 Token * literal;
17175 if (
17176 (literal = _PyPegen_expect_token(p, 11))
17177 )
17178 {
17179 res = literal;
17180 goto done;
17181 }
17182 p->mark = mark;
17183 }
17184 { // '**'
17185 Token * literal;
17186 if (
17187 (literal = _PyPegen_expect_token(p, 35))
17188 )
17189 {
17190 res = literal;
17191 goto done;
17192 }
17193 p->mark = mark;
17194 }
17195 res = NULL;
17196 done:
17197 return res;
17198}
17199
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017200void *
17201_PyPegen_parse(Parser *p)
17202{
17203 // Initialize keywords
17204 p->keywords = reserved_keywords;
17205 p->n_keyword_lists = n_keyword_lists;
17206
17207 // Run parser
17208 void *result = NULL;
17209 if (p->start_rule == Py_file_input) {
17210 result = file_rule(p);
17211 } else if (p->start_rule == Py_single_input) {
17212 result = interactive_rule(p);
17213 } else if (p->start_rule == Py_eval_input) {
17214 result = eval_rule(p);
Guido van Rossumc001c092020-04-30 12:12:19 -070017215 } else if (p->start_rule == Py_func_type_input) {
17216 result = func_type_rule(p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017217 } else if (p->start_rule == Py_fstring_input) {
17218 result = fstring_rule(p);
17219 }
17220
17221 return result;
17222}
17223
17224// The end