blob: 3a08abbca581c554a52effd64648e3bf6165306c [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
Lysandros Nikolaou4638c642020-05-07 13:44:06 +0300213#define invalid_kwarg_type 1142
214#define invalid_named_expression_type 1143
215#define invalid_assignment_type 1144
216#define invalid_block_type 1145
217#define invalid_comprehension_type 1146
218#define invalid_parameters_type 1147
219#define invalid_star_etc_type 1148
220#define invalid_lambda_star_etc_type 1149
221#define invalid_double_type_comments_type 1150
222#define _loop0_1_type 1151
223#define _loop0_2_type 1152
224#define _loop0_4_type 1153
225#define _gather_3_type 1154
226#define _loop0_6_type 1155
227#define _gather_5_type 1156
228#define _loop0_8_type 1157
229#define _gather_7_type 1158
230#define _loop0_10_type 1159
231#define _gather_9_type 1160
232#define _loop1_11_type 1161
233#define _loop0_13_type 1162
234#define _gather_12_type 1163
235#define _tmp_14_type 1164
236#define _tmp_15_type 1165
237#define _tmp_16_type 1166
238#define _tmp_17_type 1167
239#define _tmp_18_type 1168
240#define _tmp_19_type 1169
241#define _tmp_20_type 1170
242#define _tmp_21_type 1171
243#define _loop1_22_type 1172
244#define _tmp_23_type 1173
245#define _tmp_24_type 1174
246#define _loop0_26_type 1175
247#define _gather_25_type 1176
248#define _loop0_28_type 1177
249#define _gather_27_type 1178
250#define _tmp_29_type 1179
251#define _loop0_30_type 1180
252#define _loop1_31_type 1181
253#define _loop0_33_type 1182
254#define _gather_32_type 1183
255#define _tmp_34_type 1184
256#define _loop0_36_type 1185
257#define _gather_35_type 1186
258#define _tmp_37_type 1187
259#define _loop0_39_type 1188
260#define _gather_38_type 1189
261#define _loop0_41_type 1190
262#define _gather_40_type 1191
263#define _loop0_43_type 1192
264#define _gather_42_type 1193
265#define _loop0_45_type 1194
266#define _gather_44_type 1195
267#define _tmp_46_type 1196
268#define _loop1_47_type 1197
269#define _tmp_48_type 1198
270#define _tmp_49_type 1199
271#define _tmp_50_type 1200
272#define _tmp_51_type 1201
273#define _tmp_52_type 1202
274#define _loop0_53_type 1203
275#define _loop0_54_type 1204
276#define _loop0_55_type 1205
277#define _loop1_56_type 1206
278#define _loop0_57_type 1207
279#define _loop1_58_type 1208
280#define _loop1_59_type 1209
281#define _loop1_60_type 1210
282#define _loop0_61_type 1211
283#define _loop1_62_type 1212
284#define _loop0_63_type 1213
285#define _loop1_64_type 1214
286#define _loop0_65_type 1215
287#define _loop1_66_type 1216
288#define _loop1_67_type 1217
289#define _tmp_68_type 1218
290#define _loop0_70_type 1219
291#define _gather_69_type 1220
292#define _loop1_71_type 1221
293#define _loop0_73_type 1222
294#define _gather_72_type 1223
295#define _loop1_74_type 1224
296#define _loop0_75_type 1225
297#define _loop0_76_type 1226
298#define _loop0_77_type 1227
299#define _loop1_78_type 1228
300#define _loop0_79_type 1229
301#define _loop1_80_type 1230
302#define _loop1_81_type 1231
303#define _loop1_82_type 1232
304#define _loop0_83_type 1233
305#define _loop1_84_type 1234
306#define _loop0_85_type 1235
307#define _loop1_86_type 1236
308#define _loop0_87_type 1237
309#define _loop1_88_type 1238
310#define _loop1_89_type 1239
311#define _loop1_90_type 1240
312#define _loop1_91_type 1241
313#define _tmp_92_type 1242
314#define _loop0_94_type 1243
315#define _gather_93_type 1244
316#define _tmp_95_type 1245
317#define _tmp_96_type 1246
318#define _tmp_97_type 1247
319#define _tmp_98_type 1248
320#define _loop1_99_type 1249
321#define _tmp_100_type 1250
322#define _tmp_101_type 1251
323#define _loop0_103_type 1252
324#define _gather_102_type 1253
325#define _loop1_104_type 1254
326#define _loop0_105_type 1255
327#define _loop0_106_type 1256
328#define _tmp_107_type 1257
329#define _tmp_108_type 1258
330#define _loop0_110_type 1259
331#define _gather_109_type 1260
332#define _loop0_112_type 1261
333#define _gather_111_type 1262
334#define _loop0_114_type 1263
335#define _gather_113_type 1264
336#define _loop0_116_type 1265
337#define _gather_115_type 1266
338#define _loop0_117_type 1267
339#define _loop0_119_type 1268
340#define _gather_118_type 1269
341#define _tmp_120_type 1270
342#define _loop0_122_type 1271
343#define _gather_121_type 1272
344#define _loop0_124_type 1273
345#define _gather_123_type 1274
346#define _tmp_125_type 1275
347#define _tmp_126_type 1276
348#define _tmp_127_type 1277
349#define _tmp_128_type 1278
350#define _tmp_129_type 1279
351#define _loop0_130_type 1280
352#define _tmp_131_type 1281
353#define _tmp_132_type 1282
354#define _tmp_133_type 1283
355#define _tmp_134_type 1284
356#define _tmp_135_type 1285
357#define _tmp_136_type 1286
358#define _tmp_137_type 1287
359#define _tmp_138_type 1288
360#define _tmp_139_type 1289
361#define _tmp_140_type 1290
362#define _tmp_141_type 1291
363#define _tmp_142_type 1292
364#define _tmp_143_type 1293
365#define _tmp_144_type 1294
366#define _loop1_145_type 1295
367#define _tmp_146_type 1296
368#define _tmp_147_type 1297
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100369
370static mod_ty file_rule(Parser *p);
371static mod_ty interactive_rule(Parser *p);
372static mod_ty eval_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700373static mod_ty func_type_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100374static expr_ty fstring_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700375static asdl_seq* type_expressions_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100376static asdl_seq* statements_rule(Parser *p);
377static asdl_seq* statement_rule(Parser *p);
378static asdl_seq* statement_newline_rule(Parser *p);
379static asdl_seq* simple_stmt_rule(Parser *p);
380static stmt_ty small_stmt_rule(Parser *p);
381static stmt_ty compound_stmt_rule(Parser *p);
Lysandros Nikolaou999ec9a2020-05-06 21:11:04 +0300382static stmt_ty assignment_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100383static AugOperator* augassign_rule(Parser *p);
384static stmt_ty global_stmt_rule(Parser *p);
385static stmt_ty nonlocal_stmt_rule(Parser *p);
386static stmt_ty yield_stmt_rule(Parser *p);
387static stmt_ty assert_stmt_rule(Parser *p);
388static stmt_ty del_stmt_rule(Parser *p);
389static stmt_ty import_stmt_rule(Parser *p);
390static stmt_ty import_name_rule(Parser *p);
391static stmt_ty import_from_rule(Parser *p);
392static asdl_seq* import_from_targets_rule(Parser *p);
393static asdl_seq* import_from_as_names_rule(Parser *p);
394static alias_ty import_from_as_name_rule(Parser *p);
395static asdl_seq* dotted_as_names_rule(Parser *p);
396static alias_ty dotted_as_name_rule(Parser *p);
397static expr_ty dotted_name_rule(Parser *p);
398static stmt_ty if_stmt_rule(Parser *p);
399static stmt_ty elif_stmt_rule(Parser *p);
400static asdl_seq* else_block_rule(Parser *p);
401static stmt_ty while_stmt_rule(Parser *p);
402static stmt_ty for_stmt_rule(Parser *p);
403static stmt_ty with_stmt_rule(Parser *p);
404static withitem_ty with_item_rule(Parser *p);
405static stmt_ty try_stmt_rule(Parser *p);
406static excepthandler_ty except_block_rule(Parser *p);
407static asdl_seq* finally_block_rule(Parser *p);
408static stmt_ty return_stmt_rule(Parser *p);
409static stmt_ty raise_stmt_rule(Parser *p);
410static stmt_ty function_def_rule(Parser *p);
411static stmt_ty function_def_raw_rule(Parser *p);
Pablo Galindod9552412020-05-01 16:32:09 +0100412static Token* func_type_comment_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100413static arguments_ty params_rule(Parser *p);
414static arguments_ty parameters_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700415static asdl_seq* slash_no_default_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100416static SlashWithDefault* slash_with_default_rule(Parser *p);
417static StarEtc* star_etc_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100418static arg_ty kwds_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700419static arg_ty param_no_default_rule(Parser *p);
420static NameDefaultPair* param_with_default_rule(Parser *p);
421static NameDefaultPair* param_maybe_default_rule(Parser *p);
422static arg_ty param_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100423static expr_ty annotation_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700424static expr_ty default_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100425static asdl_seq* decorators_rule(Parser *p);
426static stmt_ty class_def_rule(Parser *p);
427static stmt_ty class_def_raw_rule(Parser *p);
428static asdl_seq* block_rule(Parser *p);
429static asdl_seq* expressions_list_rule(Parser *p);
430static expr_ty star_expressions_rule(Parser *p);
431static expr_ty star_expression_rule(Parser *p);
432static asdl_seq* star_named_expressions_rule(Parser *p);
433static expr_ty star_named_expression_rule(Parser *p);
434static expr_ty named_expression_rule(Parser *p);
435static expr_ty annotated_rhs_rule(Parser *p);
436static expr_ty expressions_rule(Parser *p);
437static expr_ty expression_rule(Parser *p);
438static expr_ty lambdef_rule(Parser *p);
439static arguments_ty lambda_parameters_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700440static asdl_seq* lambda_slash_no_default_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100441static SlashWithDefault* lambda_slash_with_default_rule(Parser *p);
442static StarEtc* lambda_star_etc_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100443static arg_ty lambda_kwds_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700444static arg_ty lambda_param_no_default_rule(Parser *p);
445static NameDefaultPair* lambda_param_with_default_rule(Parser *p);
446static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p);
447static arg_ty lambda_param_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100448static expr_ty disjunction_rule(Parser *p);
449static expr_ty conjunction_rule(Parser *p);
450static expr_ty inversion_rule(Parser *p);
451static expr_ty comparison_rule(Parser *p);
452static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p);
453static CmpopExprPair* eq_bitwise_or_rule(Parser *p);
454static CmpopExprPair* noteq_bitwise_or_rule(Parser *p);
455static CmpopExprPair* lte_bitwise_or_rule(Parser *p);
456static CmpopExprPair* lt_bitwise_or_rule(Parser *p);
457static CmpopExprPair* gte_bitwise_or_rule(Parser *p);
458static CmpopExprPair* gt_bitwise_or_rule(Parser *p);
459static CmpopExprPair* notin_bitwise_or_rule(Parser *p);
460static CmpopExprPair* in_bitwise_or_rule(Parser *p);
461static CmpopExprPair* isnot_bitwise_or_rule(Parser *p);
462static CmpopExprPair* is_bitwise_or_rule(Parser *p);
463static expr_ty bitwise_or_rule(Parser *p);
464static expr_ty bitwise_xor_rule(Parser *p);
465static expr_ty bitwise_and_rule(Parser *p);
466static expr_ty shift_expr_rule(Parser *p);
467static expr_ty sum_rule(Parser *p);
468static expr_ty term_rule(Parser *p);
469static expr_ty factor_rule(Parser *p);
470static expr_ty power_rule(Parser *p);
471static expr_ty await_primary_rule(Parser *p);
472static expr_ty primary_rule(Parser *p);
473static expr_ty slices_rule(Parser *p);
474static expr_ty slice_rule(Parser *p);
475static expr_ty atom_rule(Parser *p);
476static expr_ty strings_rule(Parser *p);
477static expr_ty list_rule(Parser *p);
478static expr_ty listcomp_rule(Parser *p);
479static expr_ty tuple_rule(Parser *p);
480static expr_ty group_rule(Parser *p);
481static expr_ty genexp_rule(Parser *p);
482static expr_ty set_rule(Parser *p);
483static expr_ty setcomp_rule(Parser *p);
484static expr_ty dict_rule(Parser *p);
485static expr_ty dictcomp_rule(Parser *p);
486static asdl_seq* kvpairs_rule(Parser *p);
487static KeyValuePair* kvpair_rule(Parser *p);
488static asdl_seq* for_if_clauses_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300489static comprehension_ty for_if_clause_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100490static expr_ty yield_expr_rule(Parser *p);
491static expr_ty arguments_rule(Parser *p);
492static expr_ty args_rule(Parser *p);
493static asdl_seq* kwargs_rule(Parser *p);
494static expr_ty starred_expression_rule(Parser *p);
495static KeywordOrStarred* kwarg_or_starred_rule(Parser *p);
496static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p);
497static expr_ty star_targets_rule(Parser *p);
498static asdl_seq* star_targets_seq_rule(Parser *p);
499static expr_ty star_target_rule(Parser *p);
500static expr_ty star_atom_rule(Parser *p);
501static expr_ty inside_paren_ann_assign_target_rule(Parser *p);
502static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p);
503static asdl_seq* del_targets_rule(Parser *p);
504static expr_ty del_target_rule(Parser *p);
505static expr_ty del_t_atom_rule(Parser *p);
506static asdl_seq* targets_rule(Parser *p);
507static expr_ty target_rule(Parser *p);
508static expr_ty t_primary_rule(Parser *p);
509static void *t_lookahead_rule(Parser *p);
510static expr_ty t_atom_rule(Parser *p);
511static void *incorrect_arguments_rule(Parser *p);
Lysandros Nikolaou4638c642020-05-07 13:44:06 +0300512static void *invalid_kwarg_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100513static void *invalid_named_expression_rule(Parser *p);
514static void *invalid_assignment_rule(Parser *p);
515static void *invalid_block_rule(Parser *p);
516static void *invalid_comprehension_rule(Parser *p);
517static void *invalid_parameters_rule(Parser *p);
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +0300518static void *invalid_star_etc_rule(Parser *p);
519static void *invalid_lambda_star_etc_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700520static void *invalid_double_type_comments_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100521static asdl_seq *_loop0_1_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700522static asdl_seq *_loop0_2_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100523static asdl_seq *_loop0_4_rule(Parser *p);
524static asdl_seq *_gather_3_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700525static asdl_seq *_loop0_6_rule(Parser *p);
526static asdl_seq *_gather_5_rule(Parser *p);
527static asdl_seq *_loop0_8_rule(Parser *p);
528static asdl_seq *_gather_7_rule(Parser *p);
529static asdl_seq *_loop0_10_rule(Parser *p);
530static asdl_seq *_gather_9_rule(Parser *p);
531static asdl_seq *_loop1_11_rule(Parser *p);
532static asdl_seq *_loop0_13_rule(Parser *p);
533static asdl_seq *_gather_12_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100534static void *_tmp_14_rule(Parser *p);
535static void *_tmp_15_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700536static void *_tmp_16_rule(Parser *p);
537static void *_tmp_17_rule(Parser *p);
538static void *_tmp_18_rule(Parser *p);
539static void *_tmp_19_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100540static void *_tmp_20_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700541static void *_tmp_21_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100542static asdl_seq *_loop1_22_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700543static void *_tmp_23_rule(Parser *p);
544static void *_tmp_24_rule(Parser *p);
545static asdl_seq *_loop0_26_rule(Parser *p);
546static asdl_seq *_gather_25_rule(Parser *p);
547static asdl_seq *_loop0_28_rule(Parser *p);
548static asdl_seq *_gather_27_rule(Parser *p);
549static void *_tmp_29_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100550static asdl_seq *_loop0_30_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700551static asdl_seq *_loop1_31_rule(Parser *p);
552static asdl_seq *_loop0_33_rule(Parser *p);
553static asdl_seq *_gather_32_rule(Parser *p);
554static void *_tmp_34_rule(Parser *p);
555static asdl_seq *_loop0_36_rule(Parser *p);
556static asdl_seq *_gather_35_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100557static void *_tmp_37_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700558static asdl_seq *_loop0_39_rule(Parser *p);
559static asdl_seq *_gather_38_rule(Parser *p);
560static asdl_seq *_loop0_41_rule(Parser *p);
561static asdl_seq *_gather_40_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300562static asdl_seq *_loop0_43_rule(Parser *p);
563static asdl_seq *_gather_42_rule(Parser *p);
564static asdl_seq *_loop0_45_rule(Parser *p);
565static asdl_seq *_gather_44_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100566static void *_tmp_46_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300567static asdl_seq *_loop1_47_rule(Parser *p);
568static void *_tmp_48_rule(Parser *p);
569static void *_tmp_49_rule(Parser *p);
570static void *_tmp_50_rule(Parser *p);
571static void *_tmp_51_rule(Parser *p);
572static void *_tmp_52_rule(Parser *p);
573static asdl_seq *_loop0_53_rule(Parser *p);
574static asdl_seq *_loop0_54_rule(Parser *p);
575static asdl_seq *_loop0_55_rule(Parser *p);
576static asdl_seq *_loop1_56_rule(Parser *p);
577static asdl_seq *_loop0_57_rule(Parser *p);
578static asdl_seq *_loop1_58_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700579static asdl_seq *_loop1_59_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300580static asdl_seq *_loop1_60_rule(Parser *p);
581static asdl_seq *_loop0_61_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700582static asdl_seq *_loop1_62_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300583static asdl_seq *_loop0_63_rule(Parser *p);
584static asdl_seq *_loop1_64_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700585static asdl_seq *_loop0_65_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700586static asdl_seq *_loop1_66_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300587static asdl_seq *_loop1_67_rule(Parser *p);
588static void *_tmp_68_rule(Parser *p);
589static asdl_seq *_loop0_70_rule(Parser *p);
590static asdl_seq *_gather_69_rule(Parser *p);
591static asdl_seq *_loop1_71_rule(Parser *p);
592static asdl_seq *_loop0_73_rule(Parser *p);
593static asdl_seq *_gather_72_rule(Parser *p);
594static asdl_seq *_loop1_74_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700595static asdl_seq *_loop0_75_rule(Parser *p);
596static asdl_seq *_loop0_76_rule(Parser *p);
597static asdl_seq *_loop0_77_rule(Parser *p);
598static asdl_seq *_loop1_78_rule(Parser *p);
599static asdl_seq *_loop0_79_rule(Parser *p);
600static asdl_seq *_loop1_80_rule(Parser *p);
601static asdl_seq *_loop1_81_rule(Parser *p);
602static asdl_seq *_loop1_82_rule(Parser *p);
603static asdl_seq *_loop0_83_rule(Parser *p);
604static asdl_seq *_loop1_84_rule(Parser *p);
605static asdl_seq *_loop0_85_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300606static asdl_seq *_loop1_86_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700607static asdl_seq *_loop0_87_rule(Parser *p);
608static asdl_seq *_loop1_88_rule(Parser *p);
609static asdl_seq *_loop1_89_rule(Parser *p);
610static asdl_seq *_loop1_90_rule(Parser *p);
611static asdl_seq *_loop1_91_rule(Parser *p);
612static void *_tmp_92_rule(Parser *p);
613static asdl_seq *_loop0_94_rule(Parser *p);
614static asdl_seq *_gather_93_rule(Parser *p);
615static void *_tmp_95_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700616static void *_tmp_96_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700617static void *_tmp_97_rule(Parser *p);
618static void *_tmp_98_rule(Parser *p);
619static asdl_seq *_loop1_99_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100620static void *_tmp_100_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300621static void *_tmp_101_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700622static asdl_seq *_loop0_103_rule(Parser *p);
623static asdl_seq *_gather_102_rule(Parser *p);
624static asdl_seq *_loop1_104_rule(Parser *p);
625static asdl_seq *_loop0_105_rule(Parser *p);
626static asdl_seq *_loop0_106_rule(Parser *p);
627static void *_tmp_107_rule(Parser *p);
628static void *_tmp_108_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300629static asdl_seq *_loop0_110_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700630static asdl_seq *_gather_109_rule(Parser *p);
631static asdl_seq *_loop0_112_rule(Parser *p);
632static asdl_seq *_gather_111_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100633static asdl_seq *_loop0_114_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300634static asdl_seq *_gather_113_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100635static asdl_seq *_loop0_116_rule(Parser *p);
636static asdl_seq *_gather_115_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700637static asdl_seq *_loop0_117_rule(Parser *p);
638static asdl_seq *_loop0_119_rule(Parser *p);
639static asdl_seq *_gather_118_rule(Parser *p);
640static void *_tmp_120_rule(Parser *p);
641static asdl_seq *_loop0_122_rule(Parser *p);
642static asdl_seq *_gather_121_rule(Parser *p);
643static asdl_seq *_loop0_124_rule(Parser *p);
644static asdl_seq *_gather_123_rule(Parser *p);
645static void *_tmp_125_rule(Parser *p);
646static void *_tmp_126_rule(Parser *p);
647static void *_tmp_127_rule(Parser *p);
648static void *_tmp_128_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100649static void *_tmp_129_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700650static asdl_seq *_loop0_130_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100651static void *_tmp_131_rule(Parser *p);
652static void *_tmp_132_rule(Parser *p);
653static void *_tmp_133_rule(Parser *p);
Guido van Rossum3941d972020-05-01 09:42:03 -0700654static void *_tmp_134_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100655static void *_tmp_135_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700656static void *_tmp_136_rule(Parser *p);
Pablo Galindo2b74c832020-04-27 18:02:07 +0100657static void *_tmp_137_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700658static void *_tmp_138_rule(Parser *p);
659static void *_tmp_139_rule(Parser *p);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +0300660static void *_tmp_140_rule(Parser *p);
661static void *_tmp_141_rule(Parser *p);
Guido van Rossumc001c092020-04-30 12:12:19 -0700662static void *_tmp_142_rule(Parser *p);
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +0300663static void *_tmp_143_rule(Parser *p);
664static void *_tmp_144_rule(Parser *p);
665static asdl_seq *_loop1_145_rule(Parser *p);
666static void *_tmp_146_rule(Parser *p);
667static void *_tmp_147_rule(Parser *p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100668
669
670// file: statements? $
671static mod_ty
672file_rule(Parser *p)
673{
674 if (p->error_indicator) {
675 return NULL;
676 }
677 mod_ty res = NULL;
678 int mark = p->mark;
679 { // statements? $
680 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100681 Token * endmarker_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100682 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100683 (a = statements_rule(p), 1) // statements?
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100684 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100685 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100686 )
687 {
Guido van Rossumc001c092020-04-30 12:12:19 -0700688 res = _PyPegen_make_module ( p , a );
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100689 if (res == NULL && PyErr_Occurred()) {
690 p->error_indicator = 1;
691 return NULL;
692 }
693 goto done;
694 }
695 p->mark = mark;
696 }
697 res = NULL;
698 done:
699 return res;
700}
701
702// interactive: statement_newline
703static mod_ty
704interactive_rule(Parser *p)
705{
706 if (p->error_indicator) {
707 return NULL;
708 }
709 mod_ty res = NULL;
710 int mark = p->mark;
711 { // statement_newline
712 asdl_seq* a;
713 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100714 (a = statement_newline_rule(p)) // statement_newline
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100715 )
716 {
717 res = Interactive ( a , p -> arena );
718 if (res == NULL && PyErr_Occurred()) {
719 p->error_indicator = 1;
720 return NULL;
721 }
722 goto done;
723 }
724 p->mark = mark;
725 }
726 res = NULL;
727 done:
728 return res;
729}
730
731// eval: expressions NEWLINE* $
732static mod_ty
733eval_rule(Parser *p)
734{
735 if (p->error_indicator) {
736 return NULL;
737 }
738 mod_ty res = NULL;
739 int mark = p->mark;
740 { // expressions NEWLINE* $
741 asdl_seq * _loop0_1_var;
742 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100743 Token * endmarker_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100744 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100745 (a = expressions_rule(p)) // expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100746 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100747 (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE*
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100748 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100749 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100750 )
751 {
752 res = Expression ( a , p -> arena );
753 if (res == NULL && PyErr_Occurred()) {
754 p->error_indicator = 1;
755 return NULL;
756 }
757 goto done;
758 }
759 p->mark = mark;
760 }
761 res = NULL;
762 done:
763 return res;
764}
765
Guido van Rossumc001c092020-04-30 12:12:19 -0700766// func_type: '(' type_expressions? ')' '->' expression NEWLINE* $
767static mod_ty
768func_type_rule(Parser *p)
769{
770 if (p->error_indicator) {
771 return NULL;
772 }
773 mod_ty res = NULL;
774 int mark = p->mark;
775 { // '(' type_expressions? ')' '->' expression NEWLINE* $
776 asdl_seq * _loop0_2_var;
777 void *a;
778 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100779 Token * endmarker_var;
780 Token * literal;
781 Token * literal_1;
782 Token * literal_2;
Guido van Rossumc001c092020-04-30 12:12:19 -0700783 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100784 (literal = _PyPegen_expect_token(p, 7)) // token='('
Guido van Rossumc001c092020-04-30 12:12:19 -0700785 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100786 (a = type_expressions_rule(p), 1) // type_expressions?
Guido van Rossumc001c092020-04-30 12:12:19 -0700787 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100788 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Guido van Rossumc001c092020-04-30 12:12:19 -0700789 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100790 (literal_2 = _PyPegen_expect_token(p, 51)) // token='->'
Guido van Rossumc001c092020-04-30 12:12:19 -0700791 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100792 (b = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -0700793 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100794 (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE*
Guido van Rossumc001c092020-04-30 12:12:19 -0700795 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100796 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
Guido van Rossumc001c092020-04-30 12:12:19 -0700797 )
798 {
799 res = FunctionType ( a , b , p -> arena );
800 if (res == NULL && PyErr_Occurred()) {
801 p->error_indicator = 1;
802 return NULL;
803 }
804 goto done;
805 }
806 p->mark = mark;
807 }
808 res = NULL;
809 done:
810 return res;
811}
812
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100813// fstring: star_expressions
814static expr_ty
815fstring_rule(Parser *p)
816{
817 if (p->error_indicator) {
818 return NULL;
819 }
820 expr_ty res = NULL;
821 int mark = p->mark;
822 { // star_expressions
823 expr_ty star_expressions_var;
824 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100825 (star_expressions_var = star_expressions_rule(p)) // star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +0100826 )
827 {
828 res = star_expressions_var;
829 goto done;
830 }
831 p->mark = mark;
832 }
833 res = NULL;
834 done:
835 return res;
836}
837
Guido van Rossumc001c092020-04-30 12:12:19 -0700838// type_expressions:
839// | ','.expression+ ',' '*' expression ',' '**' expression
840// | ','.expression+ ',' '*' expression
841// | ','.expression+ ',' '**' expression
Shantanu603d3542020-05-03 22:08:14 -0700842// | '*' expression ',' '**' expression
843// | '*' expression
844// | '**' expression
Guido van Rossumc001c092020-04-30 12:12:19 -0700845// | ','.expression+
846static asdl_seq*
847type_expressions_rule(Parser *p)
848{
849 if (p->error_indicator) {
850 return NULL;
851 }
852 asdl_seq* res = NULL;
853 int mark = p->mark;
854 { // ','.expression+ ',' '*' expression ',' '**' expression
855 asdl_seq * a;
856 expr_ty b;
857 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100858 Token * literal;
859 Token * literal_1;
860 Token * literal_2;
861 Token * literal_3;
Guido van Rossumc001c092020-04-30 12:12:19 -0700862 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100863 (a = _gather_3_rule(p)) // ','.expression+
Guido van Rossumc001c092020-04-30 12:12:19 -0700864 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100865 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -0700866 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100867 (literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
Guido van Rossumc001c092020-04-30 12:12:19 -0700868 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100869 (b = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -0700870 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100871 (literal_2 = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -0700872 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100873 (literal_3 = _PyPegen_expect_token(p, 35)) // token='**'
Guido van Rossumc001c092020-04-30 12:12:19 -0700874 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100875 (c = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -0700876 )
877 {
878 res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c );
879 if (res == NULL && PyErr_Occurred()) {
880 p->error_indicator = 1;
881 return NULL;
882 }
883 goto done;
884 }
885 p->mark = mark;
886 }
887 { // ','.expression+ ',' '*' expression
888 asdl_seq * a;
889 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100890 Token * literal;
891 Token * literal_1;
Guido van Rossumc001c092020-04-30 12:12:19 -0700892 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100893 (a = _gather_5_rule(p)) // ','.expression+
Guido van Rossumc001c092020-04-30 12:12:19 -0700894 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100895 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -0700896 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100897 (literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
Guido van Rossumc001c092020-04-30 12:12:19 -0700898 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100899 (b = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -0700900 )
901 {
902 res = _PyPegen_seq_append_to_end ( p , a , b );
903 if (res == NULL && PyErr_Occurred()) {
904 p->error_indicator = 1;
905 return NULL;
906 }
907 goto done;
908 }
909 p->mark = mark;
910 }
911 { // ','.expression+ ',' '**' expression
912 asdl_seq * a;
913 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +0100914 Token * literal;
915 Token * literal_1;
Guido van Rossumc001c092020-04-30 12:12:19 -0700916 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100917 (a = _gather_7_rule(p)) // ','.expression+
Guido van Rossumc001c092020-04-30 12:12:19 -0700918 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100919 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -0700920 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100921 (literal_1 = _PyPegen_expect_token(p, 35)) // token='**'
Guido van Rossumc001c092020-04-30 12:12:19 -0700922 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100923 (b = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -0700924 )
925 {
926 res = _PyPegen_seq_append_to_end ( p , a , b );
927 if (res == NULL && PyErr_Occurred()) {
928 p->error_indicator = 1;
929 return NULL;
930 }
931 goto done;
932 }
933 p->mark = mark;
934 }
Shantanu603d3542020-05-03 22:08:14 -0700935 { // '*' expression ',' '**' expression
936 expr_ty a;
937 expr_ty b;
938 Token * literal;
939 Token * literal_1;
940 Token * literal_2;
941 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100942 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Shantanu603d3542020-05-03 22:08:14 -0700943 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100944 (a = expression_rule(p)) // expression
Shantanu603d3542020-05-03 22:08:14 -0700945 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100946 (literal_1 = _PyPegen_expect_token(p, 12)) // token=','
Shantanu603d3542020-05-03 22:08:14 -0700947 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100948 (literal_2 = _PyPegen_expect_token(p, 35)) // token='**'
Shantanu603d3542020-05-03 22:08:14 -0700949 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100950 (b = expression_rule(p)) // expression
Shantanu603d3542020-05-03 22:08:14 -0700951 )
952 {
953 res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b );
954 if (res == NULL && PyErr_Occurred()) {
955 p->error_indicator = 1;
956 return NULL;
957 }
958 goto done;
959 }
960 p->mark = mark;
961 }
962 { // '*' expression
963 expr_ty a;
964 Token * literal;
965 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100966 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Shantanu603d3542020-05-03 22:08:14 -0700967 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100968 (a = expression_rule(p)) // expression
Shantanu603d3542020-05-03 22:08:14 -0700969 )
970 {
971 res = _PyPegen_singleton_seq ( p , a );
972 if (res == NULL && PyErr_Occurred()) {
973 p->error_indicator = 1;
974 return NULL;
975 }
976 goto done;
977 }
978 p->mark = mark;
979 }
980 { // '**' expression
981 expr_ty a;
982 Token * literal;
983 if (
Pablo Galindo470aac42020-05-06 23:14:43 +0100984 (literal = _PyPegen_expect_token(p, 35)) // token='**'
Shantanu603d3542020-05-03 22:08:14 -0700985 &&
Pablo Galindo470aac42020-05-06 23:14:43 +0100986 (a = expression_rule(p)) // expression
Shantanu603d3542020-05-03 22:08:14 -0700987 )
988 {
989 res = _PyPegen_singleton_seq ( p , a );
990 if (res == NULL && PyErr_Occurred()) {
991 p->error_indicator = 1;
992 return NULL;
993 }
994 goto done;
995 }
996 p->mark = mark;
997 }
Guido van Rossumc001c092020-04-30 12:12:19 -0700998 { // ','.expression+
999 asdl_seq * _gather_9_var;
1000 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001001 (_gather_9_var = _gather_9_rule(p)) // ','.expression+
Guido van Rossumc001c092020-04-30 12:12:19 -07001002 )
1003 {
1004 res = _gather_9_var;
1005 goto done;
1006 }
1007 p->mark = mark;
1008 }
1009 res = NULL;
1010 done:
1011 return res;
1012}
1013
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001014// statements: statement+
1015static asdl_seq*
1016statements_rule(Parser *p)
1017{
1018 if (p->error_indicator) {
1019 return NULL;
1020 }
1021 asdl_seq* res = NULL;
1022 int mark = p->mark;
1023 { // statement+
1024 asdl_seq * a;
1025 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001026 (a = _loop1_11_rule(p)) // statement+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001027 )
1028 {
1029 res = _PyPegen_seq_flatten ( p , a );
1030 if (res == NULL && PyErr_Occurred()) {
1031 p->error_indicator = 1;
1032 return NULL;
1033 }
1034 goto done;
1035 }
1036 p->mark = mark;
1037 }
1038 res = NULL;
1039 done:
1040 return res;
1041}
1042
1043// statement: compound_stmt | simple_stmt
1044static asdl_seq*
1045statement_rule(Parser *p)
1046{
1047 if (p->error_indicator) {
1048 return NULL;
1049 }
1050 asdl_seq* res = NULL;
1051 int mark = p->mark;
1052 { // compound_stmt
1053 stmt_ty a;
1054 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001055 (a = compound_stmt_rule(p)) // compound_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001056 )
1057 {
1058 res = _PyPegen_singleton_seq ( p , a );
1059 if (res == NULL && PyErr_Occurred()) {
1060 p->error_indicator = 1;
1061 return NULL;
1062 }
1063 goto done;
1064 }
1065 p->mark = mark;
1066 }
1067 { // simple_stmt
1068 asdl_seq* simple_stmt_var;
1069 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001070 (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001071 )
1072 {
1073 res = simple_stmt_var;
1074 goto done;
1075 }
1076 p->mark = mark;
1077 }
1078 res = NULL;
1079 done:
1080 return res;
1081}
1082
1083// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
1084static asdl_seq*
1085statement_newline_rule(Parser *p)
1086{
1087 if (p->error_indicator) {
1088 return NULL;
1089 }
1090 asdl_seq* res = NULL;
1091 int mark = p->mark;
1092 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1093 p->error_indicator = 1;
1094 return NULL;
1095 }
1096 int start_lineno = p->tokens[mark]->lineno;
1097 UNUSED(start_lineno); // Only used by EXTRA macro
1098 int start_col_offset = p->tokens[mark]->col_offset;
1099 UNUSED(start_col_offset); // Only used by EXTRA macro
1100 { // compound_stmt NEWLINE
1101 stmt_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001102 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001103 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001104 (a = compound_stmt_rule(p)) // compound_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001105 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001106 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001107 )
1108 {
1109 res = _PyPegen_singleton_seq ( p , a );
1110 if (res == NULL && PyErr_Occurred()) {
1111 p->error_indicator = 1;
1112 return NULL;
1113 }
1114 goto done;
1115 }
1116 p->mark = mark;
1117 }
1118 { // simple_stmt
1119 asdl_seq* simple_stmt_var;
1120 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001121 (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001122 )
1123 {
1124 res = simple_stmt_var;
1125 goto done;
1126 }
1127 p->mark = mark;
1128 }
1129 { // NEWLINE
Pablo Galindob796b3f2020-05-01 12:32:26 +01001130 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001131 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001132 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001133 )
1134 {
1135 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1136 if (token == NULL) {
1137 return NULL;
1138 }
1139 int end_lineno = token->end_lineno;
1140 UNUSED(end_lineno); // Only used by EXTRA macro
1141 int end_col_offset = token->end_col_offset;
1142 UNUSED(end_col_offset); // Only used by EXTRA macro
1143 res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) );
1144 if (res == NULL && PyErr_Occurred()) {
1145 p->error_indicator = 1;
1146 return NULL;
1147 }
1148 goto done;
1149 }
1150 p->mark = mark;
1151 }
1152 { // $
Pablo Galindob796b3f2020-05-01 12:32:26 +01001153 Token * endmarker_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001154 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001155 (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001156 )
1157 {
1158 res = _PyPegen_interactive_exit ( p );
1159 if (res == NULL && PyErr_Occurred()) {
1160 p->error_indicator = 1;
1161 return NULL;
1162 }
1163 goto done;
1164 }
1165 p->mark = mark;
1166 }
1167 res = NULL;
1168 done:
1169 return res;
1170}
1171
1172// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
1173static asdl_seq*
1174simple_stmt_rule(Parser *p)
1175{
1176 if (p->error_indicator) {
1177 return NULL;
1178 }
1179 asdl_seq* res = NULL;
1180 int mark = p->mark;
1181 { // small_stmt !';' NEWLINE
1182 stmt_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001183 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001184 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001185 (a = small_stmt_rule(p)) // small_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001186 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001187 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001188 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001189 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001190 )
1191 {
1192 res = _PyPegen_singleton_seq ( p , a );
1193 if (res == NULL && PyErr_Occurred()) {
1194 p->error_indicator = 1;
1195 return NULL;
1196 }
1197 goto done;
1198 }
1199 p->mark = mark;
1200 }
1201 { // ';'.small_stmt+ ';'? NEWLINE
1202 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001203 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001204 void *opt_var;
1205 UNUSED(opt_var); // Silence compiler warnings
1206 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001207 (a = _gather_12_rule(p)) // ';'.small_stmt+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001208 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001209 (opt_var = _PyPegen_expect_token(p, 13), 1) // ';'?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001210 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001211 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001212 )
1213 {
1214 res = a;
1215 if (res == NULL && PyErr_Occurred()) {
1216 p->error_indicator = 1;
1217 return NULL;
1218 }
1219 goto done;
1220 }
1221 p->mark = mark;
1222 }
1223 res = NULL;
1224 done:
1225 return res;
1226}
1227
1228// small_stmt:
1229// | assignment
1230// | star_expressions
1231// | &'return' return_stmt
1232// | &('import' | 'from') import_stmt
1233// | &'raise' raise_stmt
1234// | 'pass'
1235// | &'del' del_stmt
1236// | &'yield' yield_stmt
1237// | &'assert' assert_stmt
1238// | 'break'
1239// | 'continue'
1240// | &'global' global_stmt
1241// | &'nonlocal' nonlocal_stmt
1242static stmt_ty
1243small_stmt_rule(Parser *p)
1244{
1245 if (p->error_indicator) {
1246 return NULL;
1247 }
1248 stmt_ty res = NULL;
1249 if (_PyPegen_is_memoized(p, small_stmt_type, &res))
1250 return res;
1251 int mark = p->mark;
1252 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1253 p->error_indicator = 1;
1254 return NULL;
1255 }
1256 int start_lineno = p->tokens[mark]->lineno;
1257 UNUSED(start_lineno); // Only used by EXTRA macro
1258 int start_col_offset = p->tokens[mark]->col_offset;
1259 UNUSED(start_col_offset); // Only used by EXTRA macro
1260 { // assignment
Lysandros Nikolaou999ec9a2020-05-06 21:11:04 +03001261 stmt_ty assignment_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001262 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001263 (assignment_var = assignment_rule(p)) // assignment
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001264 )
1265 {
1266 res = assignment_var;
1267 goto done;
1268 }
1269 p->mark = mark;
1270 }
1271 { // star_expressions
1272 expr_ty e;
1273 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001274 (e = star_expressions_rule(p)) // star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001275 )
1276 {
1277 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1278 if (token == NULL) {
1279 return NULL;
1280 }
1281 int end_lineno = token->end_lineno;
1282 UNUSED(end_lineno); // Only used by EXTRA macro
1283 int end_col_offset = token->end_col_offset;
1284 UNUSED(end_col_offset); // Only used by EXTRA macro
1285 res = _Py_Expr ( e , EXTRA );
1286 if (res == NULL && PyErr_Occurred()) {
1287 p->error_indicator = 1;
1288 return NULL;
1289 }
1290 goto done;
1291 }
1292 p->mark = mark;
1293 }
1294 { // &'return' return_stmt
1295 stmt_ty return_stmt_var;
1296 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001297 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001298 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001299 (return_stmt_var = return_stmt_rule(p)) // return_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001300 )
1301 {
1302 res = return_stmt_var;
1303 goto done;
1304 }
1305 p->mark = mark;
1306 }
1307 { // &('import' | 'from') import_stmt
1308 stmt_ty import_stmt_var;
1309 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001310 _PyPegen_lookahead(1, _tmp_14_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001311 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001312 (import_stmt_var = import_stmt_rule(p)) // import_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001313 )
1314 {
1315 res = import_stmt_var;
1316 goto done;
1317 }
1318 p->mark = mark;
1319 }
1320 { // &'raise' raise_stmt
1321 stmt_ty raise_stmt_var;
1322 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001323 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001324 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001325 (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001326 )
1327 {
1328 res = raise_stmt_var;
1329 goto done;
1330 }
1331 p->mark = mark;
1332 }
1333 { // 'pass'
Pablo Galindob796b3f2020-05-01 12:32:26 +01001334 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001335 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001336 (keyword = _PyPegen_expect_token(p, 502)) // token='pass'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001337 )
1338 {
1339 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1340 if (token == NULL) {
1341 return NULL;
1342 }
1343 int end_lineno = token->end_lineno;
1344 UNUSED(end_lineno); // Only used by EXTRA macro
1345 int end_col_offset = token->end_col_offset;
1346 UNUSED(end_col_offset); // Only used by EXTRA macro
1347 res = _Py_Pass ( EXTRA );
1348 if (res == NULL && PyErr_Occurred()) {
1349 p->error_indicator = 1;
1350 return NULL;
1351 }
1352 goto done;
1353 }
1354 p->mark = mark;
1355 }
1356 { // &'del' del_stmt
1357 stmt_ty del_stmt_var;
1358 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001359 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001360 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001361 (del_stmt_var = del_stmt_rule(p)) // del_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001362 )
1363 {
1364 res = del_stmt_var;
1365 goto done;
1366 }
1367 p->mark = mark;
1368 }
1369 { // &'yield' yield_stmt
1370 stmt_ty yield_stmt_var;
1371 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001372 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001373 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001374 (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001375 )
1376 {
1377 res = yield_stmt_var;
1378 goto done;
1379 }
1380 p->mark = mark;
1381 }
1382 { // &'assert' assert_stmt
1383 stmt_ty assert_stmt_var;
1384 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001385 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001386 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001387 (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001388 )
1389 {
1390 res = assert_stmt_var;
1391 goto done;
1392 }
1393 p->mark = mark;
1394 }
1395 { // 'break'
Pablo Galindob796b3f2020-05-01 12:32:26 +01001396 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001397 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001398 (keyword = _PyPegen_expect_token(p, 506)) // token='break'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001399 )
1400 {
1401 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1402 if (token == NULL) {
1403 return NULL;
1404 }
1405 int end_lineno = token->end_lineno;
1406 UNUSED(end_lineno); // Only used by EXTRA macro
1407 int end_col_offset = token->end_col_offset;
1408 UNUSED(end_col_offset); // Only used by EXTRA macro
1409 res = _Py_Break ( EXTRA );
1410 if (res == NULL && PyErr_Occurred()) {
1411 p->error_indicator = 1;
1412 return NULL;
1413 }
1414 goto done;
1415 }
1416 p->mark = mark;
1417 }
1418 { // 'continue'
Pablo Galindob796b3f2020-05-01 12:32:26 +01001419 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001420 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001421 (keyword = _PyPegen_expect_token(p, 507)) // token='continue'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001422 )
1423 {
1424 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1425 if (token == NULL) {
1426 return NULL;
1427 }
1428 int end_lineno = token->end_lineno;
1429 UNUSED(end_lineno); // Only used by EXTRA macro
1430 int end_col_offset = token->end_col_offset;
1431 UNUSED(end_col_offset); // Only used by EXTRA macro
1432 res = _Py_Continue ( EXTRA );
1433 if (res == NULL && PyErr_Occurred()) {
1434 p->error_indicator = 1;
1435 return NULL;
1436 }
1437 goto done;
1438 }
1439 p->mark = mark;
1440 }
1441 { // &'global' global_stmt
1442 stmt_ty global_stmt_var;
1443 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001444 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001445 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001446 (global_stmt_var = global_stmt_rule(p)) // global_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001447 )
1448 {
1449 res = global_stmt_var;
1450 goto done;
1451 }
1452 p->mark = mark;
1453 }
1454 { // &'nonlocal' nonlocal_stmt
1455 stmt_ty nonlocal_stmt_var;
1456 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001457 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001458 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001459 (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001460 )
1461 {
1462 res = nonlocal_stmt_var;
1463 goto done;
1464 }
1465 p->mark = mark;
1466 }
1467 res = NULL;
1468 done:
1469 _PyPegen_insert_memo(p, mark, small_stmt_type, res);
1470 return res;
1471}
1472
1473// compound_stmt:
1474// | &('def' | '@' | ASYNC) function_def
1475// | &'if' if_stmt
1476// | &('class' | '@') class_def
1477// | &('with' | ASYNC) with_stmt
1478// | &('for' | ASYNC) for_stmt
1479// | &'try' try_stmt
1480// | &'while' while_stmt
1481static stmt_ty
1482compound_stmt_rule(Parser *p)
1483{
1484 if (p->error_indicator) {
1485 return NULL;
1486 }
1487 stmt_ty res = NULL;
1488 int mark = p->mark;
1489 { // &('def' | '@' | ASYNC) function_def
1490 stmt_ty function_def_var;
1491 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001492 _PyPegen_lookahead(1, _tmp_15_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001493 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001494 (function_def_var = function_def_rule(p)) // function_def
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001495 )
1496 {
1497 res = function_def_var;
1498 goto done;
1499 }
1500 p->mark = mark;
1501 }
1502 { // &'if' if_stmt
1503 stmt_ty if_stmt_var;
1504 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001505 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001506 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001507 (if_stmt_var = if_stmt_rule(p)) // if_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001508 )
1509 {
1510 res = if_stmt_var;
1511 goto done;
1512 }
1513 p->mark = mark;
1514 }
1515 { // &('class' | '@') class_def
1516 stmt_ty class_def_var;
1517 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001518 _PyPegen_lookahead(1, _tmp_16_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001519 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001520 (class_def_var = class_def_rule(p)) // class_def
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001521 )
1522 {
1523 res = class_def_var;
1524 goto done;
1525 }
1526 p->mark = mark;
1527 }
1528 { // &('with' | ASYNC) with_stmt
1529 stmt_ty with_stmt_var;
1530 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001531 _PyPegen_lookahead(1, _tmp_17_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001532 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001533 (with_stmt_var = with_stmt_rule(p)) // with_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001534 )
1535 {
1536 res = with_stmt_var;
1537 goto done;
1538 }
1539 p->mark = mark;
1540 }
1541 { // &('for' | ASYNC) for_stmt
1542 stmt_ty for_stmt_var;
1543 if (
Guido van Rossumc001c092020-04-30 12:12:19 -07001544 _PyPegen_lookahead(1, _tmp_18_rule, p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001545 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001546 (for_stmt_var = for_stmt_rule(p)) // for_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001547 )
1548 {
1549 res = for_stmt_var;
1550 goto done;
1551 }
1552 p->mark = mark;
1553 }
1554 { // &'try' try_stmt
1555 stmt_ty try_stmt_var;
1556 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001557 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001558 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001559 (try_stmt_var = try_stmt_rule(p)) // try_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001560 )
1561 {
1562 res = try_stmt_var;
1563 goto done;
1564 }
1565 p->mark = mark;
1566 }
1567 { // &'while' while_stmt
1568 stmt_ty while_stmt_var;
1569 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001570 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001571 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001572 (while_stmt_var = while_stmt_rule(p)) // while_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001573 )
1574 {
1575 res = while_stmt_var;
1576 goto done;
1577 }
1578 p->mark = mark;
1579 }
1580 res = NULL;
1581 done:
1582 return res;
1583}
1584
1585// assignment:
1586// | NAME ':' expression ['=' annotated_rhs]
1587// | ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs]
Guido van Rossumc001c092020-04-30 12:12:19 -07001588// | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001589// | target augassign (yield_expr | star_expressions)
1590// | invalid_assignment
Lysandros Nikolaou999ec9a2020-05-06 21:11:04 +03001591static stmt_ty
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001592assignment_rule(Parser *p)
1593{
1594 if (p->error_indicator) {
1595 return NULL;
1596 }
Lysandros Nikolaou999ec9a2020-05-06 21:11:04 +03001597 stmt_ty res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001598 int mark = p->mark;
1599 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1600 p->error_indicator = 1;
1601 return NULL;
1602 }
1603 int start_lineno = p->tokens[mark]->lineno;
1604 UNUSED(start_lineno); // Only used by EXTRA macro
1605 int start_col_offset = p->tokens[mark]->col_offset;
1606 UNUSED(start_col_offset); // Only used by EXTRA macro
1607 { // NAME ':' expression ['=' annotated_rhs]
1608 expr_ty a;
1609 expr_ty b;
1610 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001611 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001612 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001613 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001614 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001615 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001616 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001617 (b = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001618 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001619 (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001620 )
1621 {
1622 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1623 if (token == NULL) {
1624 return NULL;
1625 }
1626 int end_lineno = token->end_lineno;
1627 UNUSED(end_lineno); // Only used by EXTRA macro
1628 int end_col_offset = token->end_col_offset;
1629 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001630 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 +01001631 if (res == NULL && PyErr_Occurred()) {
1632 p->error_indicator = 1;
1633 return NULL;
1634 }
1635 goto done;
1636 }
1637 p->mark = mark;
1638 }
1639 { // ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs]
1640 void *a;
1641 expr_ty b;
1642 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001643 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001644 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001645 (a = _tmp_20_rule(p)) // '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001646 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001647 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001648 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001649 (b = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001650 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001651 (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001652 )
1653 {
1654 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1655 if (token == NULL) {
1656 return NULL;
1657 }
1658 int end_lineno = token->end_lineno;
1659 UNUSED(end_lineno); // Only used by EXTRA macro
1660 int end_col_offset = token->end_col_offset;
1661 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001662 res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001663 if (res == NULL && PyErr_Occurred()) {
1664 p->error_indicator = 1;
1665 return NULL;
1666 }
1667 goto done;
1668 }
1669 p->mark = mark;
1670 }
Guido van Rossumc001c092020-04-30 12:12:19 -07001671 { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001672 asdl_seq * a;
1673 void *b;
Guido van Rossumc001c092020-04-30 12:12:19 -07001674 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001675 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001676 (a = _loop1_22_rule(p)) // ((star_targets '='))+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001677 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001678 (b = _tmp_23_rule(p)) // yield_expr | star_expressions
Guido van Rossumc001c092020-04-30 12:12:19 -07001679 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001680 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001681 )
1682 {
1683 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1684 if (token == NULL) {
1685 return NULL;
1686 }
1687 int end_lineno = token->end_lineno;
1688 UNUSED(end_lineno); // Only used by EXTRA macro
1689 int end_col_offset = token->end_col_offset;
1690 UNUSED(end_col_offset); // Only used by EXTRA macro
Guido van Rossumc001c092020-04-30 12:12:19 -07001691 res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001692 if (res == NULL && PyErr_Occurred()) {
1693 p->error_indicator = 1;
1694 return NULL;
1695 }
1696 goto done;
1697 }
1698 p->mark = mark;
1699 }
1700 { // target augassign (yield_expr | star_expressions)
1701 expr_ty a;
1702 AugOperator* b;
1703 void *c;
1704 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001705 (a = target_rule(p)) // target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001706 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001707 (b = augassign_rule(p)) // augassign
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001708 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001709 (c = _tmp_24_rule(p)) // yield_expr | star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001710 )
1711 {
1712 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1713 if (token == NULL) {
1714 return NULL;
1715 }
1716 int end_lineno = token->end_lineno;
1717 UNUSED(end_lineno); // Only used by EXTRA macro
1718 int end_col_offset = token->end_col_offset;
1719 UNUSED(end_col_offset); // Only used by EXTRA macro
1720 res = _Py_AugAssign ( a , b -> kind , c , EXTRA );
1721 if (res == NULL && PyErr_Occurred()) {
1722 p->error_indicator = 1;
1723 return NULL;
1724 }
1725 goto done;
1726 }
1727 p->mark = mark;
1728 }
1729 { // invalid_assignment
1730 void *invalid_assignment_var;
1731 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001732 (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001733 )
1734 {
1735 res = invalid_assignment_var;
1736 goto done;
1737 }
1738 p->mark = mark;
1739 }
1740 res = NULL;
1741 done:
1742 return res;
1743}
1744
1745// augassign:
1746// | '+='
1747// | '-='
1748// | '*='
1749// | '@='
1750// | '/='
1751// | '%='
1752// | '&='
1753// | '|='
1754// | '^='
1755// | '<<='
1756// | '>>='
1757// | '**='
1758// | '//='
1759static AugOperator*
1760augassign_rule(Parser *p)
1761{
1762 if (p->error_indicator) {
1763 return NULL;
1764 }
1765 AugOperator* res = NULL;
1766 int mark = p->mark;
1767 { // '+='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001768 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001769 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001770 (literal = _PyPegen_expect_token(p, 36)) // token='+='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001771 )
1772 {
1773 res = _PyPegen_augoperator ( p , Add );
1774 if (res == NULL && PyErr_Occurred()) {
1775 p->error_indicator = 1;
1776 return NULL;
1777 }
1778 goto done;
1779 }
1780 p->mark = mark;
1781 }
1782 { // '-='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001783 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001784 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001785 (literal = _PyPegen_expect_token(p, 37)) // token='-='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001786 )
1787 {
1788 res = _PyPegen_augoperator ( p , Sub );
1789 if (res == NULL && PyErr_Occurred()) {
1790 p->error_indicator = 1;
1791 return NULL;
1792 }
1793 goto done;
1794 }
1795 p->mark = mark;
1796 }
1797 { // '*='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001798 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001799 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001800 (literal = _PyPegen_expect_token(p, 38)) // token='*='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001801 )
1802 {
1803 res = _PyPegen_augoperator ( p , Mult );
1804 if (res == NULL && PyErr_Occurred()) {
1805 p->error_indicator = 1;
1806 return NULL;
1807 }
1808 goto done;
1809 }
1810 p->mark = mark;
1811 }
1812 { // '@='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001813 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001814 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001815 (literal = _PyPegen_expect_token(p, 50)) // token='@='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001816 )
1817 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03001818 res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001819 if (res == NULL && PyErr_Occurred()) {
1820 p->error_indicator = 1;
1821 return NULL;
1822 }
1823 goto done;
1824 }
1825 p->mark = mark;
1826 }
1827 { // '/='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001828 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001829 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001830 (literal = _PyPegen_expect_token(p, 39)) // token='/='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001831 )
1832 {
1833 res = _PyPegen_augoperator ( p , Div );
1834 if (res == NULL && PyErr_Occurred()) {
1835 p->error_indicator = 1;
1836 return NULL;
1837 }
1838 goto done;
1839 }
1840 p->mark = mark;
1841 }
1842 { // '%='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001843 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001844 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001845 (literal = _PyPegen_expect_token(p, 40)) // token='%='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001846 )
1847 {
1848 res = _PyPegen_augoperator ( p , Mod );
1849 if (res == NULL && PyErr_Occurred()) {
1850 p->error_indicator = 1;
1851 return NULL;
1852 }
1853 goto done;
1854 }
1855 p->mark = mark;
1856 }
1857 { // '&='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001858 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001859 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001860 (literal = _PyPegen_expect_token(p, 41)) // token='&='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001861 )
1862 {
1863 res = _PyPegen_augoperator ( p , BitAnd );
1864 if (res == NULL && PyErr_Occurred()) {
1865 p->error_indicator = 1;
1866 return NULL;
1867 }
1868 goto done;
1869 }
1870 p->mark = mark;
1871 }
1872 { // '|='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001873 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001874 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001875 (literal = _PyPegen_expect_token(p, 42)) // token='|='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001876 )
1877 {
1878 res = _PyPegen_augoperator ( p , BitOr );
1879 if (res == NULL && PyErr_Occurred()) {
1880 p->error_indicator = 1;
1881 return NULL;
1882 }
1883 goto done;
1884 }
1885 p->mark = mark;
1886 }
1887 { // '^='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001888 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001889 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001890 (literal = _PyPegen_expect_token(p, 43)) // token='^='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001891 )
1892 {
1893 res = _PyPegen_augoperator ( p , BitXor );
1894 if (res == NULL && PyErr_Occurred()) {
1895 p->error_indicator = 1;
1896 return NULL;
1897 }
1898 goto done;
1899 }
1900 p->mark = mark;
1901 }
1902 { // '<<='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001903 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001904 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001905 (literal = _PyPegen_expect_token(p, 44)) // token='<<='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001906 )
1907 {
1908 res = _PyPegen_augoperator ( p , LShift );
1909 if (res == NULL && PyErr_Occurred()) {
1910 p->error_indicator = 1;
1911 return NULL;
1912 }
1913 goto done;
1914 }
1915 p->mark = mark;
1916 }
1917 { // '>>='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001918 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001919 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001920 (literal = _PyPegen_expect_token(p, 45)) // token='>>='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001921 )
1922 {
1923 res = _PyPegen_augoperator ( p , RShift );
1924 if (res == NULL && PyErr_Occurred()) {
1925 p->error_indicator = 1;
1926 return NULL;
1927 }
1928 goto done;
1929 }
1930 p->mark = mark;
1931 }
1932 { // '**='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001933 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001934 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001935 (literal = _PyPegen_expect_token(p, 46)) // token='**='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001936 )
1937 {
1938 res = _PyPegen_augoperator ( p , Pow );
1939 if (res == NULL && PyErr_Occurred()) {
1940 p->error_indicator = 1;
1941 return NULL;
1942 }
1943 goto done;
1944 }
1945 p->mark = mark;
1946 }
1947 { // '//='
Pablo Galindob796b3f2020-05-01 12:32:26 +01001948 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001949 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001950 (literal = _PyPegen_expect_token(p, 48)) // token='//='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001951 )
1952 {
1953 res = _PyPegen_augoperator ( p , FloorDiv );
1954 if (res == NULL && PyErr_Occurred()) {
1955 p->error_indicator = 1;
1956 return NULL;
1957 }
1958 goto done;
1959 }
1960 p->mark = mark;
1961 }
1962 res = NULL;
1963 done:
1964 return res;
1965}
1966
1967// global_stmt: 'global' ','.NAME+
1968static stmt_ty
1969global_stmt_rule(Parser *p)
1970{
1971 if (p->error_indicator) {
1972 return NULL;
1973 }
1974 stmt_ty res = NULL;
1975 int mark = p->mark;
1976 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
1977 p->error_indicator = 1;
1978 return NULL;
1979 }
1980 int start_lineno = p->tokens[mark]->lineno;
1981 UNUSED(start_lineno); // Only used by EXTRA macro
1982 int start_col_offset = p->tokens[mark]->col_offset;
1983 UNUSED(start_col_offset); // Only used by EXTRA macro
1984 { // 'global' ','.NAME+
1985 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01001986 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001987 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01001988 (keyword = _PyPegen_expect_token(p, 508)) // token='global'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001989 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01001990 (a = _gather_25_rule(p)) // ','.NAME+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01001991 )
1992 {
1993 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
1994 if (token == NULL) {
1995 return NULL;
1996 }
1997 int end_lineno = token->end_lineno;
1998 UNUSED(end_lineno); // Only used by EXTRA macro
1999 int end_col_offset = token->end_col_offset;
2000 UNUSED(end_col_offset); // Only used by EXTRA macro
2001 res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
2002 if (res == NULL && PyErr_Occurred()) {
2003 p->error_indicator = 1;
2004 return NULL;
2005 }
2006 goto done;
2007 }
2008 p->mark = mark;
2009 }
2010 res = NULL;
2011 done:
2012 return res;
2013}
2014
2015// nonlocal_stmt: 'nonlocal' ','.NAME+
2016static stmt_ty
2017nonlocal_stmt_rule(Parser *p)
2018{
2019 if (p->error_indicator) {
2020 return NULL;
2021 }
2022 stmt_ty res = NULL;
2023 int mark = p->mark;
2024 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2025 p->error_indicator = 1;
2026 return NULL;
2027 }
2028 int start_lineno = p->tokens[mark]->lineno;
2029 UNUSED(start_lineno); // Only used by EXTRA macro
2030 int start_col_offset = p->tokens[mark]->col_offset;
2031 UNUSED(start_col_offset); // Only used by EXTRA macro
2032 { // 'nonlocal' ','.NAME+
2033 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002034 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002035 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002036 (keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002037 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002038 (a = _gather_27_rule(p)) // ','.NAME+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002039 )
2040 {
2041 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2042 if (token == NULL) {
2043 return NULL;
2044 }
2045 int end_lineno = token->end_lineno;
2046 UNUSED(end_lineno); // Only used by EXTRA macro
2047 int end_col_offset = token->end_col_offset;
2048 UNUSED(end_col_offset); // Only used by EXTRA macro
2049 res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
2050 if (res == NULL && PyErr_Occurred()) {
2051 p->error_indicator = 1;
2052 return NULL;
2053 }
2054 goto done;
2055 }
2056 p->mark = mark;
2057 }
2058 res = NULL;
2059 done:
2060 return res;
2061}
2062
2063// yield_stmt: yield_expr
2064static stmt_ty
2065yield_stmt_rule(Parser *p)
2066{
2067 if (p->error_indicator) {
2068 return NULL;
2069 }
2070 stmt_ty res = NULL;
2071 int mark = p->mark;
2072 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2073 p->error_indicator = 1;
2074 return NULL;
2075 }
2076 int start_lineno = p->tokens[mark]->lineno;
2077 UNUSED(start_lineno); // Only used by EXTRA macro
2078 int start_col_offset = p->tokens[mark]->col_offset;
2079 UNUSED(start_col_offset); // Only used by EXTRA macro
2080 { // yield_expr
2081 expr_ty y;
2082 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002083 (y = yield_expr_rule(p)) // yield_expr
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002084 )
2085 {
2086 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2087 if (token == NULL) {
2088 return NULL;
2089 }
2090 int end_lineno = token->end_lineno;
2091 UNUSED(end_lineno); // Only used by EXTRA macro
2092 int end_col_offset = token->end_col_offset;
2093 UNUSED(end_col_offset); // Only used by EXTRA macro
2094 res = _Py_Expr ( y , EXTRA );
2095 if (res == NULL && PyErr_Occurred()) {
2096 p->error_indicator = 1;
2097 return NULL;
2098 }
2099 goto done;
2100 }
2101 p->mark = mark;
2102 }
2103 res = NULL;
2104 done:
2105 return res;
2106}
2107
2108// assert_stmt: 'assert' expression [',' expression]
2109static stmt_ty
2110assert_stmt_rule(Parser *p)
2111{
2112 if (p->error_indicator) {
2113 return NULL;
2114 }
2115 stmt_ty res = NULL;
2116 int mark = p->mark;
2117 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2118 p->error_indicator = 1;
2119 return NULL;
2120 }
2121 int start_lineno = p->tokens[mark]->lineno;
2122 UNUSED(start_lineno); // Only used by EXTRA macro
2123 int start_col_offset = p->tokens[mark]->col_offset;
2124 UNUSED(start_col_offset); // Only used by EXTRA macro
2125 { // 'assert' expression [',' expression]
2126 expr_ty a;
2127 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002128 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002129 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002130 (keyword = _PyPegen_expect_token(p, 505)) // token='assert'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002131 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002132 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002133 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002134 (b = _tmp_29_rule(p), 1) // [',' expression]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002135 )
2136 {
2137 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2138 if (token == NULL) {
2139 return NULL;
2140 }
2141 int end_lineno = token->end_lineno;
2142 UNUSED(end_lineno); // Only used by EXTRA macro
2143 int end_col_offset = token->end_col_offset;
2144 UNUSED(end_col_offset); // Only used by EXTRA macro
2145 res = _Py_Assert ( a , b , EXTRA );
2146 if (res == NULL && PyErr_Occurred()) {
2147 p->error_indicator = 1;
2148 return NULL;
2149 }
2150 goto done;
2151 }
2152 p->mark = mark;
2153 }
2154 res = NULL;
2155 done:
2156 return res;
2157}
2158
2159// del_stmt: 'del' del_targets
2160static stmt_ty
2161del_stmt_rule(Parser *p)
2162{
2163 if (p->error_indicator) {
2164 return NULL;
2165 }
2166 stmt_ty res = NULL;
2167 int mark = p->mark;
2168 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2169 p->error_indicator = 1;
2170 return NULL;
2171 }
2172 int start_lineno = p->tokens[mark]->lineno;
2173 UNUSED(start_lineno); // Only used by EXTRA macro
2174 int start_col_offset = p->tokens[mark]->col_offset;
2175 UNUSED(start_col_offset); // Only used by EXTRA macro
2176 { // 'del' del_targets
2177 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002178 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002179 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002180 (keyword = _PyPegen_expect_token(p, 503)) // token='del'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002181 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002182 (a = del_targets_rule(p)) // del_targets
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002183 )
2184 {
2185 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2186 if (token == NULL) {
2187 return NULL;
2188 }
2189 int end_lineno = token->end_lineno;
2190 UNUSED(end_lineno); // Only used by EXTRA macro
2191 int end_col_offset = token->end_col_offset;
2192 UNUSED(end_col_offset); // Only used by EXTRA macro
2193 res = _Py_Delete ( a , EXTRA );
2194 if (res == NULL && PyErr_Occurred()) {
2195 p->error_indicator = 1;
2196 return NULL;
2197 }
2198 goto done;
2199 }
2200 p->mark = mark;
2201 }
2202 res = NULL;
2203 done:
2204 return res;
2205}
2206
2207// import_stmt: import_name | import_from
2208static stmt_ty
2209import_stmt_rule(Parser *p)
2210{
2211 if (p->error_indicator) {
2212 return NULL;
2213 }
2214 stmt_ty res = NULL;
2215 int mark = p->mark;
2216 { // import_name
2217 stmt_ty import_name_var;
2218 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002219 (import_name_var = import_name_rule(p)) // import_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002220 )
2221 {
2222 res = import_name_var;
2223 goto done;
2224 }
2225 p->mark = mark;
2226 }
2227 { // import_from
2228 stmt_ty import_from_var;
2229 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002230 (import_from_var = import_from_rule(p)) // import_from
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002231 )
2232 {
2233 res = import_from_var;
2234 goto done;
2235 }
2236 p->mark = mark;
2237 }
2238 res = NULL;
2239 done:
2240 return res;
2241}
2242
2243// import_name: 'import' dotted_as_names
2244static stmt_ty
2245import_name_rule(Parser *p)
2246{
2247 if (p->error_indicator) {
2248 return NULL;
2249 }
2250 stmt_ty res = NULL;
2251 int mark = p->mark;
2252 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2253 p->error_indicator = 1;
2254 return NULL;
2255 }
2256 int start_lineno = p->tokens[mark]->lineno;
2257 UNUSED(start_lineno); // Only used by EXTRA macro
2258 int start_col_offset = p->tokens[mark]->col_offset;
2259 UNUSED(start_col_offset); // Only used by EXTRA macro
2260 { // 'import' dotted_as_names
2261 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002262 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002263 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002264 (keyword = _PyPegen_expect_token(p, 513)) // token='import'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002265 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002266 (a = dotted_as_names_rule(p)) // dotted_as_names
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002267 )
2268 {
2269 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2270 if (token == NULL) {
2271 return NULL;
2272 }
2273 int end_lineno = token->end_lineno;
2274 UNUSED(end_lineno); // Only used by EXTRA macro
2275 int end_col_offset = token->end_col_offset;
2276 UNUSED(end_col_offset); // Only used by EXTRA macro
2277 res = _Py_Import ( a , EXTRA );
2278 if (res == NULL && PyErr_Occurred()) {
2279 p->error_indicator = 1;
2280 return NULL;
2281 }
2282 goto done;
2283 }
2284 p->mark = mark;
2285 }
2286 res = NULL;
2287 done:
2288 return res;
2289}
2290
2291// import_from:
2292// | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
2293// | 'from' (('.' | '...'))+ 'import' import_from_targets
2294static stmt_ty
2295import_from_rule(Parser *p)
2296{
2297 if (p->error_indicator) {
2298 return NULL;
2299 }
2300 stmt_ty res = NULL;
2301 int mark = p->mark;
2302 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2303 p->error_indicator = 1;
2304 return NULL;
2305 }
2306 int start_lineno = p->tokens[mark]->lineno;
2307 UNUSED(start_lineno); // Only used by EXTRA macro
2308 int start_col_offset = p->tokens[mark]->col_offset;
2309 UNUSED(start_col_offset); // Only used by EXTRA macro
2310 { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
2311 asdl_seq * a;
2312 expr_ty b;
2313 asdl_seq* c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002314 Token * keyword;
2315 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002316 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002317 (keyword = _PyPegen_expect_token(p, 514)) // token='from'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002318 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002319 (a = _loop0_30_rule(p)) // (('.' | '...'))*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002320 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002321 (b = dotted_name_rule(p)) // dotted_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002322 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002323 (keyword_1 = _PyPegen_expect_token(p, 513)) // token='import'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002324 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002325 (c = import_from_targets_rule(p)) // import_from_targets
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002326 )
2327 {
2328 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2329 if (token == NULL) {
2330 return NULL;
2331 }
2332 int end_lineno = token->end_lineno;
2333 UNUSED(end_lineno); // Only used by EXTRA macro
2334 int end_col_offset = token->end_col_offset;
2335 UNUSED(end_col_offset); // Only used by EXTRA macro
2336 res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA );
2337 if (res == NULL && PyErr_Occurred()) {
2338 p->error_indicator = 1;
2339 return NULL;
2340 }
2341 goto done;
2342 }
2343 p->mark = mark;
2344 }
2345 { // 'from' (('.' | '...'))+ 'import' import_from_targets
2346 asdl_seq * a;
2347 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002348 Token * keyword;
2349 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002350 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002351 (keyword = _PyPegen_expect_token(p, 514)) // token='from'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002352 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002353 (a = _loop1_31_rule(p)) // (('.' | '...'))+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002354 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002355 (keyword_1 = _PyPegen_expect_token(p, 513)) // token='import'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002356 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002357 (b = import_from_targets_rule(p)) // import_from_targets
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002358 )
2359 {
2360 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2361 if (token == NULL) {
2362 return NULL;
2363 }
2364 int end_lineno = token->end_lineno;
2365 UNUSED(end_lineno); // Only used by EXTRA macro
2366 int end_col_offset = token->end_col_offset;
2367 UNUSED(end_col_offset); // Only used by EXTRA macro
2368 res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA );
2369 if (res == NULL && PyErr_Occurred()) {
2370 p->error_indicator = 1;
2371 return NULL;
2372 }
2373 goto done;
2374 }
2375 p->mark = mark;
2376 }
2377 res = NULL;
2378 done:
2379 return res;
2380}
2381
2382// import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*'
2383static asdl_seq*
2384import_from_targets_rule(Parser *p)
2385{
2386 if (p->error_indicator) {
2387 return NULL;
2388 }
2389 asdl_seq* res = NULL;
2390 int mark = p->mark;
2391 { // '(' import_from_as_names ','? ')'
2392 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002393 Token * literal;
2394 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002395 void *opt_var;
2396 UNUSED(opt_var); // Silence compiler warnings
2397 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002398 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002399 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002400 (a = import_from_as_names_rule(p)) // import_from_as_names
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002401 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002402 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002403 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002404 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002405 )
2406 {
2407 res = a;
2408 if (res == NULL && PyErr_Occurred()) {
2409 p->error_indicator = 1;
2410 return NULL;
2411 }
2412 goto done;
2413 }
2414 p->mark = mark;
2415 }
2416 { // import_from_as_names
2417 asdl_seq* import_from_as_names_var;
2418 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002419 (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002420 )
2421 {
2422 res = import_from_as_names_var;
2423 goto done;
2424 }
2425 p->mark = mark;
2426 }
2427 { // '*'
Pablo Galindob796b3f2020-05-01 12:32:26 +01002428 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002429 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002430 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002431 )
2432 {
2433 res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) );
2434 if (res == NULL && PyErr_Occurred()) {
2435 p->error_indicator = 1;
2436 return NULL;
2437 }
2438 goto done;
2439 }
2440 p->mark = mark;
2441 }
2442 res = NULL;
2443 done:
2444 return res;
2445}
2446
2447// import_from_as_names: ','.import_from_as_name+
2448static asdl_seq*
2449import_from_as_names_rule(Parser *p)
2450{
2451 if (p->error_indicator) {
2452 return NULL;
2453 }
2454 asdl_seq* res = NULL;
2455 int mark = p->mark;
2456 { // ','.import_from_as_name+
2457 asdl_seq * a;
2458 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002459 (a = _gather_32_rule(p)) // ','.import_from_as_name+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002460 )
2461 {
2462 res = a;
2463 if (res == NULL && PyErr_Occurred()) {
2464 p->error_indicator = 1;
2465 return NULL;
2466 }
2467 goto done;
2468 }
2469 p->mark = mark;
2470 }
2471 res = NULL;
2472 done:
2473 return res;
2474}
2475
2476// import_from_as_name: NAME ['as' NAME]
2477static alias_ty
2478import_from_as_name_rule(Parser *p)
2479{
2480 if (p->error_indicator) {
2481 return NULL;
2482 }
2483 alias_ty res = NULL;
2484 int mark = p->mark;
2485 { // NAME ['as' NAME]
2486 expr_ty a;
2487 void *b;
2488 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002489 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002490 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002491 (b = _tmp_34_rule(p), 1) // ['as' NAME]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002492 )
2493 {
2494 res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
2495 if (res == NULL && PyErr_Occurred()) {
2496 p->error_indicator = 1;
2497 return NULL;
2498 }
2499 goto done;
2500 }
2501 p->mark = mark;
2502 }
2503 res = NULL;
2504 done:
2505 return res;
2506}
2507
2508// dotted_as_names: ','.dotted_as_name+
2509static asdl_seq*
2510dotted_as_names_rule(Parser *p)
2511{
2512 if (p->error_indicator) {
2513 return NULL;
2514 }
2515 asdl_seq* res = NULL;
2516 int mark = p->mark;
2517 { // ','.dotted_as_name+
2518 asdl_seq * a;
2519 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002520 (a = _gather_35_rule(p)) // ','.dotted_as_name+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002521 )
2522 {
2523 res = a;
2524 if (res == NULL && PyErr_Occurred()) {
2525 p->error_indicator = 1;
2526 return NULL;
2527 }
2528 goto done;
2529 }
2530 p->mark = mark;
2531 }
2532 res = NULL;
2533 done:
2534 return res;
2535}
2536
2537// dotted_as_name: dotted_name ['as' NAME]
2538static alias_ty
2539dotted_as_name_rule(Parser *p)
2540{
2541 if (p->error_indicator) {
2542 return NULL;
2543 }
2544 alias_ty res = NULL;
2545 int mark = p->mark;
2546 { // dotted_name ['as' NAME]
2547 expr_ty a;
2548 void *b;
2549 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002550 (a = dotted_name_rule(p)) // dotted_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002551 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002552 (b = _tmp_37_rule(p), 1) // ['as' NAME]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002553 )
2554 {
2555 res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
2556 if (res == NULL && PyErr_Occurred()) {
2557 p->error_indicator = 1;
2558 return NULL;
2559 }
2560 goto done;
2561 }
2562 p->mark = mark;
2563 }
2564 res = NULL;
2565 done:
2566 return res;
2567}
2568
2569// Left-recursive
2570// dotted_name: dotted_name '.' NAME | NAME
2571static expr_ty dotted_name_raw(Parser *);
2572static expr_ty
2573dotted_name_rule(Parser *p)
2574{
2575 expr_ty res = NULL;
2576 if (_PyPegen_is_memoized(p, dotted_name_type, &res))
2577 return res;
2578 int mark = p->mark;
2579 int resmark = p->mark;
2580 while (1) {
2581 int tmpvar_0 = _PyPegen_update_memo(p, mark, dotted_name_type, res);
2582 if (tmpvar_0) {
2583 return res;
2584 }
2585 p->mark = mark;
2586 void *raw = dotted_name_raw(p);
2587 if (raw == NULL || p->mark <= resmark)
2588 break;
2589 resmark = p->mark;
2590 res = raw;
2591 }
2592 p->mark = resmark;
2593 return res;
2594}
2595static expr_ty
2596dotted_name_raw(Parser *p)
2597{
2598 if (p->error_indicator) {
2599 return NULL;
2600 }
2601 expr_ty res = NULL;
2602 int mark = p->mark;
2603 { // dotted_name '.' NAME
2604 expr_ty a;
2605 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002606 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002607 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002608 (a = dotted_name_rule(p)) // dotted_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002609 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002610 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002611 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002612 (b = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002613 )
2614 {
2615 res = _PyPegen_join_names_with_dot ( p , a , b );
2616 if (res == NULL && PyErr_Occurred()) {
2617 p->error_indicator = 1;
2618 return NULL;
2619 }
2620 goto done;
2621 }
2622 p->mark = mark;
2623 }
2624 { // NAME
2625 expr_ty name_var;
2626 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002627 (name_var = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002628 )
2629 {
2630 res = name_var;
2631 goto done;
2632 }
2633 p->mark = mark;
2634 }
2635 res = NULL;
2636 done:
2637 return res;
2638}
2639
2640// if_stmt:
2641// | 'if' named_expression ':' block elif_stmt
2642// | 'if' named_expression ':' block else_block?
2643static stmt_ty
2644if_stmt_rule(Parser *p)
2645{
2646 if (p->error_indicator) {
2647 return NULL;
2648 }
2649 stmt_ty res = NULL;
2650 int mark = p->mark;
2651 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2652 p->error_indicator = 1;
2653 return NULL;
2654 }
2655 int start_lineno = p->tokens[mark]->lineno;
2656 UNUSED(start_lineno); // Only used by EXTRA macro
2657 int start_col_offset = p->tokens[mark]->col_offset;
2658 UNUSED(start_col_offset); // Only used by EXTRA macro
2659 { // 'if' named_expression ':' block elif_stmt
2660 expr_ty a;
2661 asdl_seq* b;
2662 stmt_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002663 Token * keyword;
2664 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002665 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002666 (keyword = _PyPegen_expect_token(p, 510)) // token='if'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002667 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002668 (a = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002669 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002670 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002671 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002672 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002673 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002674 (c = elif_stmt_rule(p)) // elif_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002675 )
2676 {
2677 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2678 if (token == NULL) {
2679 return NULL;
2680 }
2681 int end_lineno = token->end_lineno;
2682 UNUSED(end_lineno); // Only used by EXTRA macro
2683 int end_col_offset = token->end_col_offset;
2684 UNUSED(end_col_offset); // Only used by EXTRA macro
2685 res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
2686 if (res == NULL && PyErr_Occurred()) {
2687 p->error_indicator = 1;
2688 return NULL;
2689 }
2690 goto done;
2691 }
2692 p->mark = mark;
2693 }
2694 { // 'if' named_expression ':' block else_block?
2695 expr_ty a;
2696 asdl_seq* b;
2697 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002698 Token * keyword;
2699 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002700 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002701 (keyword = _PyPegen_expect_token(p, 510)) // token='if'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002702 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002703 (a = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002704 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002705 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002706 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002707 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002708 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002709 (c = else_block_rule(p), 1) // else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002710 )
2711 {
2712 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2713 if (token == NULL) {
2714 return NULL;
2715 }
2716 int end_lineno = token->end_lineno;
2717 UNUSED(end_lineno); // Only used by EXTRA macro
2718 int end_col_offset = token->end_col_offset;
2719 UNUSED(end_col_offset); // Only used by EXTRA macro
2720 res = _Py_If ( a , b , c , EXTRA );
2721 if (res == NULL && PyErr_Occurred()) {
2722 p->error_indicator = 1;
2723 return NULL;
2724 }
2725 goto done;
2726 }
2727 p->mark = mark;
2728 }
2729 res = NULL;
2730 done:
2731 return res;
2732}
2733
2734// elif_stmt:
2735// | 'elif' named_expression ':' block elif_stmt
2736// | 'elif' named_expression ':' block else_block?
2737static stmt_ty
2738elif_stmt_rule(Parser *p)
2739{
2740 if (p->error_indicator) {
2741 return NULL;
2742 }
2743 stmt_ty res = NULL;
2744 int mark = p->mark;
2745 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2746 p->error_indicator = 1;
2747 return NULL;
2748 }
2749 int start_lineno = p->tokens[mark]->lineno;
2750 UNUSED(start_lineno); // Only used by EXTRA macro
2751 int start_col_offset = p->tokens[mark]->col_offset;
2752 UNUSED(start_col_offset); // Only used by EXTRA macro
2753 { // 'elif' named_expression ':' block elif_stmt
2754 expr_ty a;
2755 asdl_seq* b;
2756 stmt_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002757 Token * keyword;
2758 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002759 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002760 (keyword = _PyPegen_expect_token(p, 515)) // token='elif'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002761 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002762 (a = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002763 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002764 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002765 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002766 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002767 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002768 (c = elif_stmt_rule(p)) // elif_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002769 )
2770 {
2771 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2772 if (token == NULL) {
2773 return NULL;
2774 }
2775 int end_lineno = token->end_lineno;
2776 UNUSED(end_lineno); // Only used by EXTRA macro
2777 int end_col_offset = token->end_col_offset;
2778 UNUSED(end_col_offset); // Only used by EXTRA macro
2779 res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
2780 if (res == NULL && PyErr_Occurred()) {
2781 p->error_indicator = 1;
2782 return NULL;
2783 }
2784 goto done;
2785 }
2786 p->mark = mark;
2787 }
2788 { // 'elif' named_expression ':' block else_block?
2789 expr_ty a;
2790 asdl_seq* b;
2791 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002792 Token * keyword;
2793 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002794 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002795 (keyword = _PyPegen_expect_token(p, 515)) // token='elif'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002796 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002797 (a = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002798 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002799 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002800 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002801 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002802 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002803 (c = else_block_rule(p), 1) // else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002804 )
2805 {
2806 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2807 if (token == NULL) {
2808 return NULL;
2809 }
2810 int end_lineno = token->end_lineno;
2811 UNUSED(end_lineno); // Only used by EXTRA macro
2812 int end_col_offset = token->end_col_offset;
2813 UNUSED(end_col_offset); // Only used by EXTRA macro
2814 res = _Py_If ( a , b , c , EXTRA );
2815 if (res == NULL && PyErr_Occurred()) {
2816 p->error_indicator = 1;
2817 return NULL;
2818 }
2819 goto done;
2820 }
2821 p->mark = mark;
2822 }
2823 res = NULL;
2824 done:
2825 return res;
2826}
2827
2828// else_block: 'else' ':' block
2829static asdl_seq*
2830else_block_rule(Parser *p)
2831{
2832 if (p->error_indicator) {
2833 return NULL;
2834 }
2835 asdl_seq* res = NULL;
2836 int mark = p->mark;
2837 { // 'else' ':' block
2838 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002839 Token * keyword;
2840 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002841 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002842 (keyword = _PyPegen_expect_token(p, 516)) // token='else'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002843 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002844 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002845 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002846 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002847 )
2848 {
2849 res = b;
2850 if (res == NULL && PyErr_Occurred()) {
2851 p->error_indicator = 1;
2852 return NULL;
2853 }
2854 goto done;
2855 }
2856 p->mark = mark;
2857 }
2858 res = NULL;
2859 done:
2860 return res;
2861}
2862
2863// while_stmt: 'while' named_expression ':' block else_block?
2864static stmt_ty
2865while_stmt_rule(Parser *p)
2866{
2867 if (p->error_indicator) {
2868 return NULL;
2869 }
2870 stmt_ty res = NULL;
2871 int mark = p->mark;
2872 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2873 p->error_indicator = 1;
2874 return NULL;
2875 }
2876 int start_lineno = p->tokens[mark]->lineno;
2877 UNUSED(start_lineno); // Only used by EXTRA macro
2878 int start_col_offset = p->tokens[mark]->col_offset;
2879 UNUSED(start_col_offset); // Only used by EXTRA macro
2880 { // 'while' named_expression ':' block else_block?
2881 expr_ty a;
2882 asdl_seq* b;
2883 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002884 Token * keyword;
2885 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002886 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002887 (keyword = _PyPegen_expect_token(p, 512)) // token='while'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002888 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002889 (a = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002890 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002891 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002892 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002893 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002894 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002895 (c = else_block_rule(p), 1) // else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002896 )
2897 {
2898 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2899 if (token == NULL) {
2900 return NULL;
2901 }
2902 int end_lineno = token->end_lineno;
2903 UNUSED(end_lineno); // Only used by EXTRA macro
2904 int end_col_offset = token->end_col_offset;
2905 UNUSED(end_col_offset); // Only used by EXTRA macro
2906 res = _Py_While ( a , b , c , EXTRA );
2907 if (res == NULL && PyErr_Occurred()) {
2908 p->error_indicator = 1;
2909 return NULL;
2910 }
2911 goto done;
2912 }
2913 p->mark = mark;
2914 }
2915 res = NULL;
2916 done:
2917 return res;
2918}
2919
Guido van Rossumc001c092020-04-30 12:12:19 -07002920// for_stmt:
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002921// | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
2922// | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002923static stmt_ty
2924for_stmt_rule(Parser *p)
2925{
2926 if (p->error_indicator) {
2927 return NULL;
2928 }
2929 stmt_ty res = NULL;
2930 int mark = p->mark;
2931 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
2932 p->error_indicator = 1;
2933 return NULL;
2934 }
2935 int start_lineno = p->tokens[mark]->lineno;
2936 UNUSED(start_lineno); // Only used by EXTRA macro
2937 int start_col_offset = p->tokens[mark]->col_offset;
2938 UNUSED(start_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002939 { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002940 asdl_seq* b;
2941 void *el;
2942 expr_ty ex;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002943 Token * keyword;
2944 Token * keyword_1;
2945 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002946 expr_ty t;
Guido van Rossumc001c092020-04-30 12:12:19 -07002947 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002948 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002949 (keyword = _PyPegen_expect_token(p, 517)) // token='for'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002950 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002951 (t = star_targets_rule(p)) // star_targets
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002952 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002953 (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002954 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002955 (ex = star_expressions_rule(p)) // star_expressions
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002956 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002957 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002958 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002959 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002960 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002961 (b = block_rule(p)) // block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002962 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002963 (el = else_block_rule(p), 1) // else_block?
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002964 )
2965 {
2966 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
2967 if (token == NULL) {
2968 return NULL;
2969 }
2970 int end_lineno = token->end_lineno;
2971 UNUSED(end_lineno); // Only used by EXTRA macro
2972 int end_col_offset = token->end_col_offset;
2973 UNUSED(end_col_offset); // Only used by EXTRA macro
2974 res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
2975 if (res == NULL && PyErr_Occurred()) {
2976 p->error_indicator = 1;
2977 return NULL;
2978 }
2979 goto done;
2980 }
2981 p->mark = mark;
2982 }
2983 { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
Pablo Galindob796b3f2020-05-01 12:32:26 +01002984 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002985 asdl_seq* b;
2986 void *el;
2987 expr_ty ex;
Pablo Galindob796b3f2020-05-01 12:32:26 +01002988 Token * keyword;
2989 Token * keyword_1;
2990 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03002991 expr_ty t;
2992 void *tc;
2993 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01002994 (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002995 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002996 (keyword = _PyPegen_expect_token(p, 517)) // token='for'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002997 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01002998 (t = star_targets_rule(p)) // star_targets
Pablo Galindoc5fc1562020-04-22 23:29:27 +01002999 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003000 (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003001 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003002 (ex = star_expressions_rule(p)) // star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003003 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003004 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003005 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003006 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Guido van Rossumc001c092020-04-30 12:12:19 -07003007 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003008 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003009 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003010 (el = else_block_rule(p), 1) // else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003011 )
3012 {
3013 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3014 if (token == NULL) {
3015 return NULL;
3016 }
3017 int end_lineno = token->end_lineno;
3018 UNUSED(end_lineno); // Only used by EXTRA macro
3019 int end_col_offset = token->end_col_offset;
3020 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003021 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 +01003022 if (res == NULL && PyErr_Occurred()) {
3023 p->error_indicator = 1;
3024 return NULL;
3025 }
3026 goto done;
3027 }
3028 p->mark = mark;
3029 }
3030 res = NULL;
3031 done:
3032 return res;
3033}
3034
3035// with_stmt:
Pablo Galindo99db2a12020-05-06 22:54:34 +01003036// | 'with' '(' ','.with_item+ ','? ')' ':' block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003037// | 'with' ','.with_item+ ':' TYPE_COMMENT? block
Pablo Galindo99db2a12020-05-06 22:54:34 +01003038// | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003039// | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003040static stmt_ty
3041with_stmt_rule(Parser *p)
3042{
3043 if (p->error_indicator) {
3044 return NULL;
3045 }
3046 stmt_ty res = NULL;
3047 int mark = p->mark;
3048 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3049 p->error_indicator = 1;
3050 return NULL;
3051 }
3052 int start_lineno = p->tokens[mark]->lineno;
3053 UNUSED(start_lineno); // Only used by EXTRA macro
3054 int start_col_offset = p->tokens[mark]->col_offset;
3055 UNUSED(start_col_offset); // Only used by EXTRA macro
Pablo Galindo99db2a12020-05-06 22:54:34 +01003056 { // 'with' '(' ','.with_item+ ','? ')' ':' block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003057 asdl_seq * a;
3058 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003059 Token * keyword;
3060 Token * literal;
3061 Token * literal_1;
3062 Token * literal_2;
Pablo Galindo99db2a12020-05-06 22:54:34 +01003063 void *opt_var;
3064 UNUSED(opt_var); // Silence compiler warnings
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003065 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003066 (keyword = _PyPegen_expect_token(p, 519)) // token='with'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003067 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003068 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003069 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003070 (a = _gather_38_rule(p)) // ','.with_item+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003071 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003072 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindo99db2a12020-05-06 22:54:34 +01003073 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003074 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003075 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003076 (literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003077 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003078 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003079 )
3080 {
3081 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3082 if (token == NULL) {
3083 return NULL;
3084 }
3085 int end_lineno = token->end_lineno;
3086 UNUSED(end_lineno); // Only used by EXTRA macro
3087 int end_col_offset = token->end_col_offset;
3088 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003089 res = _Py_With ( a , b , NULL , EXTRA );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003090 if (res == NULL && PyErr_Occurred()) {
3091 p->error_indicator = 1;
3092 return NULL;
3093 }
3094 goto done;
3095 }
3096 p->mark = mark;
3097 }
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003098 { // 'with' ','.with_item+ ':' TYPE_COMMENT? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003099 asdl_seq * a;
3100 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003101 Token * keyword;
3102 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07003103 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003104 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003105 (keyword = _PyPegen_expect_token(p, 519)) // token='with'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003106 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003107 (a = _gather_40_rule(p)) // ','.with_item+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003108 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003109 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003110 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003111 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Guido van Rossumc001c092020-04-30 12:12:19 -07003112 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003113 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003114 )
3115 {
3116 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3117 if (token == NULL) {
3118 return NULL;
3119 }
3120 int end_lineno = token->end_lineno;
3121 UNUSED(end_lineno); // Only used by EXTRA macro
3122 int end_col_offset = token->end_col_offset;
3123 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003124 res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
3125 if (res == NULL && PyErr_Occurred()) {
3126 p->error_indicator = 1;
3127 return NULL;
3128 }
3129 goto done;
3130 }
3131 p->mark = mark;
3132 }
Pablo Galindo99db2a12020-05-06 22:54:34 +01003133 { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003134 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003135 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003136 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003137 Token * keyword;
3138 Token * literal;
3139 Token * literal_1;
3140 Token * literal_2;
Pablo Galindo99db2a12020-05-06 22:54:34 +01003141 void *opt_var;
3142 UNUSED(opt_var); // Silence compiler warnings
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003143 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003144 (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003145 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003146 (keyword = _PyPegen_expect_token(p, 519)) // token='with'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003147 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003148 (literal = _PyPegen_expect_token(p, 7)) // token='('
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003149 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003150 (a = _gather_42_rule(p)) // ','.with_item+
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003151 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003152 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindo99db2a12020-05-06 22:54:34 +01003153 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003154 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003155 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003156 (literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003157 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003158 (b = block_rule(p)) // block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003159 )
3160 {
3161 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3162 if (token == NULL) {
3163 return NULL;
3164 }
3165 int end_lineno = token->end_lineno;
3166 UNUSED(end_lineno); // Only used by EXTRA macro
3167 int end_col_offset = token->end_col_offset;
3168 UNUSED(end_col_offset); // Only used by EXTRA macro
3169 res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) );
3170 if (res == NULL && PyErr_Occurred()) {
3171 p->error_indicator = 1;
3172 return NULL;
3173 }
3174 goto done;
3175 }
3176 p->mark = mark;
3177 }
3178 { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
3179 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003180 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003181 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003182 Token * keyword;
3183 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003184 void *tc;
3185 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003186 (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003187 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003188 (keyword = _PyPegen_expect_token(p, 519)) // token='with'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003189 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003190 (a = _gather_44_rule(p)) // ','.with_item+
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003191 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003192 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003193 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003194 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003195 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003196 (b = block_rule(p)) // block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003197 )
3198 {
3199 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3200 if (token == NULL) {
3201 return NULL;
3202 }
3203 int end_lineno = token->end_lineno;
3204 UNUSED(end_lineno); // Only used by EXTRA macro
3205 int end_col_offset = token->end_col_offset;
3206 UNUSED(end_col_offset); // Only used by EXTRA macro
3207 res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003208 if (res == NULL && PyErr_Occurred()) {
3209 p->error_indicator = 1;
3210 return NULL;
3211 }
3212 goto done;
3213 }
3214 p->mark = mark;
3215 }
3216 res = NULL;
3217 done:
3218 return res;
3219}
3220
3221// with_item: expression ['as' target]
3222static withitem_ty
3223with_item_rule(Parser *p)
3224{
3225 if (p->error_indicator) {
3226 return NULL;
3227 }
3228 withitem_ty res = NULL;
3229 int mark = p->mark;
3230 { // expression ['as' target]
3231 expr_ty e;
3232 void *o;
3233 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003234 (e = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003235 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003236 (o = _tmp_46_rule(p), 1) // ['as' target]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003237 )
3238 {
3239 res = _Py_withitem ( e , o , p -> arena );
3240 if (res == NULL && PyErr_Occurred()) {
3241 p->error_indicator = 1;
3242 return NULL;
3243 }
3244 goto done;
3245 }
3246 p->mark = mark;
3247 }
3248 res = NULL;
3249 done:
3250 return res;
3251}
3252
3253// try_stmt:
3254// | 'try' ':' block finally_block
3255// | 'try' ':' block except_block+ else_block? finally_block?
3256static stmt_ty
3257try_stmt_rule(Parser *p)
3258{
3259 if (p->error_indicator) {
3260 return NULL;
3261 }
3262 stmt_ty res = NULL;
3263 int mark = p->mark;
3264 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3265 p->error_indicator = 1;
3266 return NULL;
3267 }
3268 int start_lineno = p->tokens[mark]->lineno;
3269 UNUSED(start_lineno); // Only used by EXTRA macro
3270 int start_col_offset = p->tokens[mark]->col_offset;
3271 UNUSED(start_col_offset); // Only used by EXTRA macro
3272 { // 'try' ':' block finally_block
3273 asdl_seq* b;
3274 asdl_seq* f;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003275 Token * keyword;
3276 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003277 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003278 (keyword = _PyPegen_expect_token(p, 511)) // token='try'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003279 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003280 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003281 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003282 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003283 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003284 (f = finally_block_rule(p)) // finally_block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003285 )
3286 {
3287 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3288 if (token == NULL) {
3289 return NULL;
3290 }
3291 int end_lineno = token->end_lineno;
3292 UNUSED(end_lineno); // Only used by EXTRA macro
3293 int end_col_offset = token->end_col_offset;
3294 UNUSED(end_col_offset); // Only used by EXTRA macro
3295 res = _Py_Try ( b , NULL , NULL , f , EXTRA );
3296 if (res == NULL && PyErr_Occurred()) {
3297 p->error_indicator = 1;
3298 return NULL;
3299 }
3300 goto done;
3301 }
3302 p->mark = mark;
3303 }
3304 { // 'try' ':' block except_block+ else_block? finally_block?
3305 asdl_seq* b;
3306 void *el;
3307 asdl_seq * ex;
3308 void *f;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003309 Token * keyword;
3310 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003311 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003312 (keyword = _PyPegen_expect_token(p, 511)) // token='try'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003313 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003314 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003315 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003316 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003317 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003318 (ex = _loop1_47_rule(p)) // except_block+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003319 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003320 (el = else_block_rule(p), 1) // else_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003321 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003322 (f = finally_block_rule(p), 1) // finally_block?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003323 )
3324 {
3325 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3326 if (token == NULL) {
3327 return NULL;
3328 }
3329 int end_lineno = token->end_lineno;
3330 UNUSED(end_lineno); // Only used by EXTRA macro
3331 int end_col_offset = token->end_col_offset;
3332 UNUSED(end_col_offset); // Only used by EXTRA macro
3333 res = _Py_Try ( b , ex , el , f , EXTRA );
3334 if (res == NULL && PyErr_Occurred()) {
3335 p->error_indicator = 1;
3336 return NULL;
3337 }
3338 goto done;
3339 }
3340 p->mark = mark;
3341 }
3342 res = NULL;
3343 done:
3344 return res;
3345}
3346
3347// except_block: 'except' expression ['as' target] ':' block | 'except' ':' block
3348static excepthandler_ty
3349except_block_rule(Parser *p)
3350{
3351 if (p->error_indicator) {
3352 return NULL;
3353 }
3354 excepthandler_ty res = NULL;
3355 int mark = p->mark;
3356 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3357 p->error_indicator = 1;
3358 return NULL;
3359 }
3360 int start_lineno = p->tokens[mark]->lineno;
3361 UNUSED(start_lineno); // Only used by EXTRA macro
3362 int start_col_offset = p->tokens[mark]->col_offset;
3363 UNUSED(start_col_offset); // Only used by EXTRA macro
3364 { // 'except' expression ['as' target] ':' block
3365 asdl_seq* b;
3366 expr_ty e;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003367 Token * keyword;
3368 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003369 void *t;
3370 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003371 (keyword = _PyPegen_expect_token(p, 520)) // token='except'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003372 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003373 (e = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003374 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003375 (t = _tmp_48_rule(p), 1) // ['as' target]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003376 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003377 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003378 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003379 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003380 )
3381 {
3382 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3383 if (token == NULL) {
3384 return NULL;
3385 }
3386 int end_lineno = token->end_lineno;
3387 UNUSED(end_lineno); // Only used by EXTRA macro
3388 int end_col_offset = token->end_col_offset;
3389 UNUSED(end_col_offset); // Only used by EXTRA macro
3390 res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA );
3391 if (res == NULL && PyErr_Occurred()) {
3392 p->error_indicator = 1;
3393 return NULL;
3394 }
3395 goto done;
3396 }
3397 p->mark = mark;
3398 }
3399 { // 'except' ':' block
3400 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003401 Token * keyword;
3402 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003403 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003404 (keyword = _PyPegen_expect_token(p, 520)) // token='except'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003405 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003406 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003407 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003408 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003409 )
3410 {
3411 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3412 if (token == NULL) {
3413 return NULL;
3414 }
3415 int end_lineno = token->end_lineno;
3416 UNUSED(end_lineno); // Only used by EXTRA macro
3417 int end_col_offset = token->end_col_offset;
3418 UNUSED(end_col_offset); // Only used by EXTRA macro
3419 res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA );
3420 if (res == NULL && PyErr_Occurred()) {
3421 p->error_indicator = 1;
3422 return NULL;
3423 }
3424 goto done;
3425 }
3426 p->mark = mark;
3427 }
3428 res = NULL;
3429 done:
3430 return res;
3431}
3432
3433// finally_block: 'finally' ':' block
3434static asdl_seq*
3435finally_block_rule(Parser *p)
3436{
3437 if (p->error_indicator) {
3438 return NULL;
3439 }
3440 asdl_seq* res = NULL;
3441 int mark = p->mark;
3442 { // 'finally' ':' block
3443 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003444 Token * keyword;
3445 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003446 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003447 (keyword = _PyPegen_expect_token(p, 521)) // token='finally'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003448 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003449 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003450 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003451 (a = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003452 )
3453 {
3454 res = a;
3455 if (res == NULL && PyErr_Occurred()) {
3456 p->error_indicator = 1;
3457 return NULL;
3458 }
3459 goto done;
3460 }
3461 p->mark = mark;
3462 }
3463 res = NULL;
3464 done:
3465 return res;
3466}
3467
3468// return_stmt: 'return' star_expressions?
3469static stmt_ty
3470return_stmt_rule(Parser *p)
3471{
3472 if (p->error_indicator) {
3473 return NULL;
3474 }
3475 stmt_ty res = NULL;
3476 int mark = p->mark;
3477 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3478 p->error_indicator = 1;
3479 return NULL;
3480 }
3481 int start_lineno = p->tokens[mark]->lineno;
3482 UNUSED(start_lineno); // Only used by EXTRA macro
3483 int start_col_offset = p->tokens[mark]->col_offset;
3484 UNUSED(start_col_offset); // Only used by EXTRA macro
3485 { // 'return' star_expressions?
3486 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003487 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003488 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003489 (keyword = _PyPegen_expect_token(p, 500)) // token='return'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003490 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003491 (a = star_expressions_rule(p), 1) // star_expressions?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003492 )
3493 {
3494 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3495 if (token == NULL) {
3496 return NULL;
3497 }
3498 int end_lineno = token->end_lineno;
3499 UNUSED(end_lineno); // Only used by EXTRA macro
3500 int end_col_offset = token->end_col_offset;
3501 UNUSED(end_col_offset); // Only used by EXTRA macro
3502 res = _Py_Return ( a , EXTRA );
3503 if (res == NULL && PyErr_Occurred()) {
3504 p->error_indicator = 1;
3505 return NULL;
3506 }
3507 goto done;
3508 }
3509 p->mark = mark;
3510 }
3511 res = NULL;
3512 done:
3513 return res;
3514}
3515
3516// raise_stmt: 'raise' expression ['from' expression] | 'raise'
3517static stmt_ty
3518raise_stmt_rule(Parser *p)
3519{
3520 if (p->error_indicator) {
3521 return NULL;
3522 }
3523 stmt_ty res = NULL;
3524 int mark = p->mark;
3525 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3526 p->error_indicator = 1;
3527 return NULL;
3528 }
3529 int start_lineno = p->tokens[mark]->lineno;
3530 UNUSED(start_lineno); // Only used by EXTRA macro
3531 int start_col_offset = p->tokens[mark]->col_offset;
3532 UNUSED(start_col_offset); // Only used by EXTRA macro
3533 { // 'raise' expression ['from' expression]
3534 expr_ty a;
3535 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003536 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003537 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003538 (keyword = _PyPegen_expect_token(p, 501)) // token='raise'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003539 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003540 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003541 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003542 (b = _tmp_49_rule(p), 1) // ['from' expression]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003543 )
3544 {
3545 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3546 if (token == NULL) {
3547 return NULL;
3548 }
3549 int end_lineno = token->end_lineno;
3550 UNUSED(end_lineno); // Only used by EXTRA macro
3551 int end_col_offset = token->end_col_offset;
3552 UNUSED(end_col_offset); // Only used by EXTRA macro
3553 res = _Py_Raise ( a , b , EXTRA );
3554 if (res == NULL && PyErr_Occurred()) {
3555 p->error_indicator = 1;
3556 return NULL;
3557 }
3558 goto done;
3559 }
3560 p->mark = mark;
3561 }
3562 { // 'raise'
Pablo Galindob796b3f2020-05-01 12:32:26 +01003563 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003564 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003565 (keyword = _PyPegen_expect_token(p, 501)) // token='raise'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003566 )
3567 {
3568 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3569 if (token == NULL) {
3570 return NULL;
3571 }
3572 int end_lineno = token->end_lineno;
3573 UNUSED(end_lineno); // Only used by EXTRA macro
3574 int end_col_offset = token->end_col_offset;
3575 UNUSED(end_col_offset); // Only used by EXTRA macro
3576 res = _Py_Raise ( NULL , NULL , EXTRA );
3577 if (res == NULL && PyErr_Occurred()) {
3578 p->error_indicator = 1;
3579 return NULL;
3580 }
3581 goto done;
3582 }
3583 p->mark = mark;
3584 }
3585 res = NULL;
3586 done:
3587 return res;
3588}
3589
3590// function_def: decorators function_def_raw | function_def_raw
3591static stmt_ty
3592function_def_rule(Parser *p)
3593{
3594 if (p->error_indicator) {
3595 return NULL;
3596 }
3597 stmt_ty res = NULL;
3598 int mark = p->mark;
3599 { // decorators function_def_raw
3600 asdl_seq* d;
3601 stmt_ty f;
3602 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003603 (d = decorators_rule(p)) // decorators
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003604 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003605 (f = function_def_raw_rule(p)) // function_def_raw
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003606 )
3607 {
3608 res = _PyPegen_function_def_decorators ( p , d , f );
3609 if (res == NULL && PyErr_Occurred()) {
3610 p->error_indicator = 1;
3611 return NULL;
3612 }
3613 goto done;
3614 }
3615 p->mark = mark;
3616 }
3617 { // function_def_raw
3618 stmt_ty function_def_raw_var;
3619 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003620 (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003621 )
3622 {
3623 res = function_def_raw_var;
3624 goto done;
3625 }
3626 p->mark = mark;
3627 }
3628 res = NULL;
3629 done:
3630 return res;
3631}
3632
Guido van Rossumc001c092020-04-30 12:12:19 -07003633// function_def_raw:
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003634// | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
3635// | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003636static stmt_ty
3637function_def_raw_rule(Parser *p)
3638{
3639 if (p->error_indicator) {
3640 return NULL;
3641 }
3642 stmt_ty res = NULL;
3643 int mark = p->mark;
3644 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
3645 p->error_indicator = 1;
3646 return NULL;
3647 }
3648 int start_lineno = p->tokens[mark]->lineno;
3649 UNUSED(start_lineno); // Only used by EXTRA macro
3650 int start_col_offset = p->tokens[mark]->col_offset;
3651 UNUSED(start_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003652 { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003653 void *a;
3654 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003655 Token * keyword;
3656 Token * literal;
3657 Token * literal_1;
3658 Token * literal_2;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003659 expr_ty n;
3660 void *params;
Guido van Rossumc001c092020-04-30 12:12:19 -07003661 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003662 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003663 (keyword = _PyPegen_expect_token(p, 522)) // token='def'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003664 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003665 (n = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003666 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003667 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003668 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003669 (params = params_rule(p), 1) // params?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003670 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003671 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003672 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003673 (a = _tmp_50_rule(p), 1) // ['->' expression]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003674 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003675 (literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003676 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003677 (tc = func_type_comment_rule(p), 1) // func_type_comment?
Guido van Rossumc001c092020-04-30 12:12:19 -07003678 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003679 (b = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003680 )
3681 {
3682 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3683 if (token == NULL) {
3684 return NULL;
3685 }
3686 int end_lineno = token->end_lineno;
3687 UNUSED(end_lineno); // Only used by EXTRA macro
3688 int end_col_offset = token->end_col_offset;
3689 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003690 res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
3691 if (res == NULL && PyErr_Occurred()) {
3692 p->error_indicator = 1;
3693 return NULL;
3694 }
3695 goto done;
3696 }
3697 p->mark = mark;
3698 }
3699 { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
3700 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003701 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003702 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003703 Token * keyword;
3704 Token * literal;
3705 Token * literal_1;
3706 Token * literal_2;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003707 expr_ty n;
3708 void *params;
3709 void *tc;
3710 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003711 (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003712 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003713 (keyword = _PyPegen_expect_token(p, 522)) // token='def'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003714 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003715 (n = _PyPegen_name_token(p)) // NAME
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003716 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003717 (literal = _PyPegen_expect_token(p, 7)) // token='('
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003718 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003719 (params = params_rule(p), 1) // params?
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003720 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003721 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003722 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003723 (a = _tmp_51_rule(p), 1) // ['->' expression]
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003724 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003725 (literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003726 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003727 (tc = func_type_comment_rule(p), 1) // func_type_comment?
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003728 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003729 (b = block_rule(p)) // block
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003730 )
3731 {
3732 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
3733 if (token == NULL) {
3734 return NULL;
3735 }
3736 int end_lineno = token->end_lineno;
3737 UNUSED(end_lineno); // Only used by EXTRA macro
3738 int end_col_offset = token->end_col_offset;
3739 UNUSED(end_col_offset); // Only used by EXTRA macro
3740 res = CHECK_VERSION ( 5 , "Async functions are" , _Py_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003741 if (res == NULL && PyErr_Occurred()) {
3742 p->error_indicator = 1;
3743 return NULL;
3744 }
3745 goto done;
3746 }
3747 p->mark = mark;
3748 }
3749 res = NULL;
3750 done:
3751 return res;
3752}
3753
Guido van Rossumc001c092020-04-30 12:12:19 -07003754// func_type_comment:
3755// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
3756// | invalid_double_type_comments
3757// | TYPE_COMMENT
Pablo Galindod9552412020-05-01 16:32:09 +01003758static Token*
Guido van Rossumc001c092020-04-30 12:12:19 -07003759func_type_comment_rule(Parser *p)
3760{
3761 if (p->error_indicator) {
3762 return NULL;
3763 }
Pablo Galindod9552412020-05-01 16:32:09 +01003764 Token* res = NULL;
Guido van Rossumc001c092020-04-30 12:12:19 -07003765 int mark = p->mark;
3766 { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
Pablo Galindob796b3f2020-05-01 12:32:26 +01003767 Token * newline_var;
3768 Token * t;
Guido van Rossumc001c092020-04-30 12:12:19 -07003769 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003770 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Guido van Rossumc001c092020-04-30 12:12:19 -07003771 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003772 (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
Guido van Rossumc001c092020-04-30 12:12:19 -07003773 &&
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03003774 _PyPegen_lookahead(1, _tmp_52_rule, p)
Guido van Rossumc001c092020-04-30 12:12:19 -07003775 )
3776 {
3777 res = t;
3778 if (res == NULL && PyErr_Occurred()) {
3779 p->error_indicator = 1;
3780 return NULL;
3781 }
3782 goto done;
3783 }
3784 p->mark = mark;
3785 }
3786 { // invalid_double_type_comments
3787 void *invalid_double_type_comments_var;
3788 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003789 (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments
Guido van Rossumc001c092020-04-30 12:12:19 -07003790 )
3791 {
3792 res = invalid_double_type_comments_var;
3793 goto done;
3794 }
3795 p->mark = mark;
3796 }
3797 { // TYPE_COMMENT
Pablo Galindob796b3f2020-05-01 12:32:26 +01003798 Token * type_comment_var;
Guido van Rossumc001c092020-04-30 12:12:19 -07003799 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003800 (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
Guido van Rossumc001c092020-04-30 12:12:19 -07003801 )
3802 {
3803 res = type_comment_var;
3804 goto done;
3805 }
3806 p->mark = mark;
3807 }
3808 res = NULL;
3809 done:
3810 return res;
3811}
3812
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003813// params: invalid_parameters | parameters
3814static arguments_ty
3815params_rule(Parser *p)
3816{
3817 if (p->error_indicator) {
3818 return NULL;
3819 }
3820 arguments_ty res = NULL;
3821 int mark = p->mark;
3822 { // invalid_parameters
3823 void *invalid_parameters_var;
3824 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003825 (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003826 )
3827 {
3828 res = invalid_parameters_var;
3829 goto done;
3830 }
3831 p->mark = mark;
3832 }
3833 { // parameters
3834 arguments_ty parameters_var;
3835 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003836 (parameters_var = parameters_rule(p)) // parameters
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003837 )
3838 {
3839 res = parameters_var;
3840 goto done;
3841 }
3842 p->mark = mark;
3843 }
3844 res = NULL;
3845 done:
3846 return res;
3847}
3848
3849// parameters:
Guido van Rossumc001c092020-04-30 12:12:19 -07003850// | slash_no_default param_no_default* param_with_default* star_etc?
3851// | slash_with_default param_with_default* star_etc?
3852// | param_no_default+ param_with_default* star_etc?
3853// | param_with_default+ star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003854// | star_etc
3855static arguments_ty
3856parameters_rule(Parser *p)
3857{
3858 if (p->error_indicator) {
3859 return NULL;
3860 }
3861 arguments_ty res = NULL;
3862 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07003863 { // slash_no_default param_no_default* param_with_default* star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003864 asdl_seq* a;
Guido van Rossumc001c092020-04-30 12:12:19 -07003865 asdl_seq * b;
3866 asdl_seq * c;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003867 void *d;
3868 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003869 (a = slash_no_default_rule(p)) // slash_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003870 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003871 (b = _loop0_53_rule(p)) // param_no_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003872 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003873 (c = _loop0_54_rule(p)) // param_with_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003874 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003875 (d = star_etc_rule(p), 1) // star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003876 )
3877 {
3878 res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
3879 if (res == NULL && PyErr_Occurred()) {
3880 p->error_indicator = 1;
3881 return NULL;
3882 }
3883 goto done;
3884 }
3885 p->mark = mark;
3886 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003887 { // slash_with_default param_with_default* star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003888 SlashWithDefault* a;
Guido van Rossumc001c092020-04-30 12:12:19 -07003889 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003890 void *c;
3891 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003892 (a = slash_with_default_rule(p)) // slash_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003893 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003894 (b = _loop0_55_rule(p)) // param_with_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003895 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003896 (c = star_etc_rule(p), 1) // star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003897 )
3898 {
3899 res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
3900 if (res == NULL && PyErr_Occurred()) {
3901 p->error_indicator = 1;
3902 return NULL;
3903 }
3904 goto done;
3905 }
3906 p->mark = mark;
3907 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003908 { // param_no_default+ param_with_default* star_etc?
3909 asdl_seq * a;
3910 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003911 void *c;
3912 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003913 (a = _loop1_56_rule(p)) // param_no_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003914 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003915 (b = _loop0_57_rule(p)) // param_with_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003916 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003917 (c = star_etc_rule(p), 1) // star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003918 )
3919 {
3920 res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
3921 if (res == NULL && PyErr_Occurred()) {
3922 p->error_indicator = 1;
3923 return NULL;
3924 }
3925 goto done;
3926 }
3927 p->mark = mark;
3928 }
Guido van Rossumc001c092020-04-30 12:12:19 -07003929 { // param_with_default+ star_etc?
3930 asdl_seq * a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003931 void *b;
3932 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003933 (a = _loop1_58_rule(p)) // param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003934 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003935 (b = star_etc_rule(p), 1) // star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003936 )
3937 {
3938 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
3939 if (res == NULL && PyErr_Occurred()) {
3940 p->error_indicator = 1;
3941 return NULL;
3942 }
3943 goto done;
3944 }
3945 p->mark = mark;
3946 }
3947 { // star_etc
3948 StarEtc* a;
3949 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003950 (a = star_etc_rule(p)) // star_etc
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003951 )
3952 {
3953 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
3954 if (res == NULL && PyErr_Occurred()) {
3955 p->error_indicator = 1;
3956 return NULL;
3957 }
3958 goto done;
3959 }
3960 p->mark = mark;
3961 }
3962 res = NULL;
3963 done:
3964 return res;
3965}
3966
Guido van Rossumc001c092020-04-30 12:12:19 -07003967// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003968static asdl_seq*
Guido van Rossumc001c092020-04-30 12:12:19 -07003969slash_no_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003970{
3971 if (p->error_indicator) {
3972 return NULL;
3973 }
3974 asdl_seq* res = NULL;
3975 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07003976 { // param_no_default+ '/' ','
3977 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003978 Token * literal;
3979 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003980 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01003981 (a = _loop1_59_rule(p)) // param_no_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003982 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003983 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01003984 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01003985 (literal_1 = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -07003986 )
3987 {
3988 res = a;
3989 if (res == NULL && PyErr_Occurred()) {
3990 p->error_indicator = 1;
3991 return NULL;
3992 }
3993 goto done;
3994 }
3995 p->mark = mark;
3996 }
3997 { // param_no_default+ '/' &')'
3998 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01003999 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004000 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004001 (a = _loop1_60_rule(p)) // param_no_default+
Guido van Rossumc001c092020-04-30 12:12:19 -07004002 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004003 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Guido van Rossumc001c092020-04-30 12:12:19 -07004004 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004005 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004006 )
4007 {
4008 res = a;
4009 if (res == NULL && PyErr_Occurred()) {
4010 p->error_indicator = 1;
4011 return NULL;
4012 }
4013 goto done;
4014 }
4015 p->mark = mark;
4016 }
4017 res = NULL;
4018 done:
4019 return res;
4020}
4021
Guido van Rossumc001c092020-04-30 12:12:19 -07004022// slash_with_default:
4023// | param_no_default* param_with_default+ '/' ','
4024// | param_no_default* param_with_default+ '/' &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004025static SlashWithDefault*
4026slash_with_default_rule(Parser *p)
4027{
4028 if (p->error_indicator) {
4029 return NULL;
4030 }
4031 SlashWithDefault* res = NULL;
4032 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004033 { // param_no_default* param_with_default+ '/' ','
4034 asdl_seq * a;
4035 asdl_seq * b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004036 Token * literal;
4037 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004038 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004039 (a = _loop0_61_rule(p)) // param_no_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004040 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004041 (b = _loop1_62_rule(p)) // param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004042 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004043 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004044 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004045 (literal_1 = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -07004046 )
4047 {
4048 res = _PyPegen_slash_with_default ( p , a , b );
4049 if (res == NULL && PyErr_Occurred()) {
4050 p->error_indicator = 1;
4051 return NULL;
4052 }
4053 goto done;
4054 }
4055 p->mark = mark;
4056 }
4057 { // param_no_default* param_with_default+ '/' &')'
4058 asdl_seq * a;
4059 asdl_seq * b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004060 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004061 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004062 (a = _loop0_63_rule(p)) // param_no_default*
Guido van Rossumc001c092020-04-30 12:12:19 -07004063 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004064 (b = _loop1_64_rule(p)) // param_with_default+
Guido van Rossumc001c092020-04-30 12:12:19 -07004065 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004066 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Guido van Rossumc001c092020-04-30 12:12:19 -07004067 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004068 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004069 )
4070 {
4071 res = _PyPegen_slash_with_default ( p , a , b );
4072 if (res == NULL && PyErr_Occurred()) {
4073 p->error_indicator = 1;
4074 return NULL;
4075 }
4076 goto done;
4077 }
4078 p->mark = mark;
4079 }
4080 res = NULL;
4081 done:
4082 return res;
4083}
4084
4085// star_etc:
Guido van Rossumc001c092020-04-30 12:12:19 -07004086// | '*' param_no_default param_maybe_default* kwds?
4087// | '*' ',' param_maybe_default+ kwds?
4088// | kwds
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03004089// | invalid_star_etc
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004090static StarEtc*
4091star_etc_rule(Parser *p)
4092{
4093 if (p->error_indicator) {
4094 return NULL;
4095 }
4096 StarEtc* res = NULL;
4097 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004098 { // '*' param_no_default param_maybe_default* kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004099 arg_ty a;
4100 asdl_seq * b;
4101 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004102 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004103 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004104 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004105 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004106 (a = param_no_default_rule(p)) // param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004107 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004108 (b = _loop0_65_rule(p)) // param_maybe_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004109 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004110 (c = kwds_rule(p), 1) // kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004111 )
4112 {
4113 res = _PyPegen_star_etc ( p , a , b , c );
4114 if (res == NULL && PyErr_Occurred()) {
4115 p->error_indicator = 1;
4116 return NULL;
4117 }
4118 goto done;
4119 }
4120 p->mark = mark;
4121 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004122 { // '*' ',' param_maybe_default+ kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004123 asdl_seq * b;
4124 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004125 Token * literal;
4126 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004127 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004128 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004129 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004130 (literal_1 = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004131 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004132 (b = _loop1_66_rule(p)) // param_maybe_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004133 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004134 (c = kwds_rule(p), 1) // kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004135 )
4136 {
4137 res = _PyPegen_star_etc ( p , NULL , b , c );
4138 if (res == NULL && PyErr_Occurred()) {
4139 p->error_indicator = 1;
4140 return NULL;
4141 }
4142 goto done;
4143 }
4144 p->mark = mark;
4145 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004146 { // kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004147 arg_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004148 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004149 (a = kwds_rule(p)) // kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004150 )
4151 {
4152 res = _PyPegen_star_etc ( p , NULL , NULL , a );
4153 if (res == NULL && PyErr_Occurred()) {
4154 p->error_indicator = 1;
4155 return NULL;
4156 }
4157 goto done;
4158 }
4159 p->mark = mark;
4160 }
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03004161 { // invalid_star_etc
4162 void *invalid_star_etc_var;
4163 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004164 (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03004165 )
4166 {
4167 res = invalid_star_etc_var;
4168 goto done;
4169 }
4170 p->mark = mark;
4171 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004172 res = NULL;
4173 done:
4174 return res;
4175}
4176
Guido van Rossumc001c092020-04-30 12:12:19 -07004177// kwds: '**' param_no_default
4178static arg_ty
4179kwds_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004180{
4181 if (p->error_indicator) {
4182 return NULL;
4183 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004184 arg_ty res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004185 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004186 { // '**' param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004187 arg_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004188 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004189 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004190 (literal = _PyPegen_expect_token(p, 35)) // token='**'
Guido van Rossumc001c092020-04-30 12:12:19 -07004191 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004192 (a = param_no_default_rule(p)) // param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -07004193 )
4194 {
4195 res = a;
4196 if (res == NULL && PyErr_Occurred()) {
4197 p->error_indicator = 1;
4198 return NULL;
4199 }
4200 goto done;
4201 }
4202 p->mark = mark;
4203 }
4204 res = NULL;
4205 done:
4206 return res;
4207}
4208
4209// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')'
4210static arg_ty
4211param_no_default_rule(Parser *p)
4212{
4213 if (p->error_indicator) {
4214 return NULL;
4215 }
4216 arg_ty res = NULL;
4217 int mark = p->mark;
4218 { // param ',' TYPE_COMMENT?
4219 arg_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004220 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004221 void *tc;
4222 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004223 (a = param_rule(p)) // param
Guido van Rossumc001c092020-04-30 12:12:19 -07004224 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004225 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004226 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004227 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004228 )
4229 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004230 res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004231 if (res == NULL && PyErr_Occurred()) {
4232 p->error_indicator = 1;
4233 return NULL;
4234 }
4235 goto done;
4236 }
4237 p->mark = mark;
4238 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004239 { // param TYPE_COMMENT? &')'
4240 arg_ty a;
4241 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004242 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004243 (a = param_rule(p)) // param
Guido van Rossumc001c092020-04-30 12:12:19 -07004244 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004245 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Guido van Rossumc001c092020-04-30 12:12:19 -07004246 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004247 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004248 )
4249 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004250 res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004251 if (res == NULL && PyErr_Occurred()) {
4252 p->error_indicator = 1;
4253 return NULL;
4254 }
4255 goto done;
4256 }
4257 p->mark = mark;
4258 }
4259 res = NULL;
4260 done:
4261 return res;
4262}
4263
Guido van Rossumc001c092020-04-30 12:12:19 -07004264// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004265static NameDefaultPair*
Guido van Rossumc001c092020-04-30 12:12:19 -07004266param_with_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004267{
4268 if (p->error_indicator) {
4269 return NULL;
4270 }
4271 NameDefaultPair* res = NULL;
4272 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004273 { // param default ',' TYPE_COMMENT?
4274 arg_ty a;
4275 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004276 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004277 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004278 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004279 (a = param_rule(p)) // param
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004280 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004281 (c = default_rule(p)) // default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004282 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004283 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -07004284 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004285 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004286 )
4287 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004288 res = _PyPegen_name_default_pair ( p , a , c , tc );
4289 if (res == NULL && PyErr_Occurred()) {
4290 p->error_indicator = 1;
4291 return NULL;
4292 }
4293 goto done;
4294 }
4295 p->mark = mark;
4296 }
4297 { // param default TYPE_COMMENT? &')'
4298 arg_ty a;
4299 expr_ty c;
4300 void *tc;
4301 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004302 (a = param_rule(p)) // param
Guido van Rossumc001c092020-04-30 12:12:19 -07004303 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004304 (c = default_rule(p)) // default
Guido van Rossumc001c092020-04-30 12:12:19 -07004305 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004306 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Guido van Rossumc001c092020-04-30 12:12:19 -07004307 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004308 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
Guido van Rossumc001c092020-04-30 12:12:19 -07004309 )
4310 {
4311 res = _PyPegen_name_default_pair ( p , a , c , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004312 if (res == NULL && PyErr_Occurred()) {
4313 p->error_indicator = 1;
4314 return NULL;
4315 }
4316 goto done;
4317 }
4318 p->mark = mark;
4319 }
4320 res = NULL;
4321 done:
4322 return res;
4323}
4324
Guido van Rossumc001c092020-04-30 12:12:19 -07004325// param_maybe_default:
4326// | param default? ',' TYPE_COMMENT?
4327// | param default? TYPE_COMMENT? &')'
4328static NameDefaultPair*
4329param_maybe_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004330{
4331 if (p->error_indicator) {
4332 return NULL;
4333 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004334 NameDefaultPair* res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004335 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004336 { // param default? ',' TYPE_COMMENT?
4337 arg_ty a;
4338 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004339 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -07004340 void *tc;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004341 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004342 (a = param_rule(p)) // param
Guido van Rossumc001c092020-04-30 12:12:19 -07004343 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004344 (c = default_rule(p), 1) // default?
Guido van Rossumc001c092020-04-30 12:12:19 -07004345 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004346 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -07004347 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004348 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004349 )
4350 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004351 res = _PyPegen_name_default_pair ( p , a , c , tc );
4352 if (res == NULL && PyErr_Occurred()) {
4353 p->error_indicator = 1;
4354 return NULL;
4355 }
4356 goto done;
4357 }
4358 p->mark = mark;
4359 }
4360 { // param default? TYPE_COMMENT? &')'
4361 arg_ty a;
4362 void *c;
4363 void *tc;
4364 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004365 (a = param_rule(p)) // param
Guido van Rossumc001c092020-04-30 12:12:19 -07004366 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004367 (c = default_rule(p), 1) // default?
Guido van Rossumc001c092020-04-30 12:12:19 -07004368 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004369 (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
Guido van Rossumc001c092020-04-30 12:12:19 -07004370 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004371 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
Guido van Rossumc001c092020-04-30 12:12:19 -07004372 )
4373 {
4374 res = _PyPegen_name_default_pair ( p , a , c , tc );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004375 if (res == NULL && PyErr_Occurred()) {
4376 p->error_indicator = 1;
4377 return NULL;
4378 }
4379 goto done;
4380 }
4381 p->mark = mark;
4382 }
4383 res = NULL;
4384 done:
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004385 return res;
4386}
4387
Guido van Rossumc001c092020-04-30 12:12:19 -07004388// param: NAME annotation?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004389static arg_ty
Guido van Rossumc001c092020-04-30 12:12:19 -07004390param_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004391{
4392 if (p->error_indicator) {
4393 return NULL;
4394 }
4395 arg_ty res = NULL;
4396 int mark = p->mark;
4397 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4398 p->error_indicator = 1;
4399 return NULL;
4400 }
4401 int start_lineno = p->tokens[mark]->lineno;
4402 UNUSED(start_lineno); // Only used by EXTRA macro
4403 int start_col_offset = p->tokens[mark]->col_offset;
4404 UNUSED(start_col_offset); // Only used by EXTRA macro
Guido van Rossumc001c092020-04-30 12:12:19 -07004405 { // NAME annotation?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004406 expr_ty a;
4407 void *b;
4408 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004409 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004410 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004411 (b = annotation_rule(p), 1) // annotation?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004412 )
4413 {
4414 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4415 if (token == NULL) {
4416 return NULL;
4417 }
4418 int end_lineno = token->end_lineno;
4419 UNUSED(end_lineno); // Only used by EXTRA macro
4420 int end_col_offset = token->end_col_offset;
4421 UNUSED(end_col_offset); // Only used by EXTRA macro
4422 res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA );
4423 if (res == NULL && PyErr_Occurred()) {
4424 p->error_indicator = 1;
4425 return NULL;
4426 }
4427 goto done;
4428 }
4429 p->mark = mark;
4430 }
4431 res = NULL;
4432 done:
4433 return res;
4434}
4435
Guido van Rossumc001c092020-04-30 12:12:19 -07004436// annotation: ':' expression
4437static expr_ty
4438annotation_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004439{
4440 if (p->error_indicator) {
4441 return NULL;
4442 }
Guido van Rossumc001c092020-04-30 12:12:19 -07004443 expr_ty res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004444 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004445 { // ':' expression
4446 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004447 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004448 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004449 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004450 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004451 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004452 )
4453 {
4454 res = a;
4455 if (res == NULL && PyErr_Occurred()) {
4456 p->error_indicator = 1;
4457 return NULL;
4458 }
4459 goto done;
4460 }
4461 p->mark = mark;
4462 }
4463 res = NULL;
4464 done:
4465 return res;
4466}
4467
Guido van Rossumc001c092020-04-30 12:12:19 -07004468// default: '=' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004469static expr_ty
Guido van Rossumc001c092020-04-30 12:12:19 -07004470default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004471{
4472 if (p->error_indicator) {
4473 return NULL;
4474 }
4475 expr_ty res = NULL;
4476 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -07004477 { // '=' expression
4478 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004479 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004480 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004481 (literal = _PyPegen_expect_token(p, 22)) // token='='
Guido van Rossumc001c092020-04-30 12:12:19 -07004482 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004483 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004484 )
4485 {
Guido van Rossumc001c092020-04-30 12:12:19 -07004486 res = a;
4487 if (res == NULL && PyErr_Occurred()) {
4488 p->error_indicator = 1;
4489 return NULL;
4490 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004491 goto done;
4492 }
4493 p->mark = mark;
4494 }
4495 res = NULL;
4496 done:
4497 return res;
4498}
4499
4500// decorators: (('@' named_expression NEWLINE))+
4501static asdl_seq*
4502decorators_rule(Parser *p)
4503{
4504 if (p->error_indicator) {
4505 return NULL;
4506 }
4507 asdl_seq* res = NULL;
4508 int mark = p->mark;
4509 { // (('@' named_expression NEWLINE))+
4510 asdl_seq * a;
4511 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004512 (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004513 )
4514 {
4515 res = a;
4516 if (res == NULL && PyErr_Occurred()) {
4517 p->error_indicator = 1;
4518 return NULL;
4519 }
4520 goto done;
4521 }
4522 p->mark = mark;
4523 }
4524 res = NULL;
4525 done:
4526 return res;
4527}
4528
4529// class_def: decorators class_def_raw | class_def_raw
4530static stmt_ty
4531class_def_rule(Parser *p)
4532{
4533 if (p->error_indicator) {
4534 return NULL;
4535 }
4536 stmt_ty res = NULL;
4537 int mark = p->mark;
4538 { // decorators class_def_raw
4539 asdl_seq* a;
4540 stmt_ty b;
4541 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004542 (a = decorators_rule(p)) // decorators
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004543 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004544 (b = class_def_raw_rule(p)) // class_def_raw
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004545 )
4546 {
4547 res = _PyPegen_class_def_decorators ( p , a , b );
4548 if (res == NULL && PyErr_Occurred()) {
4549 p->error_indicator = 1;
4550 return NULL;
4551 }
4552 goto done;
4553 }
4554 p->mark = mark;
4555 }
4556 { // class_def_raw
4557 stmt_ty class_def_raw_var;
4558 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004559 (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004560 )
4561 {
4562 res = class_def_raw_var;
4563 goto done;
4564 }
4565 p->mark = mark;
4566 }
4567 res = NULL;
4568 done:
4569 return res;
4570}
4571
4572// class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block
4573static stmt_ty
4574class_def_raw_rule(Parser *p)
4575{
4576 if (p->error_indicator) {
4577 return NULL;
4578 }
4579 stmt_ty res = NULL;
4580 int mark = p->mark;
4581 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4582 p->error_indicator = 1;
4583 return NULL;
4584 }
4585 int start_lineno = p->tokens[mark]->lineno;
4586 UNUSED(start_lineno); // Only used by EXTRA macro
4587 int start_col_offset = p->tokens[mark]->col_offset;
4588 UNUSED(start_col_offset); // Only used by EXTRA macro
4589 { // 'class' NAME ['(' arguments? ')'] ':' block
4590 expr_ty a;
4591 void *b;
4592 asdl_seq* c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004593 Token * keyword;
4594 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004595 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004596 (keyword = _PyPegen_expect_token(p, 523)) // token='class'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004597 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004598 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004599 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004600 (b = _tmp_68_rule(p), 1) // ['(' arguments? ')']
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004601 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004602 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004603 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004604 (c = block_rule(p)) // block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004605 )
4606 {
4607 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4608 if (token == NULL) {
4609 return NULL;
4610 }
4611 int end_lineno = token->end_lineno;
4612 UNUSED(end_lineno); // Only used by EXTRA macro
4613 int end_col_offset = token->end_col_offset;
4614 UNUSED(end_col_offset); // Only used by EXTRA macro
4615 res = _Py_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA );
4616 if (res == NULL && PyErr_Occurred()) {
4617 p->error_indicator = 1;
4618 return NULL;
4619 }
4620 goto done;
4621 }
4622 p->mark = mark;
4623 }
4624 res = NULL;
4625 done:
4626 return res;
4627}
4628
4629// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
4630static asdl_seq*
4631block_rule(Parser *p)
4632{
4633 if (p->error_indicator) {
4634 return NULL;
4635 }
4636 asdl_seq* res = NULL;
4637 if (_PyPegen_is_memoized(p, block_type, &res))
4638 return res;
4639 int mark = p->mark;
4640 { // NEWLINE INDENT statements DEDENT
4641 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004642 Token * dedent_var;
4643 Token * indent_var;
4644 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004645 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004646 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004647 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004648 (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004649 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004650 (a = statements_rule(p)) // statements
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004651 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004652 (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004653 )
4654 {
4655 res = a;
4656 if (res == NULL && PyErr_Occurred()) {
4657 p->error_indicator = 1;
4658 return NULL;
4659 }
4660 goto done;
4661 }
4662 p->mark = mark;
4663 }
4664 { // simple_stmt
4665 asdl_seq* simple_stmt_var;
4666 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004667 (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004668 )
4669 {
4670 res = simple_stmt_var;
4671 goto done;
4672 }
4673 p->mark = mark;
4674 }
4675 { // invalid_block
4676 void *invalid_block_var;
4677 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004678 (invalid_block_var = invalid_block_rule(p)) // invalid_block
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004679 )
4680 {
4681 res = invalid_block_var;
4682 goto done;
4683 }
4684 p->mark = mark;
4685 }
4686 res = NULL;
4687 done:
4688 _PyPegen_insert_memo(p, mark, block_type, res);
4689 return res;
4690}
4691
4692// expressions_list: ','.star_expression+ ','?
4693static asdl_seq*
4694expressions_list_rule(Parser *p)
4695{
4696 if (p->error_indicator) {
4697 return NULL;
4698 }
4699 asdl_seq* res = NULL;
4700 int mark = p->mark;
4701 { // ','.star_expression+ ','?
4702 asdl_seq * a;
4703 void *opt_var;
4704 UNUSED(opt_var); // Silence compiler warnings
4705 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004706 (a = _gather_69_rule(p)) // ','.star_expression+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004707 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004708 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004709 )
4710 {
4711 res = a;
4712 if (res == NULL && PyErr_Occurred()) {
4713 p->error_indicator = 1;
4714 return NULL;
4715 }
4716 goto done;
4717 }
4718 p->mark = mark;
4719 }
4720 res = NULL;
4721 done:
4722 return res;
4723}
4724
4725// star_expressions:
4726// | star_expression ((',' star_expression))+ ','?
4727// | star_expression ','
4728// | star_expression
4729static expr_ty
4730star_expressions_rule(Parser *p)
4731{
4732 if (p->error_indicator) {
4733 return NULL;
4734 }
4735 expr_ty res = NULL;
4736 int mark = p->mark;
4737 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4738 p->error_indicator = 1;
4739 return NULL;
4740 }
4741 int start_lineno = p->tokens[mark]->lineno;
4742 UNUSED(start_lineno); // Only used by EXTRA macro
4743 int start_col_offset = p->tokens[mark]->col_offset;
4744 UNUSED(start_col_offset); // Only used by EXTRA macro
4745 { // star_expression ((',' star_expression))+ ','?
4746 expr_ty a;
4747 asdl_seq * b;
4748 void *opt_var;
4749 UNUSED(opt_var); // Silence compiler warnings
4750 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004751 (a = star_expression_rule(p)) // star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004752 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004753 (b = _loop1_71_rule(p)) // ((',' star_expression))+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004754 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004755 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004756 )
4757 {
4758 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4759 if (token == NULL) {
4760 return NULL;
4761 }
4762 int end_lineno = token->end_lineno;
4763 UNUSED(end_lineno); // Only used by EXTRA macro
4764 int end_col_offset = token->end_col_offset;
4765 UNUSED(end_col_offset); // Only used by EXTRA macro
4766 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
4767 if (res == NULL && PyErr_Occurred()) {
4768 p->error_indicator = 1;
4769 return NULL;
4770 }
4771 goto done;
4772 }
4773 p->mark = mark;
4774 }
4775 { // star_expression ','
4776 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004777 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004778 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004779 (a = star_expression_rule(p)) // star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004780 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004781 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004782 )
4783 {
4784 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4785 if (token == NULL) {
4786 return NULL;
4787 }
4788 int end_lineno = token->end_lineno;
4789 UNUSED(end_lineno); // Only used by EXTRA macro
4790 int end_col_offset = token->end_col_offset;
4791 UNUSED(end_col_offset); // Only used by EXTRA macro
4792 res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
4793 if (res == NULL && PyErr_Occurred()) {
4794 p->error_indicator = 1;
4795 return NULL;
4796 }
4797 goto done;
4798 }
4799 p->mark = mark;
4800 }
4801 { // star_expression
4802 expr_ty star_expression_var;
4803 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004804 (star_expression_var = star_expression_rule(p)) // star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004805 )
4806 {
4807 res = star_expression_var;
4808 goto done;
4809 }
4810 p->mark = mark;
4811 }
4812 res = NULL;
4813 done:
4814 return res;
4815}
4816
4817// star_expression: '*' bitwise_or | expression
4818static expr_ty
4819star_expression_rule(Parser *p)
4820{
4821 if (p->error_indicator) {
4822 return NULL;
4823 }
4824 expr_ty res = NULL;
4825 if (_PyPegen_is_memoized(p, star_expression_type, &res))
4826 return res;
4827 int mark = p->mark;
4828 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4829 p->error_indicator = 1;
4830 return NULL;
4831 }
4832 int start_lineno = p->tokens[mark]->lineno;
4833 UNUSED(start_lineno); // Only used by EXTRA macro
4834 int start_col_offset = p->tokens[mark]->col_offset;
4835 UNUSED(start_col_offset); // Only used by EXTRA macro
4836 { // '*' bitwise_or
4837 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004838 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004839 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004840 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004841 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004842 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004843 )
4844 {
4845 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4846 if (token == NULL) {
4847 return NULL;
4848 }
4849 int end_lineno = token->end_lineno;
4850 UNUSED(end_lineno); // Only used by EXTRA macro
4851 int end_col_offset = token->end_col_offset;
4852 UNUSED(end_col_offset); // Only used by EXTRA macro
4853 res = _Py_Starred ( a , Load , EXTRA );
4854 if (res == NULL && PyErr_Occurred()) {
4855 p->error_indicator = 1;
4856 return NULL;
4857 }
4858 goto done;
4859 }
4860 p->mark = mark;
4861 }
4862 { // expression
4863 expr_ty expression_var;
4864 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004865 (expression_var = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004866 )
4867 {
4868 res = expression_var;
4869 goto done;
4870 }
4871 p->mark = mark;
4872 }
4873 res = NULL;
4874 done:
4875 _PyPegen_insert_memo(p, mark, star_expression_type, res);
4876 return res;
4877}
4878
4879// star_named_expressions: ','.star_named_expression+ ','?
4880static asdl_seq*
4881star_named_expressions_rule(Parser *p)
4882{
4883 if (p->error_indicator) {
4884 return NULL;
4885 }
4886 asdl_seq* res = NULL;
4887 int mark = p->mark;
4888 { // ','.star_named_expression+ ','?
4889 asdl_seq * a;
4890 void *opt_var;
4891 UNUSED(opt_var); // Silence compiler warnings
4892 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004893 (a = _gather_72_rule(p)) // ','.star_named_expression+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004894 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004895 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004896 )
4897 {
4898 res = a;
4899 if (res == NULL && PyErr_Occurred()) {
4900 p->error_indicator = 1;
4901 return NULL;
4902 }
4903 goto done;
4904 }
4905 p->mark = mark;
4906 }
4907 res = NULL;
4908 done:
4909 return res;
4910}
4911
4912// star_named_expression: '*' bitwise_or | named_expression
4913static expr_ty
4914star_named_expression_rule(Parser *p)
4915{
4916 if (p->error_indicator) {
4917 return NULL;
4918 }
4919 expr_ty res = NULL;
4920 int mark = p->mark;
4921 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4922 p->error_indicator = 1;
4923 return NULL;
4924 }
4925 int start_lineno = p->tokens[mark]->lineno;
4926 UNUSED(start_lineno); // Only used by EXTRA macro
4927 int start_col_offset = p->tokens[mark]->col_offset;
4928 UNUSED(start_col_offset); // Only used by EXTRA macro
4929 { // '*' bitwise_or
4930 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004931 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004932 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004933 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004934 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004935 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004936 )
4937 {
4938 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
4939 if (token == NULL) {
4940 return NULL;
4941 }
4942 int end_lineno = token->end_lineno;
4943 UNUSED(end_lineno); // Only used by EXTRA macro
4944 int end_col_offset = token->end_col_offset;
4945 UNUSED(end_col_offset); // Only used by EXTRA macro
4946 res = _Py_Starred ( a , Load , EXTRA );
4947 if (res == NULL && PyErr_Occurred()) {
4948 p->error_indicator = 1;
4949 return NULL;
4950 }
4951 goto done;
4952 }
4953 p->mark = mark;
4954 }
4955 { // named_expression
4956 expr_ty named_expression_var;
4957 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004958 (named_expression_var = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004959 )
4960 {
4961 res = named_expression_var;
4962 goto done;
4963 }
4964 p->mark = mark;
4965 }
4966 res = NULL;
4967 done:
4968 return res;
4969}
4970
4971// named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression
4972static expr_ty
4973named_expression_rule(Parser *p)
4974{
4975 if (p->error_indicator) {
4976 return NULL;
4977 }
4978 expr_ty res = NULL;
4979 int mark = p->mark;
4980 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
4981 p->error_indicator = 1;
4982 return NULL;
4983 }
4984 int start_lineno = p->tokens[mark]->lineno;
4985 UNUSED(start_lineno); // Only used by EXTRA macro
4986 int start_col_offset = p->tokens[mark]->col_offset;
4987 UNUSED(start_col_offset); // Only used by EXTRA macro
4988 { // NAME ':=' expression
4989 expr_ty a;
4990 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01004991 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004992 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01004993 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004994 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004995 (literal = _PyPegen_expect_token(p, 53)) // token=':='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004996 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01004997 (b = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01004998 )
4999 {
5000 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5001 if (token == NULL) {
5002 return NULL;
5003 }
5004 int end_lineno = token->end_lineno;
5005 UNUSED(end_lineno); // Only used by EXTRA macro
5006 int end_col_offset = token->end_col_offset;
5007 UNUSED(end_col_offset); // Only used by EXTRA macro
5008 res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA );
5009 if (res == NULL && PyErr_Occurred()) {
5010 p->error_indicator = 1;
5011 return NULL;
5012 }
5013 goto done;
5014 }
5015 p->mark = mark;
5016 }
5017 { // expression !':='
5018 expr_ty expression_var;
5019 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005020 (expression_var = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005021 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005022 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005023 )
5024 {
5025 res = expression_var;
5026 goto done;
5027 }
5028 p->mark = mark;
5029 }
5030 { // invalid_named_expression
5031 void *invalid_named_expression_var;
5032 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005033 (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005034 )
5035 {
5036 res = invalid_named_expression_var;
5037 goto done;
5038 }
5039 p->mark = mark;
5040 }
5041 res = NULL;
5042 done:
5043 return res;
5044}
5045
5046// annotated_rhs: yield_expr | star_expressions
5047static expr_ty
5048annotated_rhs_rule(Parser *p)
5049{
5050 if (p->error_indicator) {
5051 return NULL;
5052 }
5053 expr_ty res = NULL;
5054 int mark = p->mark;
5055 { // yield_expr
5056 expr_ty yield_expr_var;
5057 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005058 (yield_expr_var = yield_expr_rule(p)) // yield_expr
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005059 )
5060 {
5061 res = yield_expr_var;
5062 goto done;
5063 }
5064 p->mark = mark;
5065 }
5066 { // star_expressions
5067 expr_ty star_expressions_var;
5068 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005069 (star_expressions_var = star_expressions_rule(p)) // star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005070 )
5071 {
5072 res = star_expressions_var;
5073 goto done;
5074 }
5075 p->mark = mark;
5076 }
5077 res = NULL;
5078 done:
5079 return res;
5080}
5081
5082// expressions: expression ((',' expression))+ ','? | expression ',' | expression
5083static expr_ty
5084expressions_rule(Parser *p)
5085{
5086 if (p->error_indicator) {
5087 return NULL;
5088 }
5089 expr_ty res = NULL;
5090 int mark = p->mark;
5091 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5092 p->error_indicator = 1;
5093 return NULL;
5094 }
5095 int start_lineno = p->tokens[mark]->lineno;
5096 UNUSED(start_lineno); // Only used by EXTRA macro
5097 int start_col_offset = p->tokens[mark]->col_offset;
5098 UNUSED(start_col_offset); // Only used by EXTRA macro
5099 { // expression ((',' expression))+ ','?
5100 expr_ty a;
5101 asdl_seq * b;
5102 void *opt_var;
5103 UNUSED(opt_var); // Silence compiler warnings
5104 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005105 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005106 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005107 (b = _loop1_74_rule(p)) // ((',' expression))+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005108 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005109 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005110 )
5111 {
5112 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5113 if (token == NULL) {
5114 return NULL;
5115 }
5116 int end_lineno = token->end_lineno;
5117 UNUSED(end_lineno); // Only used by EXTRA macro
5118 int end_col_offset = token->end_col_offset;
5119 UNUSED(end_col_offset); // Only used by EXTRA macro
5120 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
5121 if (res == NULL && PyErr_Occurred()) {
5122 p->error_indicator = 1;
5123 return NULL;
5124 }
5125 goto done;
5126 }
5127 p->mark = mark;
5128 }
5129 { // expression ','
5130 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005131 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005132 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005133 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005134 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005135 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005136 )
5137 {
5138 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5139 if (token == NULL) {
5140 return NULL;
5141 }
5142 int end_lineno = token->end_lineno;
5143 UNUSED(end_lineno); // Only used by EXTRA macro
5144 int end_col_offset = token->end_col_offset;
5145 UNUSED(end_col_offset); // Only used by EXTRA macro
5146 res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
5147 if (res == NULL && PyErr_Occurred()) {
5148 p->error_indicator = 1;
5149 return NULL;
5150 }
5151 goto done;
5152 }
5153 p->mark = mark;
5154 }
5155 { // expression
5156 expr_ty expression_var;
5157 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005158 (expression_var = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005159 )
5160 {
5161 res = expression_var;
5162 goto done;
5163 }
5164 p->mark = mark;
5165 }
5166 res = NULL;
5167 done:
5168 return res;
5169}
5170
5171// expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef
5172static expr_ty
5173expression_rule(Parser *p)
5174{
5175 if (p->error_indicator) {
5176 return NULL;
5177 }
5178 expr_ty res = NULL;
5179 if (_PyPegen_is_memoized(p, expression_type, &res))
5180 return res;
5181 int mark = p->mark;
5182 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5183 p->error_indicator = 1;
5184 return NULL;
5185 }
5186 int start_lineno = p->tokens[mark]->lineno;
5187 UNUSED(start_lineno); // Only used by EXTRA macro
5188 int start_col_offset = p->tokens[mark]->col_offset;
5189 UNUSED(start_col_offset); // Only used by EXTRA macro
5190 { // disjunction 'if' disjunction 'else' expression
5191 expr_ty a;
5192 expr_ty b;
5193 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005194 Token * keyword;
5195 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005196 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005197 (a = disjunction_rule(p)) // disjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005198 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005199 (keyword = _PyPegen_expect_token(p, 510)) // token='if'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005200 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005201 (b = disjunction_rule(p)) // disjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005202 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005203 (keyword_1 = _PyPegen_expect_token(p, 516)) // token='else'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005204 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005205 (c = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005206 )
5207 {
5208 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5209 if (token == NULL) {
5210 return NULL;
5211 }
5212 int end_lineno = token->end_lineno;
5213 UNUSED(end_lineno); // Only used by EXTRA macro
5214 int end_col_offset = token->end_col_offset;
5215 UNUSED(end_col_offset); // Only used by EXTRA macro
5216 res = _Py_IfExp ( b , a , c , EXTRA );
5217 if (res == NULL && PyErr_Occurred()) {
5218 p->error_indicator = 1;
5219 return NULL;
5220 }
5221 goto done;
5222 }
5223 p->mark = mark;
5224 }
5225 { // disjunction
5226 expr_ty disjunction_var;
5227 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005228 (disjunction_var = disjunction_rule(p)) // disjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005229 )
5230 {
5231 res = disjunction_var;
5232 goto done;
5233 }
5234 p->mark = mark;
5235 }
5236 { // lambdef
5237 expr_ty lambdef_var;
5238 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005239 (lambdef_var = lambdef_rule(p)) // lambdef
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005240 )
5241 {
5242 res = lambdef_var;
5243 goto done;
5244 }
5245 p->mark = mark;
5246 }
5247 res = NULL;
5248 done:
5249 _PyPegen_insert_memo(p, mark, expression_type, res);
5250 return res;
5251}
5252
5253// lambdef: 'lambda' lambda_parameters? ':' expression
5254static expr_ty
5255lambdef_rule(Parser *p)
5256{
5257 if (p->error_indicator) {
5258 return NULL;
5259 }
5260 expr_ty res = NULL;
5261 int mark = p->mark;
5262 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5263 p->error_indicator = 1;
5264 return NULL;
5265 }
5266 int start_lineno = p->tokens[mark]->lineno;
5267 UNUSED(start_lineno); // Only used by EXTRA macro
5268 int start_col_offset = p->tokens[mark]->col_offset;
5269 UNUSED(start_col_offset); // Only used by EXTRA macro
5270 { // 'lambda' lambda_parameters? ':' expression
5271 void *a;
5272 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005273 Token * keyword;
5274 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005275 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005276 (keyword = _PyPegen_expect_token(p, 524)) // token='lambda'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005277 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005278 (a = lambda_parameters_rule(p), 1) // lambda_parameters?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005279 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005280 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005281 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005282 (b = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005283 )
5284 {
5285 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5286 if (token == NULL) {
5287 return NULL;
5288 }
5289 int end_lineno = token->end_lineno;
5290 UNUSED(end_lineno); // Only used by EXTRA macro
5291 int end_col_offset = token->end_col_offset;
5292 UNUSED(end_col_offset); // Only used by EXTRA macro
5293 res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA );
5294 if (res == NULL && PyErr_Occurred()) {
5295 p->error_indicator = 1;
5296 return NULL;
5297 }
5298 goto done;
5299 }
5300 p->mark = mark;
5301 }
5302 res = NULL;
5303 done:
5304 return res;
5305}
5306
5307// lambda_parameters:
Guido van Rossum3941d972020-05-01 09:42:03 -07005308// | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
5309// | lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
5310// | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
5311// | lambda_param_with_default+ lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005312// | lambda_star_etc
5313static arguments_ty
5314lambda_parameters_rule(Parser *p)
5315{
5316 if (p->error_indicator) {
5317 return NULL;
5318 }
5319 arguments_ty res = NULL;
5320 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -07005321 { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005322 asdl_seq* a;
Guido van Rossum3941d972020-05-01 09:42:03 -07005323 asdl_seq * b;
5324 asdl_seq * c;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005325 void *d;
5326 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005327 (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005328 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005329 (b = _loop0_75_rule(p)) // lambda_param_no_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005330 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005331 (c = _loop0_76_rule(p)) // lambda_param_with_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005332 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005333 (d = lambda_star_etc_rule(p), 1) // lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005334 )
5335 {
5336 res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
5337 if (res == NULL && PyErr_Occurred()) {
5338 p->error_indicator = 1;
5339 return NULL;
5340 }
5341 goto done;
5342 }
5343 p->mark = mark;
5344 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005345 { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005346 SlashWithDefault* a;
Guido van Rossum3941d972020-05-01 09:42:03 -07005347 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005348 void *c;
5349 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005350 (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005351 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005352 (b = _loop0_77_rule(p)) // lambda_param_with_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005353 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005354 (c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005355 )
5356 {
5357 res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
5358 if (res == NULL && PyErr_Occurred()) {
5359 p->error_indicator = 1;
5360 return NULL;
5361 }
5362 goto done;
5363 }
5364 p->mark = mark;
5365 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005366 { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
5367 asdl_seq * a;
5368 asdl_seq * b;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005369 void *c;
5370 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005371 (a = _loop1_78_rule(p)) // lambda_param_no_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005372 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005373 (b = _loop0_79_rule(p)) // lambda_param_with_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005374 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005375 (c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005376 )
5377 {
5378 res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
5379 if (res == NULL && PyErr_Occurred()) {
5380 p->error_indicator = 1;
5381 return NULL;
5382 }
5383 goto done;
5384 }
5385 p->mark = mark;
5386 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005387 { // lambda_param_with_default+ lambda_star_etc?
5388 asdl_seq * a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005389 void *b;
5390 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005391 (a = _loop1_80_rule(p)) // lambda_param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005392 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005393 (b = lambda_star_etc_rule(p), 1) // lambda_star_etc?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005394 )
5395 {
5396 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
5397 if (res == NULL && PyErr_Occurred()) {
5398 p->error_indicator = 1;
5399 return NULL;
5400 }
5401 goto done;
5402 }
5403 p->mark = mark;
5404 }
5405 { // lambda_star_etc
5406 StarEtc* a;
5407 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005408 (a = lambda_star_etc_rule(p)) // lambda_star_etc
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005409 )
5410 {
5411 res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
5412 if (res == NULL && PyErr_Occurred()) {
5413 p->error_indicator = 1;
5414 return NULL;
5415 }
5416 goto done;
5417 }
5418 p->mark = mark;
5419 }
5420 res = NULL;
5421 done:
5422 return res;
5423}
5424
Guido van Rossum3941d972020-05-01 09:42:03 -07005425// lambda_slash_no_default:
5426// | lambda_param_no_default+ '/' ','
5427// | lambda_param_no_default+ '/' &':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005428static asdl_seq*
Guido van Rossum3941d972020-05-01 09:42:03 -07005429lambda_slash_no_default_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005430{
5431 if (p->error_indicator) {
5432 return NULL;
5433 }
5434 asdl_seq* res = NULL;
5435 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -07005436 { // lambda_param_no_default+ '/' ','
5437 asdl_seq * a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005438 Token * literal;
5439 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005440 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005441 (a = _loop1_81_rule(p)) // lambda_param_no_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005442 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005443 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005444 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005445 (literal_1 = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossum3941d972020-05-01 09:42:03 -07005446 )
5447 {
5448 res = a;
5449 if (res == NULL && PyErr_Occurred()) {
5450 p->error_indicator = 1;
5451 return NULL;
5452 }
5453 goto done;
5454 }
5455 p->mark = mark;
5456 }
5457 { // lambda_param_no_default+ '/' &':'
5458 asdl_seq * a;
5459 Token * literal;
5460 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005461 (a = _loop1_82_rule(p)) // lambda_param_no_default+
Guido van Rossum3941d972020-05-01 09:42:03 -07005462 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005463 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Guido van Rossum3941d972020-05-01 09:42:03 -07005464 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005465 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005466 )
5467 {
5468 res = a;
5469 if (res == NULL && PyErr_Occurred()) {
5470 p->error_indicator = 1;
5471 return NULL;
5472 }
5473 goto done;
5474 }
5475 p->mark = mark;
5476 }
5477 res = NULL;
5478 done:
5479 return res;
5480}
5481
Guido van Rossum3941d972020-05-01 09:42:03 -07005482// lambda_slash_with_default:
5483// | lambda_param_no_default* lambda_param_with_default+ '/' ','
5484// | lambda_param_no_default* lambda_param_with_default+ '/' &':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005485static SlashWithDefault*
5486lambda_slash_with_default_rule(Parser *p)
5487{
5488 if (p->error_indicator) {
5489 return NULL;
5490 }
5491 SlashWithDefault* res = NULL;
5492 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -07005493 { // lambda_param_no_default* lambda_param_with_default+ '/' ','
5494 asdl_seq * a;
5495 asdl_seq * b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005496 Token * literal;
5497 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005498 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005499 (a = _loop0_83_rule(p)) // lambda_param_no_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005500 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005501 (b = _loop1_84_rule(p)) // lambda_param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005502 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005503 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005504 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005505 (literal_1 = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossum3941d972020-05-01 09:42:03 -07005506 )
5507 {
5508 res = _PyPegen_slash_with_default ( p , a , b );
5509 if (res == NULL && PyErr_Occurred()) {
5510 p->error_indicator = 1;
5511 return NULL;
5512 }
5513 goto done;
5514 }
5515 p->mark = mark;
5516 }
5517 { // lambda_param_no_default* lambda_param_with_default+ '/' &':'
5518 asdl_seq * a;
5519 asdl_seq * b;
5520 Token * literal;
5521 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005522 (a = _loop0_85_rule(p)) // lambda_param_no_default*
Guido van Rossum3941d972020-05-01 09:42:03 -07005523 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005524 (b = _loop1_86_rule(p)) // lambda_param_with_default+
Guido van Rossum3941d972020-05-01 09:42:03 -07005525 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005526 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Guido van Rossum3941d972020-05-01 09:42:03 -07005527 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005528 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005529 )
5530 {
5531 res = _PyPegen_slash_with_default ( p , a , b );
5532 if (res == NULL && PyErr_Occurred()) {
5533 p->error_indicator = 1;
5534 return NULL;
5535 }
5536 goto done;
5537 }
5538 p->mark = mark;
5539 }
5540 res = NULL;
5541 done:
5542 return res;
5543}
5544
5545// lambda_star_etc:
Guido van Rossum3941d972020-05-01 09:42:03 -07005546// | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
5547// | '*' ',' lambda_param_maybe_default+ lambda_kwds?
5548// | lambda_kwds
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03005549// | invalid_lambda_star_etc
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005550static StarEtc*
5551lambda_star_etc_rule(Parser *p)
5552{
5553 if (p->error_indicator) {
5554 return NULL;
5555 }
5556 StarEtc* res = NULL;
5557 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -07005558 { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005559 arg_ty a;
5560 asdl_seq * b;
5561 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005562 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005563 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005564 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005565 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005566 (a = lambda_param_no_default_rule(p)) // lambda_param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005567 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005568 (b = _loop0_87_rule(p)) // lambda_param_maybe_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005569 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005570 (c = lambda_kwds_rule(p), 1) // lambda_kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005571 )
5572 {
5573 res = _PyPegen_star_etc ( p , a , b , c );
5574 if (res == NULL && PyErr_Occurred()) {
5575 p->error_indicator = 1;
5576 return NULL;
5577 }
5578 goto done;
5579 }
5580 p->mark = mark;
5581 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005582 { // '*' ',' lambda_param_maybe_default+ lambda_kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005583 asdl_seq * b;
5584 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01005585 Token * literal;
Guido van Rossum3941d972020-05-01 09:42:03 -07005586 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005587 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005588 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005589 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005590 (literal_1 = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005591 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005592 (b = _loop1_88_rule(p)) // lambda_param_maybe_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005593 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005594 (c = lambda_kwds_rule(p), 1) // lambda_kwds?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005595 )
5596 {
5597 res = _PyPegen_star_etc ( p , NULL , b , c );
5598 if (res == NULL && PyErr_Occurred()) {
5599 p->error_indicator = 1;
5600 return NULL;
5601 }
5602 goto done;
5603 }
5604 p->mark = mark;
5605 }
Guido van Rossum3941d972020-05-01 09:42:03 -07005606 { // lambda_kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005607 arg_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005608 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005609 (a = lambda_kwds_rule(p)) // lambda_kwds
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005610 )
5611 {
5612 res = _PyPegen_star_etc ( p , NULL , NULL , a );
5613 if (res == NULL && PyErr_Occurred()) {
5614 p->error_indicator = 1;
5615 return NULL;
5616 }
5617 goto done;
5618 }
5619 p->mark = mark;
5620 }
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03005621 { // invalid_lambda_star_etc
5622 void *invalid_lambda_star_etc_var;
5623 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005624 (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +03005625 )
5626 {
5627 res = invalid_lambda_star_etc_var;
5628 goto done;
5629 }
5630 p->mark = mark;
5631 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005632 res = NULL;
5633 done:
5634 return res;
5635}
5636
Guido van Rossum3941d972020-05-01 09:42:03 -07005637// lambda_kwds: '**' lambda_param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005638static arg_ty
Guido van Rossum3941d972020-05-01 09:42:03 -07005639lambda_kwds_rule(Parser *p)
5640{
5641 if (p->error_indicator) {
5642 return NULL;
5643 }
5644 arg_ty res = NULL;
5645 int mark = p->mark;
5646 { // '**' lambda_param_no_default
5647 arg_ty a;
5648 Token * literal;
5649 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005650 (literal = _PyPegen_expect_token(p, 35)) // token='**'
Guido van Rossum3941d972020-05-01 09:42:03 -07005651 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005652 (a = lambda_param_no_default_rule(p)) // lambda_param_no_default
Guido van Rossum3941d972020-05-01 09:42:03 -07005653 )
5654 {
5655 res = a;
5656 if (res == NULL && PyErr_Occurred()) {
5657 p->error_indicator = 1;
5658 return NULL;
5659 }
5660 goto done;
5661 }
5662 p->mark = mark;
5663 }
5664 res = NULL;
5665 done:
5666 return res;
5667}
5668
5669// lambda_param_no_default: lambda_param ',' | lambda_param &':'
5670static arg_ty
5671lambda_param_no_default_rule(Parser *p)
5672{
5673 if (p->error_indicator) {
5674 return NULL;
5675 }
5676 arg_ty res = NULL;
5677 int mark = p->mark;
5678 { // lambda_param ','
5679 arg_ty a;
5680 Token * literal;
5681 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005682 (a = lambda_param_rule(p)) // lambda_param
Guido van Rossum3941d972020-05-01 09:42:03 -07005683 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005684 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossum3941d972020-05-01 09:42:03 -07005685 )
5686 {
5687 res = a;
5688 if (res == NULL && PyErr_Occurred()) {
5689 p->error_indicator = 1;
5690 return NULL;
5691 }
5692 goto done;
5693 }
5694 p->mark = mark;
5695 }
5696 { // lambda_param &':'
5697 arg_ty a;
5698 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005699 (a = lambda_param_rule(p)) // lambda_param
Guido van Rossum3941d972020-05-01 09:42:03 -07005700 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005701 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
Guido van Rossum3941d972020-05-01 09:42:03 -07005702 )
5703 {
5704 res = a;
5705 if (res == NULL && PyErr_Occurred()) {
5706 p->error_indicator = 1;
5707 return NULL;
5708 }
5709 goto done;
5710 }
5711 p->mark = mark;
5712 }
5713 res = NULL;
5714 done:
5715 return res;
5716}
5717
5718// lambda_param_with_default: lambda_param default ',' | lambda_param default &':'
5719static NameDefaultPair*
5720lambda_param_with_default_rule(Parser *p)
5721{
5722 if (p->error_indicator) {
5723 return NULL;
5724 }
5725 NameDefaultPair* res = NULL;
5726 int mark = p->mark;
5727 { // lambda_param default ','
5728 arg_ty a;
5729 expr_ty c;
5730 Token * literal;
5731 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005732 (a = lambda_param_rule(p)) // lambda_param
Guido van Rossum3941d972020-05-01 09:42:03 -07005733 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005734 (c = default_rule(p)) // default
Guido van Rossum3941d972020-05-01 09:42:03 -07005735 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005736 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossum3941d972020-05-01 09:42:03 -07005737 )
5738 {
5739 res = _PyPegen_name_default_pair ( p , a , c , NULL );
5740 if (res == NULL && PyErr_Occurred()) {
5741 p->error_indicator = 1;
5742 return NULL;
5743 }
5744 goto done;
5745 }
5746 p->mark = mark;
5747 }
5748 { // lambda_param default &':'
5749 arg_ty a;
5750 expr_ty c;
5751 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005752 (a = lambda_param_rule(p)) // lambda_param
Guido van Rossum3941d972020-05-01 09:42:03 -07005753 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005754 (c = default_rule(p)) // default
Guido van Rossum3941d972020-05-01 09:42:03 -07005755 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005756 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
Guido van Rossum3941d972020-05-01 09:42:03 -07005757 )
5758 {
5759 res = _PyPegen_name_default_pair ( p , a , c , NULL );
5760 if (res == NULL && PyErr_Occurred()) {
5761 p->error_indicator = 1;
5762 return NULL;
5763 }
5764 goto done;
5765 }
5766 p->mark = mark;
5767 }
5768 res = NULL;
5769 done:
5770 return res;
5771}
5772
5773// lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':'
5774static NameDefaultPair*
5775lambda_param_maybe_default_rule(Parser *p)
5776{
5777 if (p->error_indicator) {
5778 return NULL;
5779 }
5780 NameDefaultPair* res = NULL;
5781 int mark = p->mark;
5782 { // lambda_param default? ','
5783 arg_ty a;
5784 void *c;
5785 Token * literal;
5786 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005787 (a = lambda_param_rule(p)) // lambda_param
Guido van Rossum3941d972020-05-01 09:42:03 -07005788 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005789 (c = default_rule(p), 1) // default?
Guido van Rossum3941d972020-05-01 09:42:03 -07005790 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005791 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossum3941d972020-05-01 09:42:03 -07005792 )
5793 {
5794 res = _PyPegen_name_default_pair ( p , a , c , NULL );
5795 if (res == NULL && PyErr_Occurred()) {
5796 p->error_indicator = 1;
5797 return NULL;
5798 }
5799 goto done;
5800 }
5801 p->mark = mark;
5802 }
5803 { // lambda_param default? &':'
5804 arg_ty a;
5805 void *c;
5806 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005807 (a = lambda_param_rule(p)) // lambda_param
Guido van Rossum3941d972020-05-01 09:42:03 -07005808 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005809 (c = default_rule(p), 1) // default?
Guido van Rossum3941d972020-05-01 09:42:03 -07005810 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005811 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
Guido van Rossum3941d972020-05-01 09:42:03 -07005812 )
5813 {
5814 res = _PyPegen_name_default_pair ( p , a , c , NULL );
5815 if (res == NULL && PyErr_Occurred()) {
5816 p->error_indicator = 1;
5817 return NULL;
5818 }
5819 goto done;
5820 }
5821 p->mark = mark;
5822 }
5823 res = NULL;
5824 done:
5825 return res;
5826}
5827
5828// lambda_param: NAME
5829static arg_ty
5830lambda_param_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005831{
5832 if (p->error_indicator) {
5833 return NULL;
5834 }
5835 arg_ty res = NULL;
5836 int mark = p->mark;
5837 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5838 p->error_indicator = 1;
5839 return NULL;
5840 }
5841 int start_lineno = p->tokens[mark]->lineno;
5842 UNUSED(start_lineno); // Only used by EXTRA macro
5843 int start_col_offset = p->tokens[mark]->col_offset;
5844 UNUSED(start_col_offset); // Only used by EXTRA macro
5845 { // NAME
5846 expr_ty a;
5847 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005848 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005849 )
5850 {
5851 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5852 if (token == NULL) {
5853 return NULL;
5854 }
5855 int end_lineno = token->end_lineno;
5856 UNUSED(end_lineno); // Only used by EXTRA macro
5857 int end_col_offset = token->end_col_offset;
5858 UNUSED(end_col_offset); // Only used by EXTRA macro
5859 res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA );
5860 if (res == NULL && PyErr_Occurred()) {
5861 p->error_indicator = 1;
5862 return NULL;
5863 }
5864 goto done;
5865 }
5866 p->mark = mark;
5867 }
5868 res = NULL;
5869 done:
5870 return res;
5871}
5872
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005873// disjunction: conjunction (('or' conjunction))+ | conjunction
5874static expr_ty
5875disjunction_rule(Parser *p)
5876{
5877 if (p->error_indicator) {
5878 return NULL;
5879 }
5880 expr_ty res = NULL;
5881 if (_PyPegen_is_memoized(p, disjunction_type, &res))
5882 return res;
5883 int mark = p->mark;
5884 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5885 p->error_indicator = 1;
5886 return NULL;
5887 }
5888 int start_lineno = p->tokens[mark]->lineno;
5889 UNUSED(start_lineno); // Only used by EXTRA macro
5890 int start_col_offset = p->tokens[mark]->col_offset;
5891 UNUSED(start_col_offset); // Only used by EXTRA macro
5892 { // conjunction (('or' conjunction))+
5893 expr_ty a;
5894 asdl_seq * b;
5895 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005896 (a = conjunction_rule(p)) // conjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005897 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005898 (b = _loop1_89_rule(p)) // (('or' conjunction))+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005899 )
5900 {
5901 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5902 if (token == NULL) {
5903 return NULL;
5904 }
5905 int end_lineno = token->end_lineno;
5906 UNUSED(end_lineno); // Only used by EXTRA macro
5907 int end_col_offset = token->end_col_offset;
5908 UNUSED(end_col_offset); // Only used by EXTRA macro
5909 res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
5910 if (res == NULL && PyErr_Occurred()) {
5911 p->error_indicator = 1;
5912 return NULL;
5913 }
5914 goto done;
5915 }
5916 p->mark = mark;
5917 }
5918 { // conjunction
5919 expr_ty conjunction_var;
5920 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005921 (conjunction_var = conjunction_rule(p)) // conjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005922 )
5923 {
5924 res = conjunction_var;
5925 goto done;
5926 }
5927 p->mark = mark;
5928 }
5929 res = NULL;
5930 done:
5931 _PyPegen_insert_memo(p, mark, disjunction_type, res);
5932 return res;
5933}
5934
5935// conjunction: inversion (('and' inversion))+ | inversion
5936static expr_ty
5937conjunction_rule(Parser *p)
5938{
5939 if (p->error_indicator) {
5940 return NULL;
5941 }
5942 expr_ty res = NULL;
5943 if (_PyPegen_is_memoized(p, conjunction_type, &res))
5944 return res;
5945 int mark = p->mark;
5946 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
5947 p->error_indicator = 1;
5948 return NULL;
5949 }
5950 int start_lineno = p->tokens[mark]->lineno;
5951 UNUSED(start_lineno); // Only used by EXTRA macro
5952 int start_col_offset = p->tokens[mark]->col_offset;
5953 UNUSED(start_col_offset); // Only used by EXTRA macro
5954 { // inversion (('and' inversion))+
5955 expr_ty a;
5956 asdl_seq * b;
5957 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005958 (a = inversion_rule(p)) // inversion
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005959 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01005960 (b = _loop1_90_rule(p)) // (('and' inversion))+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005961 )
5962 {
5963 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
5964 if (token == NULL) {
5965 return NULL;
5966 }
5967 int end_lineno = token->end_lineno;
5968 UNUSED(end_lineno); // Only used by EXTRA macro
5969 int end_col_offset = token->end_col_offset;
5970 UNUSED(end_col_offset); // Only used by EXTRA macro
5971 res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
5972 if (res == NULL && PyErr_Occurred()) {
5973 p->error_indicator = 1;
5974 return NULL;
5975 }
5976 goto done;
5977 }
5978 p->mark = mark;
5979 }
5980 { // inversion
5981 expr_ty inversion_var;
5982 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01005983 (inversion_var = inversion_rule(p)) // inversion
Pablo Galindoc5fc1562020-04-22 23:29:27 +01005984 )
5985 {
5986 res = inversion_var;
5987 goto done;
5988 }
5989 p->mark = mark;
5990 }
5991 res = NULL;
5992 done:
5993 _PyPegen_insert_memo(p, mark, conjunction_type, res);
5994 return res;
5995}
5996
5997// inversion: 'not' inversion | comparison
5998static expr_ty
5999inversion_rule(Parser *p)
6000{
6001 if (p->error_indicator) {
6002 return NULL;
6003 }
6004 expr_ty res = NULL;
6005 if (_PyPegen_is_memoized(p, inversion_type, &res))
6006 return res;
6007 int mark = p->mark;
6008 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6009 p->error_indicator = 1;
6010 return NULL;
6011 }
6012 int start_lineno = p->tokens[mark]->lineno;
6013 UNUSED(start_lineno); // Only used by EXTRA macro
6014 int start_col_offset = p->tokens[mark]->col_offset;
6015 UNUSED(start_col_offset); // Only used by EXTRA macro
6016 { // 'not' inversion
6017 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006018 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006019 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006020 (keyword = _PyPegen_expect_token(p, 525)) // token='not'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006021 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006022 (a = inversion_rule(p)) // inversion
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006023 )
6024 {
6025 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6026 if (token == NULL) {
6027 return NULL;
6028 }
6029 int end_lineno = token->end_lineno;
6030 UNUSED(end_lineno); // Only used by EXTRA macro
6031 int end_col_offset = token->end_col_offset;
6032 UNUSED(end_col_offset); // Only used by EXTRA macro
6033 res = _Py_UnaryOp ( Not , a , EXTRA );
6034 if (res == NULL && PyErr_Occurred()) {
6035 p->error_indicator = 1;
6036 return NULL;
6037 }
6038 goto done;
6039 }
6040 p->mark = mark;
6041 }
6042 { // comparison
6043 expr_ty comparison_var;
6044 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006045 (comparison_var = comparison_rule(p)) // comparison
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006046 )
6047 {
6048 res = comparison_var;
6049 goto done;
6050 }
6051 p->mark = mark;
6052 }
6053 res = NULL;
6054 done:
6055 _PyPegen_insert_memo(p, mark, inversion_type, res);
6056 return res;
6057}
6058
6059// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or
6060static expr_ty
6061comparison_rule(Parser *p)
6062{
6063 if (p->error_indicator) {
6064 return NULL;
6065 }
6066 expr_ty res = NULL;
6067 int mark = p->mark;
6068 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6069 p->error_indicator = 1;
6070 return NULL;
6071 }
6072 int start_lineno = p->tokens[mark]->lineno;
6073 UNUSED(start_lineno); // Only used by EXTRA macro
6074 int start_col_offset = p->tokens[mark]->col_offset;
6075 UNUSED(start_col_offset); // Only used by EXTRA macro
6076 { // bitwise_or compare_op_bitwise_or_pair+
6077 expr_ty a;
6078 asdl_seq * b;
6079 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006080 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006081 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006082 (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006083 )
6084 {
6085 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6086 if (token == NULL) {
6087 return NULL;
6088 }
6089 int end_lineno = token->end_lineno;
6090 UNUSED(end_lineno); // Only used by EXTRA macro
6091 int end_col_offset = token->end_col_offset;
6092 UNUSED(end_col_offset); // Only used by EXTRA macro
6093 res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA );
6094 if (res == NULL && PyErr_Occurred()) {
6095 p->error_indicator = 1;
6096 return NULL;
6097 }
6098 goto done;
6099 }
6100 p->mark = mark;
6101 }
6102 { // bitwise_or
6103 expr_ty bitwise_or_var;
6104 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006105 (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006106 )
6107 {
6108 res = bitwise_or_var;
6109 goto done;
6110 }
6111 p->mark = mark;
6112 }
6113 res = NULL;
6114 done:
6115 return res;
6116}
6117
6118// compare_op_bitwise_or_pair:
6119// | eq_bitwise_or
6120// | noteq_bitwise_or
6121// | lte_bitwise_or
6122// | lt_bitwise_or
6123// | gte_bitwise_or
6124// | gt_bitwise_or
6125// | notin_bitwise_or
6126// | in_bitwise_or
6127// | isnot_bitwise_or
6128// | is_bitwise_or
6129static CmpopExprPair*
6130compare_op_bitwise_or_pair_rule(Parser *p)
6131{
6132 if (p->error_indicator) {
6133 return NULL;
6134 }
6135 CmpopExprPair* res = NULL;
6136 int mark = p->mark;
6137 { // eq_bitwise_or
6138 CmpopExprPair* eq_bitwise_or_var;
6139 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006140 (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006141 )
6142 {
6143 res = eq_bitwise_or_var;
6144 goto done;
6145 }
6146 p->mark = mark;
6147 }
6148 { // noteq_bitwise_or
6149 CmpopExprPair* noteq_bitwise_or_var;
6150 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006151 (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006152 )
6153 {
6154 res = noteq_bitwise_or_var;
6155 goto done;
6156 }
6157 p->mark = mark;
6158 }
6159 { // lte_bitwise_or
6160 CmpopExprPair* lte_bitwise_or_var;
6161 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006162 (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006163 )
6164 {
6165 res = lte_bitwise_or_var;
6166 goto done;
6167 }
6168 p->mark = mark;
6169 }
6170 { // lt_bitwise_or
6171 CmpopExprPair* lt_bitwise_or_var;
6172 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006173 (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006174 )
6175 {
6176 res = lt_bitwise_or_var;
6177 goto done;
6178 }
6179 p->mark = mark;
6180 }
6181 { // gte_bitwise_or
6182 CmpopExprPair* gte_bitwise_or_var;
6183 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006184 (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006185 )
6186 {
6187 res = gte_bitwise_or_var;
6188 goto done;
6189 }
6190 p->mark = mark;
6191 }
6192 { // gt_bitwise_or
6193 CmpopExprPair* gt_bitwise_or_var;
6194 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006195 (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006196 )
6197 {
6198 res = gt_bitwise_or_var;
6199 goto done;
6200 }
6201 p->mark = mark;
6202 }
6203 { // notin_bitwise_or
6204 CmpopExprPair* notin_bitwise_or_var;
6205 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006206 (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006207 )
6208 {
6209 res = notin_bitwise_or_var;
6210 goto done;
6211 }
6212 p->mark = mark;
6213 }
6214 { // in_bitwise_or
6215 CmpopExprPair* in_bitwise_or_var;
6216 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006217 (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006218 )
6219 {
6220 res = in_bitwise_or_var;
6221 goto done;
6222 }
6223 p->mark = mark;
6224 }
6225 { // isnot_bitwise_or
6226 CmpopExprPair* isnot_bitwise_or_var;
6227 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006228 (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006229 )
6230 {
6231 res = isnot_bitwise_or_var;
6232 goto done;
6233 }
6234 p->mark = mark;
6235 }
6236 { // is_bitwise_or
6237 CmpopExprPair* is_bitwise_or_var;
6238 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006239 (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006240 )
6241 {
6242 res = is_bitwise_or_var;
6243 goto done;
6244 }
6245 p->mark = mark;
6246 }
6247 res = NULL;
6248 done:
6249 return res;
6250}
6251
6252// eq_bitwise_or: '==' bitwise_or
6253static CmpopExprPair*
6254eq_bitwise_or_rule(Parser *p)
6255{
6256 if (p->error_indicator) {
6257 return NULL;
6258 }
6259 CmpopExprPair* res = NULL;
6260 int mark = p->mark;
6261 { // '==' bitwise_or
6262 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006263 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006264 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006265 (literal = _PyPegen_expect_token(p, 27)) // token='=='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006266 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006267 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006268 )
6269 {
6270 res = _PyPegen_cmpop_expr_pair ( p , Eq , a );
6271 if (res == NULL && PyErr_Occurred()) {
6272 p->error_indicator = 1;
6273 return NULL;
6274 }
6275 goto done;
6276 }
6277 p->mark = mark;
6278 }
6279 res = NULL;
6280 done:
6281 return res;
6282}
6283
Pablo Galindo2b74c832020-04-27 18:02:07 +01006284// noteq_bitwise_or: ('!=') bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006285static CmpopExprPair*
6286noteq_bitwise_or_rule(Parser *p)
6287{
6288 if (p->error_indicator) {
6289 return NULL;
6290 }
6291 CmpopExprPair* res = NULL;
6292 int mark = p->mark;
Pablo Galindo2b74c832020-04-27 18:02:07 +01006293 { // ('!=') bitwise_or
Guido van Rossum3941d972020-05-01 09:42:03 -07006294 void *_tmp_92_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006295 expr_ty a;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006296 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006297 (_tmp_92_var = _tmp_92_rule(p)) // '!='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006298 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006299 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006300 )
6301 {
6302 res = _PyPegen_cmpop_expr_pair ( p , NotEq , a );
6303 if (res == NULL && PyErr_Occurred()) {
6304 p->error_indicator = 1;
6305 return NULL;
6306 }
6307 goto done;
6308 }
6309 p->mark = mark;
6310 }
6311 res = NULL;
6312 done:
6313 return res;
6314}
6315
6316// lte_bitwise_or: '<=' bitwise_or
6317static CmpopExprPair*
6318lte_bitwise_or_rule(Parser *p)
6319{
6320 if (p->error_indicator) {
6321 return NULL;
6322 }
6323 CmpopExprPair* res = NULL;
6324 int mark = p->mark;
6325 { // '<=' bitwise_or
6326 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006327 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006328 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006329 (literal = _PyPegen_expect_token(p, 29)) // token='<='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006330 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006331 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006332 )
6333 {
6334 res = _PyPegen_cmpop_expr_pair ( p , LtE , a );
6335 if (res == NULL && PyErr_Occurred()) {
6336 p->error_indicator = 1;
6337 return NULL;
6338 }
6339 goto done;
6340 }
6341 p->mark = mark;
6342 }
6343 res = NULL;
6344 done:
6345 return res;
6346}
6347
6348// lt_bitwise_or: '<' bitwise_or
6349static CmpopExprPair*
6350lt_bitwise_or_rule(Parser *p)
6351{
6352 if (p->error_indicator) {
6353 return NULL;
6354 }
6355 CmpopExprPair* res = NULL;
6356 int mark = p->mark;
6357 { // '<' bitwise_or
6358 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006359 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006360 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006361 (literal = _PyPegen_expect_token(p, 20)) // token='<'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006362 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006363 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006364 )
6365 {
6366 res = _PyPegen_cmpop_expr_pair ( p , Lt , a );
6367 if (res == NULL && PyErr_Occurred()) {
6368 p->error_indicator = 1;
6369 return NULL;
6370 }
6371 goto done;
6372 }
6373 p->mark = mark;
6374 }
6375 res = NULL;
6376 done:
6377 return res;
6378}
6379
6380// gte_bitwise_or: '>=' bitwise_or
6381static CmpopExprPair*
6382gte_bitwise_or_rule(Parser *p)
6383{
6384 if (p->error_indicator) {
6385 return NULL;
6386 }
6387 CmpopExprPair* res = NULL;
6388 int mark = p->mark;
6389 { // '>=' bitwise_or
6390 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006391 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006392 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006393 (literal = _PyPegen_expect_token(p, 30)) // token='>='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006394 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006395 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006396 )
6397 {
6398 res = _PyPegen_cmpop_expr_pair ( p , GtE , a );
6399 if (res == NULL && PyErr_Occurred()) {
6400 p->error_indicator = 1;
6401 return NULL;
6402 }
6403 goto done;
6404 }
6405 p->mark = mark;
6406 }
6407 res = NULL;
6408 done:
6409 return res;
6410}
6411
6412// gt_bitwise_or: '>' bitwise_or
6413static CmpopExprPair*
6414gt_bitwise_or_rule(Parser *p)
6415{
6416 if (p->error_indicator) {
6417 return NULL;
6418 }
6419 CmpopExprPair* res = NULL;
6420 int mark = p->mark;
6421 { // '>' bitwise_or
6422 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006423 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006424 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006425 (literal = _PyPegen_expect_token(p, 21)) // token='>'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006426 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006427 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006428 )
6429 {
6430 res = _PyPegen_cmpop_expr_pair ( p , Gt , a );
6431 if (res == NULL && PyErr_Occurred()) {
6432 p->error_indicator = 1;
6433 return NULL;
6434 }
6435 goto done;
6436 }
6437 p->mark = mark;
6438 }
6439 res = NULL;
6440 done:
6441 return res;
6442}
6443
6444// notin_bitwise_or: 'not' 'in' bitwise_or
6445static CmpopExprPair*
6446notin_bitwise_or_rule(Parser *p)
6447{
6448 if (p->error_indicator) {
6449 return NULL;
6450 }
6451 CmpopExprPair* res = NULL;
6452 int mark = p->mark;
6453 { // 'not' 'in' bitwise_or
6454 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006455 Token * keyword;
6456 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006457 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006458 (keyword = _PyPegen_expect_token(p, 525)) // token='not'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006459 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006460 (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006461 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006462 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006463 )
6464 {
6465 res = _PyPegen_cmpop_expr_pair ( p , NotIn , a );
6466 if (res == NULL && PyErr_Occurred()) {
6467 p->error_indicator = 1;
6468 return NULL;
6469 }
6470 goto done;
6471 }
6472 p->mark = mark;
6473 }
6474 res = NULL;
6475 done:
6476 return res;
6477}
6478
6479// in_bitwise_or: 'in' bitwise_or
6480static CmpopExprPair*
6481in_bitwise_or_rule(Parser *p)
6482{
6483 if (p->error_indicator) {
6484 return NULL;
6485 }
6486 CmpopExprPair* res = NULL;
6487 int mark = p->mark;
6488 { // 'in' bitwise_or
6489 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006490 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006491 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006492 (keyword = _PyPegen_expect_token(p, 518)) // token='in'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006493 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006494 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006495 )
6496 {
6497 res = _PyPegen_cmpop_expr_pair ( p , In , a );
6498 if (res == NULL && PyErr_Occurred()) {
6499 p->error_indicator = 1;
6500 return NULL;
6501 }
6502 goto done;
6503 }
6504 p->mark = mark;
6505 }
6506 res = NULL;
6507 done:
6508 return res;
6509}
6510
6511// isnot_bitwise_or: 'is' 'not' bitwise_or
6512static CmpopExprPair*
6513isnot_bitwise_or_rule(Parser *p)
6514{
6515 if (p->error_indicator) {
6516 return NULL;
6517 }
6518 CmpopExprPair* res = NULL;
6519 int mark = p->mark;
6520 { // 'is' 'not' bitwise_or
6521 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006522 Token * keyword;
6523 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006524 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006525 (keyword = _PyPegen_expect_token(p, 526)) // token='is'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006526 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006527 (keyword_1 = _PyPegen_expect_token(p, 525)) // token='not'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006528 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006529 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006530 )
6531 {
6532 res = _PyPegen_cmpop_expr_pair ( p , IsNot , a );
6533 if (res == NULL && PyErr_Occurred()) {
6534 p->error_indicator = 1;
6535 return NULL;
6536 }
6537 goto done;
6538 }
6539 p->mark = mark;
6540 }
6541 res = NULL;
6542 done:
6543 return res;
6544}
6545
6546// is_bitwise_or: 'is' bitwise_or
6547static CmpopExprPair*
6548is_bitwise_or_rule(Parser *p)
6549{
6550 if (p->error_indicator) {
6551 return NULL;
6552 }
6553 CmpopExprPair* res = NULL;
6554 int mark = p->mark;
6555 { // 'is' bitwise_or
6556 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006557 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006558 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006559 (keyword = _PyPegen_expect_token(p, 526)) // token='is'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006560 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006561 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006562 )
6563 {
6564 res = _PyPegen_cmpop_expr_pair ( p , Is , a );
6565 if (res == NULL && PyErr_Occurred()) {
6566 p->error_indicator = 1;
6567 return NULL;
6568 }
6569 goto done;
6570 }
6571 p->mark = mark;
6572 }
6573 res = NULL;
6574 done:
6575 return res;
6576}
6577
6578// Left-recursive
6579// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor
6580static expr_ty bitwise_or_raw(Parser *);
6581static expr_ty
6582bitwise_or_rule(Parser *p)
6583{
6584 expr_ty res = NULL;
6585 if (_PyPegen_is_memoized(p, bitwise_or_type, &res))
6586 return res;
6587 int mark = p->mark;
6588 int resmark = p->mark;
6589 while (1) {
6590 int tmpvar_1 = _PyPegen_update_memo(p, mark, bitwise_or_type, res);
6591 if (tmpvar_1) {
6592 return res;
6593 }
6594 p->mark = mark;
6595 void *raw = bitwise_or_raw(p);
6596 if (raw == NULL || p->mark <= resmark)
6597 break;
6598 resmark = p->mark;
6599 res = raw;
6600 }
6601 p->mark = resmark;
6602 return res;
6603}
6604static expr_ty
6605bitwise_or_raw(Parser *p)
6606{
6607 if (p->error_indicator) {
6608 return NULL;
6609 }
6610 expr_ty res = NULL;
6611 int mark = p->mark;
6612 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6613 p->error_indicator = 1;
6614 return NULL;
6615 }
6616 int start_lineno = p->tokens[mark]->lineno;
6617 UNUSED(start_lineno); // Only used by EXTRA macro
6618 int start_col_offset = p->tokens[mark]->col_offset;
6619 UNUSED(start_col_offset); // Only used by EXTRA macro
6620 { // bitwise_or '|' bitwise_xor
6621 expr_ty a;
6622 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006623 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006624 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006625 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006626 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006627 (literal = _PyPegen_expect_token(p, 18)) // token='|'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006628 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006629 (b = bitwise_xor_rule(p)) // bitwise_xor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006630 )
6631 {
6632 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6633 if (token == NULL) {
6634 return NULL;
6635 }
6636 int end_lineno = token->end_lineno;
6637 UNUSED(end_lineno); // Only used by EXTRA macro
6638 int end_col_offset = token->end_col_offset;
6639 UNUSED(end_col_offset); // Only used by EXTRA macro
6640 res = _Py_BinOp ( a , BitOr , b , EXTRA );
6641 if (res == NULL && PyErr_Occurred()) {
6642 p->error_indicator = 1;
6643 return NULL;
6644 }
6645 goto done;
6646 }
6647 p->mark = mark;
6648 }
6649 { // bitwise_xor
6650 expr_ty bitwise_xor_var;
6651 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006652 (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006653 )
6654 {
6655 res = bitwise_xor_var;
6656 goto done;
6657 }
6658 p->mark = mark;
6659 }
6660 res = NULL;
6661 done:
6662 return res;
6663}
6664
6665// Left-recursive
6666// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and
6667static expr_ty bitwise_xor_raw(Parser *);
6668static expr_ty
6669bitwise_xor_rule(Parser *p)
6670{
6671 expr_ty res = NULL;
6672 if (_PyPegen_is_memoized(p, bitwise_xor_type, &res))
6673 return res;
6674 int mark = p->mark;
6675 int resmark = p->mark;
6676 while (1) {
6677 int tmpvar_2 = _PyPegen_update_memo(p, mark, bitwise_xor_type, res);
6678 if (tmpvar_2) {
6679 return res;
6680 }
6681 p->mark = mark;
6682 void *raw = bitwise_xor_raw(p);
6683 if (raw == NULL || p->mark <= resmark)
6684 break;
6685 resmark = p->mark;
6686 res = raw;
6687 }
6688 p->mark = resmark;
6689 return res;
6690}
6691static expr_ty
6692bitwise_xor_raw(Parser *p)
6693{
6694 if (p->error_indicator) {
6695 return NULL;
6696 }
6697 expr_ty res = NULL;
6698 int mark = p->mark;
6699 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6700 p->error_indicator = 1;
6701 return NULL;
6702 }
6703 int start_lineno = p->tokens[mark]->lineno;
6704 UNUSED(start_lineno); // Only used by EXTRA macro
6705 int start_col_offset = p->tokens[mark]->col_offset;
6706 UNUSED(start_col_offset); // Only used by EXTRA macro
6707 { // bitwise_xor '^' bitwise_and
6708 expr_ty a;
6709 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006710 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006711 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006712 (a = bitwise_xor_rule(p)) // bitwise_xor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006713 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006714 (literal = _PyPegen_expect_token(p, 32)) // token='^'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006715 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006716 (b = bitwise_and_rule(p)) // bitwise_and
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006717 )
6718 {
6719 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6720 if (token == NULL) {
6721 return NULL;
6722 }
6723 int end_lineno = token->end_lineno;
6724 UNUSED(end_lineno); // Only used by EXTRA macro
6725 int end_col_offset = token->end_col_offset;
6726 UNUSED(end_col_offset); // Only used by EXTRA macro
6727 res = _Py_BinOp ( a , BitXor , b , EXTRA );
6728 if (res == NULL && PyErr_Occurred()) {
6729 p->error_indicator = 1;
6730 return NULL;
6731 }
6732 goto done;
6733 }
6734 p->mark = mark;
6735 }
6736 { // bitwise_and
6737 expr_ty bitwise_and_var;
6738 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006739 (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006740 )
6741 {
6742 res = bitwise_and_var;
6743 goto done;
6744 }
6745 p->mark = mark;
6746 }
6747 res = NULL;
6748 done:
6749 return res;
6750}
6751
6752// Left-recursive
6753// bitwise_and: bitwise_and '&' shift_expr | shift_expr
6754static expr_ty bitwise_and_raw(Parser *);
6755static expr_ty
6756bitwise_and_rule(Parser *p)
6757{
6758 expr_ty res = NULL;
6759 if (_PyPegen_is_memoized(p, bitwise_and_type, &res))
6760 return res;
6761 int mark = p->mark;
6762 int resmark = p->mark;
6763 while (1) {
6764 int tmpvar_3 = _PyPegen_update_memo(p, mark, bitwise_and_type, res);
6765 if (tmpvar_3) {
6766 return res;
6767 }
6768 p->mark = mark;
6769 void *raw = bitwise_and_raw(p);
6770 if (raw == NULL || p->mark <= resmark)
6771 break;
6772 resmark = p->mark;
6773 res = raw;
6774 }
6775 p->mark = resmark;
6776 return res;
6777}
6778static expr_ty
6779bitwise_and_raw(Parser *p)
6780{
6781 if (p->error_indicator) {
6782 return NULL;
6783 }
6784 expr_ty res = NULL;
6785 int mark = p->mark;
6786 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6787 p->error_indicator = 1;
6788 return NULL;
6789 }
6790 int start_lineno = p->tokens[mark]->lineno;
6791 UNUSED(start_lineno); // Only used by EXTRA macro
6792 int start_col_offset = p->tokens[mark]->col_offset;
6793 UNUSED(start_col_offset); // Only used by EXTRA macro
6794 { // bitwise_and '&' shift_expr
6795 expr_ty a;
6796 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006797 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006798 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006799 (a = bitwise_and_rule(p)) // bitwise_and
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006800 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006801 (literal = _PyPegen_expect_token(p, 19)) // token='&'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006802 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006803 (b = shift_expr_rule(p)) // shift_expr
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006804 )
6805 {
6806 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6807 if (token == NULL) {
6808 return NULL;
6809 }
6810 int end_lineno = token->end_lineno;
6811 UNUSED(end_lineno); // Only used by EXTRA macro
6812 int end_col_offset = token->end_col_offset;
6813 UNUSED(end_col_offset); // Only used by EXTRA macro
6814 res = _Py_BinOp ( a , BitAnd , b , EXTRA );
6815 if (res == NULL && PyErr_Occurred()) {
6816 p->error_indicator = 1;
6817 return NULL;
6818 }
6819 goto done;
6820 }
6821 p->mark = mark;
6822 }
6823 { // shift_expr
6824 expr_ty shift_expr_var;
6825 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006826 (shift_expr_var = shift_expr_rule(p)) // shift_expr
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006827 )
6828 {
6829 res = shift_expr_var;
6830 goto done;
6831 }
6832 p->mark = mark;
6833 }
6834 res = NULL;
6835 done:
6836 return res;
6837}
6838
6839// Left-recursive
6840// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum
6841static expr_ty shift_expr_raw(Parser *);
6842static expr_ty
6843shift_expr_rule(Parser *p)
6844{
6845 expr_ty res = NULL;
6846 if (_PyPegen_is_memoized(p, shift_expr_type, &res))
6847 return res;
6848 int mark = p->mark;
6849 int resmark = p->mark;
6850 while (1) {
6851 int tmpvar_4 = _PyPegen_update_memo(p, mark, shift_expr_type, res);
6852 if (tmpvar_4) {
6853 return res;
6854 }
6855 p->mark = mark;
6856 void *raw = shift_expr_raw(p);
6857 if (raw == NULL || p->mark <= resmark)
6858 break;
6859 resmark = p->mark;
6860 res = raw;
6861 }
6862 p->mark = resmark;
6863 return res;
6864}
6865static expr_ty
6866shift_expr_raw(Parser *p)
6867{
6868 if (p->error_indicator) {
6869 return NULL;
6870 }
6871 expr_ty res = NULL;
6872 int mark = p->mark;
6873 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6874 p->error_indicator = 1;
6875 return NULL;
6876 }
6877 int start_lineno = p->tokens[mark]->lineno;
6878 UNUSED(start_lineno); // Only used by EXTRA macro
6879 int start_col_offset = p->tokens[mark]->col_offset;
6880 UNUSED(start_col_offset); // Only used by EXTRA macro
6881 { // shift_expr '<<' sum
6882 expr_ty a;
6883 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006884 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006885 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006886 (a = shift_expr_rule(p)) // shift_expr
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006887 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006888 (literal = _PyPegen_expect_token(p, 33)) // token='<<'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006889 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006890 (b = sum_rule(p)) // sum
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006891 )
6892 {
6893 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6894 if (token == NULL) {
6895 return NULL;
6896 }
6897 int end_lineno = token->end_lineno;
6898 UNUSED(end_lineno); // Only used by EXTRA macro
6899 int end_col_offset = token->end_col_offset;
6900 UNUSED(end_col_offset); // Only used by EXTRA macro
6901 res = _Py_BinOp ( a , LShift , b , EXTRA );
6902 if (res == NULL && PyErr_Occurred()) {
6903 p->error_indicator = 1;
6904 return NULL;
6905 }
6906 goto done;
6907 }
6908 p->mark = mark;
6909 }
6910 { // shift_expr '>>' sum
6911 expr_ty a;
6912 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01006913 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006914 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006915 (a = shift_expr_rule(p)) // shift_expr
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006916 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006917 (literal = _PyPegen_expect_token(p, 34)) // token='>>'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006918 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01006919 (b = sum_rule(p)) // sum
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006920 )
6921 {
6922 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
6923 if (token == NULL) {
6924 return NULL;
6925 }
6926 int end_lineno = token->end_lineno;
6927 UNUSED(end_lineno); // Only used by EXTRA macro
6928 int end_col_offset = token->end_col_offset;
6929 UNUSED(end_col_offset); // Only used by EXTRA macro
6930 res = _Py_BinOp ( a , RShift , b , EXTRA );
6931 if (res == NULL && PyErr_Occurred()) {
6932 p->error_indicator = 1;
6933 return NULL;
6934 }
6935 goto done;
6936 }
6937 p->mark = mark;
6938 }
6939 { // sum
6940 expr_ty sum_var;
6941 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01006942 (sum_var = sum_rule(p)) // sum
Pablo Galindoc5fc1562020-04-22 23:29:27 +01006943 )
6944 {
6945 res = sum_var;
6946 goto done;
6947 }
6948 p->mark = mark;
6949 }
6950 res = NULL;
6951 done:
6952 return res;
6953}
6954
6955// Left-recursive
6956// sum: sum '+' term | sum '-' term | term
6957static expr_ty sum_raw(Parser *);
6958static expr_ty
6959sum_rule(Parser *p)
6960{
6961 expr_ty res = NULL;
6962 if (_PyPegen_is_memoized(p, sum_type, &res))
6963 return res;
6964 int mark = p->mark;
6965 int resmark = p->mark;
6966 while (1) {
6967 int tmpvar_5 = _PyPegen_update_memo(p, mark, sum_type, res);
6968 if (tmpvar_5) {
6969 return res;
6970 }
6971 p->mark = mark;
6972 void *raw = sum_raw(p);
6973 if (raw == NULL || p->mark <= resmark)
6974 break;
6975 resmark = p->mark;
6976 res = raw;
6977 }
6978 p->mark = resmark;
6979 return res;
6980}
6981static expr_ty
6982sum_raw(Parser *p)
6983{
6984 if (p->error_indicator) {
6985 return NULL;
6986 }
6987 expr_ty res = NULL;
6988 int mark = p->mark;
6989 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
6990 p->error_indicator = 1;
6991 return NULL;
6992 }
6993 int start_lineno = p->tokens[mark]->lineno;
6994 UNUSED(start_lineno); // Only used by EXTRA macro
6995 int start_col_offset = p->tokens[mark]->col_offset;
6996 UNUSED(start_col_offset); // Only used by EXTRA macro
6997 { // sum '+' term
6998 expr_ty a;
6999 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007000 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007001 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007002 (a = sum_rule(p)) // sum
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007003 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007004 (literal = _PyPegen_expect_token(p, 14)) // token='+'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007005 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007006 (b = term_rule(p)) // term
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007007 )
7008 {
7009 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7010 if (token == NULL) {
7011 return NULL;
7012 }
7013 int end_lineno = token->end_lineno;
7014 UNUSED(end_lineno); // Only used by EXTRA macro
7015 int end_col_offset = token->end_col_offset;
7016 UNUSED(end_col_offset); // Only used by EXTRA macro
7017 res = _Py_BinOp ( a , Add , b , EXTRA );
7018 if (res == NULL && PyErr_Occurred()) {
7019 p->error_indicator = 1;
7020 return NULL;
7021 }
7022 goto done;
7023 }
7024 p->mark = mark;
7025 }
7026 { // sum '-' term
7027 expr_ty a;
7028 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007029 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007030 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007031 (a = sum_rule(p)) // sum
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007032 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007033 (literal = _PyPegen_expect_token(p, 15)) // token='-'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007034 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007035 (b = term_rule(p)) // term
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007036 )
7037 {
7038 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7039 if (token == NULL) {
7040 return NULL;
7041 }
7042 int end_lineno = token->end_lineno;
7043 UNUSED(end_lineno); // Only used by EXTRA macro
7044 int end_col_offset = token->end_col_offset;
7045 UNUSED(end_col_offset); // Only used by EXTRA macro
7046 res = _Py_BinOp ( a , Sub , b , EXTRA );
7047 if (res == NULL && PyErr_Occurred()) {
7048 p->error_indicator = 1;
7049 return NULL;
7050 }
7051 goto done;
7052 }
7053 p->mark = mark;
7054 }
7055 { // term
7056 expr_ty term_var;
7057 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007058 (term_var = term_rule(p)) // term
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007059 )
7060 {
7061 res = term_var;
7062 goto done;
7063 }
7064 p->mark = mark;
7065 }
7066 res = NULL;
7067 done:
7068 return res;
7069}
7070
7071// Left-recursive
7072// term:
7073// | term '*' factor
7074// | term '/' factor
7075// | term '//' factor
7076// | term '%' factor
7077// | term '@' factor
7078// | factor
7079static expr_ty term_raw(Parser *);
7080static expr_ty
7081term_rule(Parser *p)
7082{
7083 expr_ty res = NULL;
7084 if (_PyPegen_is_memoized(p, term_type, &res))
7085 return res;
7086 int mark = p->mark;
7087 int resmark = p->mark;
7088 while (1) {
7089 int tmpvar_6 = _PyPegen_update_memo(p, mark, term_type, res);
7090 if (tmpvar_6) {
7091 return res;
7092 }
7093 p->mark = mark;
7094 void *raw = term_raw(p);
7095 if (raw == NULL || p->mark <= resmark)
7096 break;
7097 resmark = p->mark;
7098 res = raw;
7099 }
7100 p->mark = resmark;
7101 return res;
7102}
7103static expr_ty
7104term_raw(Parser *p)
7105{
7106 if (p->error_indicator) {
7107 return NULL;
7108 }
7109 expr_ty res = NULL;
7110 int mark = p->mark;
7111 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7112 p->error_indicator = 1;
7113 return NULL;
7114 }
7115 int start_lineno = p->tokens[mark]->lineno;
7116 UNUSED(start_lineno); // Only used by EXTRA macro
7117 int start_col_offset = p->tokens[mark]->col_offset;
7118 UNUSED(start_col_offset); // Only used by EXTRA macro
7119 { // term '*' factor
7120 expr_ty a;
7121 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007122 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007123 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007124 (a = term_rule(p)) // term
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007125 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007126 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007127 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007128 (b = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007129 )
7130 {
7131 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7132 if (token == NULL) {
7133 return NULL;
7134 }
7135 int end_lineno = token->end_lineno;
7136 UNUSED(end_lineno); // Only used by EXTRA macro
7137 int end_col_offset = token->end_col_offset;
7138 UNUSED(end_col_offset); // Only used by EXTRA macro
7139 res = _Py_BinOp ( a , Mult , b , EXTRA );
7140 if (res == NULL && PyErr_Occurred()) {
7141 p->error_indicator = 1;
7142 return NULL;
7143 }
7144 goto done;
7145 }
7146 p->mark = mark;
7147 }
7148 { // term '/' factor
7149 expr_ty a;
7150 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007151 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007152 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007153 (a = term_rule(p)) // term
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007154 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007155 (literal = _PyPegen_expect_token(p, 17)) // token='/'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007156 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007157 (b = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007158 )
7159 {
7160 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7161 if (token == NULL) {
7162 return NULL;
7163 }
7164 int end_lineno = token->end_lineno;
7165 UNUSED(end_lineno); // Only used by EXTRA macro
7166 int end_col_offset = token->end_col_offset;
7167 UNUSED(end_col_offset); // Only used by EXTRA macro
7168 res = _Py_BinOp ( a , Div , b , EXTRA );
7169 if (res == NULL && PyErr_Occurred()) {
7170 p->error_indicator = 1;
7171 return NULL;
7172 }
7173 goto done;
7174 }
7175 p->mark = mark;
7176 }
7177 { // term '//' factor
7178 expr_ty a;
7179 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007180 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007181 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007182 (a = term_rule(p)) // term
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007183 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007184 (literal = _PyPegen_expect_token(p, 47)) // token='//'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007185 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007186 (b = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007187 )
7188 {
7189 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7190 if (token == NULL) {
7191 return NULL;
7192 }
7193 int end_lineno = token->end_lineno;
7194 UNUSED(end_lineno); // Only used by EXTRA macro
7195 int end_col_offset = token->end_col_offset;
7196 UNUSED(end_col_offset); // Only used by EXTRA macro
7197 res = _Py_BinOp ( a , FloorDiv , b , EXTRA );
7198 if (res == NULL && PyErr_Occurred()) {
7199 p->error_indicator = 1;
7200 return NULL;
7201 }
7202 goto done;
7203 }
7204 p->mark = mark;
7205 }
7206 { // term '%' factor
7207 expr_ty a;
7208 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007209 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007210 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007211 (a = term_rule(p)) // term
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007212 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007213 (literal = _PyPegen_expect_token(p, 24)) // token='%'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007214 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007215 (b = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007216 )
7217 {
7218 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7219 if (token == NULL) {
7220 return NULL;
7221 }
7222 int end_lineno = token->end_lineno;
7223 UNUSED(end_lineno); // Only used by EXTRA macro
7224 int end_col_offset = token->end_col_offset;
7225 UNUSED(end_col_offset); // Only used by EXTRA macro
7226 res = _Py_BinOp ( a , Mod , b , EXTRA );
7227 if (res == NULL && PyErr_Occurred()) {
7228 p->error_indicator = 1;
7229 return NULL;
7230 }
7231 goto done;
7232 }
7233 p->mark = mark;
7234 }
7235 { // term '@' factor
7236 expr_ty a;
7237 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007238 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007239 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007240 (a = term_rule(p)) // term
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007241 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007242 (literal = _PyPegen_expect_token(p, 49)) // token='@'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007243 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007244 (b = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007245 )
7246 {
7247 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7248 if (token == NULL) {
7249 return NULL;
7250 }
7251 int end_lineno = token->end_lineno;
7252 UNUSED(end_lineno); // Only used by EXTRA macro
7253 int end_col_offset = token->end_col_offset;
7254 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007255 res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007256 if (res == NULL && PyErr_Occurred()) {
7257 p->error_indicator = 1;
7258 return NULL;
7259 }
7260 goto done;
7261 }
7262 p->mark = mark;
7263 }
7264 { // factor
7265 expr_ty factor_var;
7266 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007267 (factor_var = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007268 )
7269 {
7270 res = factor_var;
7271 goto done;
7272 }
7273 p->mark = mark;
7274 }
7275 res = NULL;
7276 done:
7277 return res;
7278}
7279
7280// factor: '+' factor | '-' factor | '~' factor | power
7281static expr_ty
7282factor_rule(Parser *p)
7283{
7284 if (p->error_indicator) {
7285 return NULL;
7286 }
7287 expr_ty res = NULL;
7288 if (_PyPegen_is_memoized(p, factor_type, &res))
7289 return res;
7290 int mark = p->mark;
7291 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7292 p->error_indicator = 1;
7293 return NULL;
7294 }
7295 int start_lineno = p->tokens[mark]->lineno;
7296 UNUSED(start_lineno); // Only used by EXTRA macro
7297 int start_col_offset = p->tokens[mark]->col_offset;
7298 UNUSED(start_col_offset); // Only used by EXTRA macro
7299 { // '+' factor
7300 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007301 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007302 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007303 (literal = _PyPegen_expect_token(p, 14)) // token='+'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007304 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007305 (a = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007306 )
7307 {
7308 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7309 if (token == NULL) {
7310 return NULL;
7311 }
7312 int end_lineno = token->end_lineno;
7313 UNUSED(end_lineno); // Only used by EXTRA macro
7314 int end_col_offset = token->end_col_offset;
7315 UNUSED(end_col_offset); // Only used by EXTRA macro
7316 res = _Py_UnaryOp ( UAdd , a , EXTRA );
7317 if (res == NULL && PyErr_Occurred()) {
7318 p->error_indicator = 1;
7319 return NULL;
7320 }
7321 goto done;
7322 }
7323 p->mark = mark;
7324 }
7325 { // '-' factor
7326 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007327 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007328 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007329 (literal = _PyPegen_expect_token(p, 15)) // token='-'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007330 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007331 (a = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007332 )
7333 {
7334 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7335 if (token == NULL) {
7336 return NULL;
7337 }
7338 int end_lineno = token->end_lineno;
7339 UNUSED(end_lineno); // Only used by EXTRA macro
7340 int end_col_offset = token->end_col_offset;
7341 UNUSED(end_col_offset); // Only used by EXTRA macro
7342 res = _Py_UnaryOp ( USub , a , EXTRA );
7343 if (res == NULL && PyErr_Occurred()) {
7344 p->error_indicator = 1;
7345 return NULL;
7346 }
7347 goto done;
7348 }
7349 p->mark = mark;
7350 }
7351 { // '~' factor
7352 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007353 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007354 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007355 (literal = _PyPegen_expect_token(p, 31)) // token='~'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007356 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007357 (a = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007358 )
7359 {
7360 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7361 if (token == NULL) {
7362 return NULL;
7363 }
7364 int end_lineno = token->end_lineno;
7365 UNUSED(end_lineno); // Only used by EXTRA macro
7366 int end_col_offset = token->end_col_offset;
7367 UNUSED(end_col_offset); // Only used by EXTRA macro
7368 res = _Py_UnaryOp ( Invert , a , EXTRA );
7369 if (res == NULL && PyErr_Occurred()) {
7370 p->error_indicator = 1;
7371 return NULL;
7372 }
7373 goto done;
7374 }
7375 p->mark = mark;
7376 }
7377 { // power
7378 expr_ty power_var;
7379 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007380 (power_var = power_rule(p)) // power
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007381 )
7382 {
7383 res = power_var;
7384 goto done;
7385 }
7386 p->mark = mark;
7387 }
7388 res = NULL;
7389 done:
7390 _PyPegen_insert_memo(p, mark, factor_type, res);
7391 return res;
7392}
7393
7394// power: await_primary '**' factor | await_primary
7395static expr_ty
7396power_rule(Parser *p)
7397{
7398 if (p->error_indicator) {
7399 return NULL;
7400 }
7401 expr_ty res = NULL;
7402 int mark = p->mark;
7403 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7404 p->error_indicator = 1;
7405 return NULL;
7406 }
7407 int start_lineno = p->tokens[mark]->lineno;
7408 UNUSED(start_lineno); // Only used by EXTRA macro
7409 int start_col_offset = p->tokens[mark]->col_offset;
7410 UNUSED(start_col_offset); // Only used by EXTRA macro
7411 { // await_primary '**' factor
7412 expr_ty a;
7413 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007414 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007415 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007416 (a = await_primary_rule(p)) // await_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007417 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007418 (literal = _PyPegen_expect_token(p, 35)) // token='**'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007419 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007420 (b = factor_rule(p)) // factor
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007421 )
7422 {
7423 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7424 if (token == NULL) {
7425 return NULL;
7426 }
7427 int end_lineno = token->end_lineno;
7428 UNUSED(end_lineno); // Only used by EXTRA macro
7429 int end_col_offset = token->end_col_offset;
7430 UNUSED(end_col_offset); // Only used by EXTRA macro
7431 res = _Py_BinOp ( a , Pow , b , EXTRA );
7432 if (res == NULL && PyErr_Occurred()) {
7433 p->error_indicator = 1;
7434 return NULL;
7435 }
7436 goto done;
7437 }
7438 p->mark = mark;
7439 }
7440 { // await_primary
7441 expr_ty await_primary_var;
7442 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007443 (await_primary_var = await_primary_rule(p)) // await_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007444 )
7445 {
7446 res = await_primary_var;
7447 goto done;
7448 }
7449 p->mark = mark;
7450 }
7451 res = NULL;
7452 done:
7453 return res;
7454}
7455
7456// await_primary: AWAIT primary | primary
7457static expr_ty
7458await_primary_rule(Parser *p)
7459{
7460 if (p->error_indicator) {
7461 return NULL;
7462 }
7463 expr_ty res = NULL;
7464 if (_PyPegen_is_memoized(p, await_primary_type, &res))
7465 return res;
7466 int mark = p->mark;
7467 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7468 p->error_indicator = 1;
7469 return NULL;
7470 }
7471 int start_lineno = p->tokens[mark]->lineno;
7472 UNUSED(start_lineno); // Only used by EXTRA macro
7473 int start_col_offset = p->tokens[mark]->col_offset;
7474 UNUSED(start_col_offset); // Only used by EXTRA macro
7475 { // AWAIT primary
7476 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007477 Token * await_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007478 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007479 (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007480 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007481 (a = primary_rule(p)) // primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007482 )
7483 {
7484 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7485 if (token == NULL) {
7486 return NULL;
7487 }
7488 int end_lineno = token->end_lineno;
7489 UNUSED(end_lineno); // Only used by EXTRA macro
7490 int end_col_offset = token->end_col_offset;
7491 UNUSED(end_col_offset); // Only used by EXTRA macro
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03007492 res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007493 if (res == NULL && PyErr_Occurred()) {
7494 p->error_indicator = 1;
7495 return NULL;
7496 }
7497 goto done;
7498 }
7499 p->mark = mark;
7500 }
7501 { // primary
7502 expr_ty primary_var;
7503 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007504 (primary_var = primary_rule(p)) // primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007505 )
7506 {
7507 res = primary_var;
7508 goto done;
7509 }
7510 p->mark = mark;
7511 }
7512 res = NULL;
7513 done:
7514 _PyPegen_insert_memo(p, mark, await_primary_type, res);
7515 return res;
7516}
7517
7518// Left-recursive
7519// primary:
7520// | primary '.' NAME
7521// | primary genexp
7522// | primary '(' arguments? ')'
7523// | primary '[' slices ']'
7524// | atom
7525static expr_ty primary_raw(Parser *);
7526static expr_ty
7527primary_rule(Parser *p)
7528{
7529 expr_ty res = NULL;
7530 if (_PyPegen_is_memoized(p, primary_type, &res))
7531 return res;
7532 int mark = p->mark;
7533 int resmark = p->mark;
7534 while (1) {
7535 int tmpvar_7 = _PyPegen_update_memo(p, mark, primary_type, res);
7536 if (tmpvar_7) {
7537 return res;
7538 }
7539 p->mark = mark;
7540 void *raw = primary_raw(p);
7541 if (raw == NULL || p->mark <= resmark)
7542 break;
7543 resmark = p->mark;
7544 res = raw;
7545 }
7546 p->mark = resmark;
7547 return res;
7548}
7549static expr_ty
7550primary_raw(Parser *p)
7551{
7552 if (p->error_indicator) {
7553 return NULL;
7554 }
7555 expr_ty res = NULL;
7556 int mark = p->mark;
7557 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7558 p->error_indicator = 1;
7559 return NULL;
7560 }
7561 int start_lineno = p->tokens[mark]->lineno;
7562 UNUSED(start_lineno); // Only used by EXTRA macro
7563 int start_col_offset = p->tokens[mark]->col_offset;
7564 UNUSED(start_col_offset); // Only used by EXTRA macro
7565 { // primary '.' NAME
7566 expr_ty a;
7567 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007568 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007569 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007570 (a = primary_rule(p)) // primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007571 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007572 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007573 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007574 (b = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007575 )
7576 {
7577 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7578 if (token == NULL) {
7579 return NULL;
7580 }
7581 int end_lineno = token->end_lineno;
7582 UNUSED(end_lineno); // Only used by EXTRA macro
7583 int end_col_offset = token->end_col_offset;
7584 UNUSED(end_col_offset); // Only used by EXTRA macro
7585 res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
7586 if (res == NULL && PyErr_Occurred()) {
7587 p->error_indicator = 1;
7588 return NULL;
7589 }
7590 goto done;
7591 }
7592 p->mark = mark;
7593 }
7594 { // primary genexp
7595 expr_ty a;
7596 expr_ty b;
7597 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007598 (a = primary_rule(p)) // primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007599 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007600 (b = genexp_rule(p)) // genexp
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007601 )
7602 {
7603 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7604 if (token == NULL) {
7605 return NULL;
7606 }
7607 int end_lineno = token->end_lineno;
7608 UNUSED(end_lineno); // Only used by EXTRA macro
7609 int end_col_offset = token->end_col_offset;
7610 UNUSED(end_col_offset); // Only used by EXTRA macro
7611 res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
7612 if (res == NULL && PyErr_Occurred()) {
7613 p->error_indicator = 1;
7614 return NULL;
7615 }
7616 goto done;
7617 }
7618 p->mark = mark;
7619 }
7620 { // primary '(' arguments? ')'
7621 expr_ty a;
7622 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007623 Token * literal;
7624 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007625 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007626 (a = primary_rule(p)) // primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007627 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007628 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007629 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007630 (b = arguments_rule(p), 1) // arguments?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007631 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007632 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007633 )
7634 {
7635 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7636 if (token == NULL) {
7637 return NULL;
7638 }
7639 int end_lineno = token->end_lineno;
7640 UNUSED(end_lineno); // Only used by EXTRA macro
7641 int end_col_offset = token->end_col_offset;
7642 UNUSED(end_col_offset); // Only used by EXTRA macro
7643 res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
7644 if (res == NULL && PyErr_Occurred()) {
7645 p->error_indicator = 1;
7646 return NULL;
7647 }
7648 goto done;
7649 }
7650 p->mark = mark;
7651 }
7652 { // primary '[' slices ']'
7653 expr_ty a;
7654 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007655 Token * literal;
7656 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007657 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007658 (a = primary_rule(p)) // primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007659 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007660 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007661 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007662 (b = slices_rule(p)) // slices
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007663 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007664 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007665 )
7666 {
7667 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7668 if (token == NULL) {
7669 return NULL;
7670 }
7671 int end_lineno = token->end_lineno;
7672 UNUSED(end_lineno); // Only used by EXTRA macro
7673 int end_col_offset = token->end_col_offset;
7674 UNUSED(end_col_offset); // Only used by EXTRA macro
7675 res = _Py_Subscript ( a , b , Load , EXTRA );
7676 if (res == NULL && PyErr_Occurred()) {
7677 p->error_indicator = 1;
7678 return NULL;
7679 }
7680 goto done;
7681 }
7682 p->mark = mark;
7683 }
7684 { // atom
7685 expr_ty atom_var;
7686 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007687 (atom_var = atom_rule(p)) // atom
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007688 )
7689 {
7690 res = atom_var;
7691 goto done;
7692 }
7693 p->mark = mark;
7694 }
7695 res = NULL;
7696 done:
7697 return res;
7698}
7699
7700// slices: slice !',' | ','.slice+ ','?
7701static expr_ty
7702slices_rule(Parser *p)
7703{
7704 if (p->error_indicator) {
7705 return NULL;
7706 }
7707 expr_ty res = NULL;
7708 int mark = p->mark;
7709 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7710 p->error_indicator = 1;
7711 return NULL;
7712 }
7713 int start_lineno = p->tokens[mark]->lineno;
7714 UNUSED(start_lineno); // Only used by EXTRA macro
7715 int start_col_offset = p->tokens[mark]->col_offset;
7716 UNUSED(start_col_offset); // Only used by EXTRA macro
7717 { // slice !','
7718 expr_ty a;
7719 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007720 (a = slice_rule(p)) // slice
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007721 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007722 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007723 )
7724 {
7725 res = a;
7726 if (res == NULL && PyErr_Occurred()) {
7727 p->error_indicator = 1;
7728 return NULL;
7729 }
7730 goto done;
7731 }
7732 p->mark = mark;
7733 }
7734 { // ','.slice+ ','?
7735 asdl_seq * a;
7736 void *opt_var;
7737 UNUSED(opt_var); // Silence compiler warnings
7738 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007739 (a = _gather_93_rule(p)) // ','.slice+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007740 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007741 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007742 )
7743 {
7744 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7745 if (token == NULL) {
7746 return NULL;
7747 }
7748 int end_lineno = token->end_lineno;
7749 UNUSED(end_lineno); // Only used by EXTRA macro
7750 int end_col_offset = token->end_col_offset;
7751 UNUSED(end_col_offset); // Only used by EXTRA macro
7752 res = _Py_Tuple ( a , Load , EXTRA );
7753 if (res == NULL && PyErr_Occurred()) {
7754 p->error_indicator = 1;
7755 return NULL;
7756 }
7757 goto done;
7758 }
7759 p->mark = mark;
7760 }
7761 res = NULL;
7762 done:
7763 return res;
7764}
7765
7766// slice: expression? ':' expression? [':' expression?] | expression
7767static expr_ty
7768slice_rule(Parser *p)
7769{
7770 if (p->error_indicator) {
7771 return NULL;
7772 }
7773 expr_ty res = NULL;
7774 int mark = p->mark;
7775 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7776 p->error_indicator = 1;
7777 return NULL;
7778 }
7779 int start_lineno = p->tokens[mark]->lineno;
7780 UNUSED(start_lineno); // Only used by EXTRA macro
7781 int start_col_offset = p->tokens[mark]->col_offset;
7782 UNUSED(start_col_offset); // Only used by EXTRA macro
7783 { // expression? ':' expression? [':' expression?]
7784 void *a;
7785 void *b;
7786 void *c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01007787 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007788 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007789 (a = expression_rule(p), 1) // expression?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007790 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007791 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007792 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007793 (b = expression_rule(p), 1) // expression?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007794 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007795 (c = _tmp_95_rule(p), 1) // [':' expression?]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007796 )
7797 {
7798 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7799 if (token == NULL) {
7800 return NULL;
7801 }
7802 int end_lineno = token->end_lineno;
7803 UNUSED(end_lineno); // Only used by EXTRA macro
7804 int end_col_offset = token->end_col_offset;
7805 UNUSED(end_col_offset); // Only used by EXTRA macro
7806 res = _Py_Slice ( a , b , c , EXTRA );
7807 if (res == NULL && PyErr_Occurred()) {
7808 p->error_indicator = 1;
7809 return NULL;
7810 }
7811 goto done;
7812 }
7813 p->mark = mark;
7814 }
7815 { // expression
7816 expr_ty a;
7817 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007818 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007819 )
7820 {
7821 res = a;
7822 if (res == NULL && PyErr_Occurred()) {
7823 p->error_indicator = 1;
7824 return NULL;
7825 }
7826 goto done;
7827 }
7828 p->mark = mark;
7829 }
7830 res = NULL;
7831 done:
7832 return res;
7833}
7834
7835// atom:
7836// | NAME
7837// | 'True'
7838// | 'False'
7839// | 'None'
7840// | '__new_parser__'
7841// | &STRING strings
7842// | NUMBER
7843// | &'(' (tuple | group | genexp)
7844// | &'[' (list | listcomp)
7845// | &'{' (dict | set | dictcomp | setcomp)
7846// | '...'
7847static expr_ty
7848atom_rule(Parser *p)
7849{
7850 if (p->error_indicator) {
7851 return NULL;
7852 }
7853 expr_ty res = NULL;
7854 int mark = p->mark;
7855 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
7856 p->error_indicator = 1;
7857 return NULL;
7858 }
7859 int start_lineno = p->tokens[mark]->lineno;
7860 UNUSED(start_lineno); // Only used by EXTRA macro
7861 int start_col_offset = p->tokens[mark]->col_offset;
7862 UNUSED(start_col_offset); // Only used by EXTRA macro
7863 { // NAME
7864 expr_ty name_var;
7865 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007866 (name_var = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007867 )
7868 {
7869 res = name_var;
7870 goto done;
7871 }
7872 p->mark = mark;
7873 }
7874 { // 'True'
Pablo Galindob796b3f2020-05-01 12:32:26 +01007875 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007876 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007877 (keyword = _PyPegen_expect_token(p, 527)) // token='True'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007878 )
7879 {
7880 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7881 if (token == NULL) {
7882 return NULL;
7883 }
7884 int end_lineno = token->end_lineno;
7885 UNUSED(end_lineno); // Only used by EXTRA macro
7886 int end_col_offset = token->end_col_offset;
7887 UNUSED(end_col_offset); // Only used by EXTRA macro
7888 res = _Py_Constant ( Py_True , NULL , EXTRA );
7889 if (res == NULL && PyErr_Occurred()) {
7890 p->error_indicator = 1;
7891 return NULL;
7892 }
7893 goto done;
7894 }
7895 p->mark = mark;
7896 }
7897 { // 'False'
Pablo Galindob796b3f2020-05-01 12:32:26 +01007898 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007899 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007900 (keyword = _PyPegen_expect_token(p, 528)) // token='False'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007901 )
7902 {
7903 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7904 if (token == NULL) {
7905 return NULL;
7906 }
7907 int end_lineno = token->end_lineno;
7908 UNUSED(end_lineno); // Only used by EXTRA macro
7909 int end_col_offset = token->end_col_offset;
7910 UNUSED(end_col_offset); // Only used by EXTRA macro
7911 res = _Py_Constant ( Py_False , NULL , EXTRA );
7912 if (res == NULL && PyErr_Occurred()) {
7913 p->error_indicator = 1;
7914 return NULL;
7915 }
7916 goto done;
7917 }
7918 p->mark = mark;
7919 }
7920 { // 'None'
Pablo Galindob796b3f2020-05-01 12:32:26 +01007921 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007922 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007923 (keyword = _PyPegen_expect_token(p, 529)) // token='None'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007924 )
7925 {
7926 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
7927 if (token == NULL) {
7928 return NULL;
7929 }
7930 int end_lineno = token->end_lineno;
7931 UNUSED(end_lineno); // Only used by EXTRA macro
7932 int end_col_offset = token->end_col_offset;
7933 UNUSED(end_col_offset); // Only used by EXTRA macro
7934 res = _Py_Constant ( Py_None , NULL , EXTRA );
7935 if (res == NULL && PyErr_Occurred()) {
7936 p->error_indicator = 1;
7937 return NULL;
7938 }
7939 goto done;
7940 }
7941 p->mark = mark;
7942 }
7943 { // '__new_parser__'
Pablo Galindob796b3f2020-05-01 12:32:26 +01007944 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007945 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007946 (keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007947 )
7948 {
7949 res = RAISE_SYNTAX_ERROR ( "You found it!" );
7950 if (res == NULL && PyErr_Occurred()) {
7951 p->error_indicator = 1;
7952 return NULL;
7953 }
7954 goto done;
7955 }
7956 p->mark = mark;
7957 }
7958 { // &STRING strings
7959 expr_ty strings_var;
7960 if (
7961 _PyPegen_lookahead(1, _PyPegen_string_token, p)
7962 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007963 (strings_var = strings_rule(p)) // strings
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007964 )
7965 {
7966 res = strings_var;
7967 goto done;
7968 }
7969 p->mark = mark;
7970 }
7971 { // NUMBER
7972 expr_ty number_var;
7973 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007974 (number_var = _PyPegen_number_token(p)) // NUMBER
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007975 )
7976 {
7977 res = number_var;
7978 goto done;
7979 }
7980 p->mark = mark;
7981 }
7982 { // &'(' (tuple | group | genexp)
Guido van Rossum3941d972020-05-01 09:42:03 -07007983 void *_tmp_96_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007984 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007985 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007986 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01007987 (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007988 )
7989 {
Guido van Rossum3941d972020-05-01 09:42:03 -07007990 res = _tmp_96_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007991 goto done;
7992 }
7993 p->mark = mark;
7994 }
Pablo Galindo2b74c832020-04-27 18:02:07 +01007995 { // &'[' (list | listcomp)
Guido van Rossum3941d972020-05-01 09:42:03 -07007996 void *_tmp_97_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007997 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01007998 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01007999 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008000 (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008001 )
8002 {
Guido van Rossum3941d972020-05-01 09:42:03 -07008003 res = _tmp_97_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008004 goto done;
8005 }
8006 p->mark = mark;
8007 }
Pablo Galindo2b74c832020-04-27 18:02:07 +01008008 { // &'{' (dict | set | dictcomp | setcomp)
Guido van Rossum3941d972020-05-01 09:42:03 -07008009 void *_tmp_98_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +01008010 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008011 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{'
Pablo Galindo2b74c832020-04-27 18:02:07 +01008012 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008013 (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp
Pablo Galindo2b74c832020-04-27 18:02:07 +01008014 )
8015 {
Guido van Rossum3941d972020-05-01 09:42:03 -07008016 res = _tmp_98_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +01008017 goto done;
8018 }
8019 p->mark = mark;
8020 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008021 { // '...'
Pablo Galindob796b3f2020-05-01 12:32:26 +01008022 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008023 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008024 (literal = _PyPegen_expect_token(p, 52)) // token='...'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008025 )
8026 {
8027 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8028 if (token == NULL) {
8029 return NULL;
8030 }
8031 int end_lineno = token->end_lineno;
8032 UNUSED(end_lineno); // Only used by EXTRA macro
8033 int end_col_offset = token->end_col_offset;
8034 UNUSED(end_col_offset); // Only used by EXTRA macro
8035 res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA );
8036 if (res == NULL && PyErr_Occurred()) {
8037 p->error_indicator = 1;
8038 return NULL;
8039 }
8040 goto done;
8041 }
8042 p->mark = mark;
8043 }
8044 res = NULL;
8045 done:
8046 return res;
8047}
8048
8049// strings: STRING+
8050static expr_ty
8051strings_rule(Parser *p)
8052{
8053 if (p->error_indicator) {
8054 return NULL;
8055 }
8056 expr_ty res = NULL;
8057 if (_PyPegen_is_memoized(p, strings_type, &res))
8058 return res;
8059 int mark = p->mark;
8060 { // STRING+
8061 asdl_seq * a;
8062 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008063 (a = _loop1_99_rule(p)) // STRING+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008064 )
8065 {
8066 res = _PyPegen_concatenate_strings ( p , a );
8067 if (res == NULL && PyErr_Occurred()) {
8068 p->error_indicator = 1;
8069 return NULL;
8070 }
8071 goto done;
8072 }
8073 p->mark = mark;
8074 }
8075 res = NULL;
8076 done:
8077 _PyPegen_insert_memo(p, mark, strings_type, res);
8078 return res;
8079}
8080
8081// list: '[' star_named_expressions? ']'
8082static expr_ty
8083list_rule(Parser *p)
8084{
8085 if (p->error_indicator) {
8086 return NULL;
8087 }
8088 expr_ty res = NULL;
8089 int mark = p->mark;
8090 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8091 p->error_indicator = 1;
8092 return NULL;
8093 }
8094 int start_lineno = p->tokens[mark]->lineno;
8095 UNUSED(start_lineno); // Only used by EXTRA macro
8096 int start_col_offset = p->tokens[mark]->col_offset;
8097 UNUSED(start_col_offset); // Only used by EXTRA macro
8098 { // '[' star_named_expressions? ']'
8099 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008100 Token * literal;
8101 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008102 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008103 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008104 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008105 (a = star_named_expressions_rule(p), 1) // star_named_expressions?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008106 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008107 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008108 )
8109 {
8110 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8111 if (token == NULL) {
8112 return NULL;
8113 }
8114 int end_lineno = token->end_lineno;
8115 UNUSED(end_lineno); // Only used by EXTRA macro
8116 int end_col_offset = token->end_col_offset;
8117 UNUSED(end_col_offset); // Only used by EXTRA macro
8118 res = _Py_List ( a , Load , EXTRA );
8119 if (res == NULL && PyErr_Occurred()) {
8120 p->error_indicator = 1;
8121 return NULL;
8122 }
8123 goto done;
8124 }
8125 p->mark = mark;
8126 }
8127 res = NULL;
8128 done:
8129 return res;
8130}
8131
8132// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension
8133static expr_ty
8134listcomp_rule(Parser *p)
8135{
8136 if (p->error_indicator) {
8137 return NULL;
8138 }
8139 expr_ty res = NULL;
8140 int mark = p->mark;
8141 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8142 p->error_indicator = 1;
8143 return NULL;
8144 }
8145 int start_lineno = p->tokens[mark]->lineno;
8146 UNUSED(start_lineno); // Only used by EXTRA macro
8147 int start_col_offset = p->tokens[mark]->col_offset;
8148 UNUSED(start_col_offset); // Only used by EXTRA macro
8149 { // '[' named_expression for_if_clauses ']'
8150 expr_ty a;
8151 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008152 Token * literal;
8153 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008154 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008155 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008156 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008157 (a = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008158 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008159 (b = for_if_clauses_rule(p)) // for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008160 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008161 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008162 )
8163 {
8164 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8165 if (token == NULL) {
8166 return NULL;
8167 }
8168 int end_lineno = token->end_lineno;
8169 UNUSED(end_lineno); // Only used by EXTRA macro
8170 int end_col_offset = token->end_col_offset;
8171 UNUSED(end_col_offset); // Only used by EXTRA macro
8172 res = _Py_ListComp ( a , b , EXTRA );
8173 if (res == NULL && PyErr_Occurred()) {
8174 p->error_indicator = 1;
8175 return NULL;
8176 }
8177 goto done;
8178 }
8179 p->mark = mark;
8180 }
8181 { // invalid_comprehension
8182 void *invalid_comprehension_var;
8183 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008184 (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008185 )
8186 {
8187 res = invalid_comprehension_var;
8188 goto done;
8189 }
8190 p->mark = mark;
8191 }
8192 res = NULL;
8193 done:
8194 return res;
8195}
8196
8197// tuple: '(' [star_named_expression ',' star_named_expressions?] ')'
8198static expr_ty
8199tuple_rule(Parser *p)
8200{
8201 if (p->error_indicator) {
8202 return NULL;
8203 }
8204 expr_ty res = NULL;
8205 int mark = p->mark;
8206 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8207 p->error_indicator = 1;
8208 return NULL;
8209 }
8210 int start_lineno = p->tokens[mark]->lineno;
8211 UNUSED(start_lineno); // Only used by EXTRA macro
8212 int start_col_offset = p->tokens[mark]->col_offset;
8213 UNUSED(start_col_offset); // Only used by EXTRA macro
8214 { // '(' [star_named_expression ',' star_named_expressions?] ')'
8215 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008216 Token * literal;
8217 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008218 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008219 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008220 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008221 (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008222 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008223 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008224 )
8225 {
8226 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8227 if (token == NULL) {
8228 return NULL;
8229 }
8230 int end_lineno = token->end_lineno;
8231 UNUSED(end_lineno); // Only used by EXTRA macro
8232 int end_col_offset = token->end_col_offset;
8233 UNUSED(end_col_offset); // Only used by EXTRA macro
8234 res = _Py_Tuple ( a , Load , EXTRA );
8235 if (res == NULL && PyErr_Occurred()) {
8236 p->error_indicator = 1;
8237 return NULL;
8238 }
8239 goto done;
8240 }
8241 p->mark = mark;
8242 }
8243 res = NULL;
8244 done:
8245 return res;
8246}
8247
8248// group: '(' (yield_expr | named_expression) ')'
8249static expr_ty
8250group_rule(Parser *p)
8251{
8252 if (p->error_indicator) {
8253 return NULL;
8254 }
8255 expr_ty res = NULL;
8256 int mark = p->mark;
8257 { // '(' (yield_expr | named_expression) ')'
8258 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008259 Token * literal;
8260 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008261 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008262 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008263 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008264 (a = _tmp_101_rule(p)) // yield_expr | named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008265 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008266 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008267 )
8268 {
8269 res = a;
8270 if (res == NULL && PyErr_Occurred()) {
8271 p->error_indicator = 1;
8272 return NULL;
8273 }
8274 goto done;
8275 }
8276 p->mark = mark;
8277 }
8278 res = NULL;
8279 done:
8280 return res;
8281}
8282
8283// genexp: '(' expression for_if_clauses ')' | invalid_comprehension
8284static expr_ty
8285genexp_rule(Parser *p)
8286{
8287 if (p->error_indicator) {
8288 return NULL;
8289 }
8290 expr_ty res = NULL;
8291 int mark = p->mark;
8292 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8293 p->error_indicator = 1;
8294 return NULL;
8295 }
8296 int start_lineno = p->tokens[mark]->lineno;
8297 UNUSED(start_lineno); // Only used by EXTRA macro
8298 int start_col_offset = p->tokens[mark]->col_offset;
8299 UNUSED(start_col_offset); // Only used by EXTRA macro
8300 { // '(' expression for_if_clauses ')'
8301 expr_ty a;
8302 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008303 Token * literal;
8304 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008305 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008306 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008307 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008308 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008309 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008310 (b = for_if_clauses_rule(p)) // for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008311 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008312 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008313 )
8314 {
8315 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8316 if (token == NULL) {
8317 return NULL;
8318 }
8319 int end_lineno = token->end_lineno;
8320 UNUSED(end_lineno); // Only used by EXTRA macro
8321 int end_col_offset = token->end_col_offset;
8322 UNUSED(end_col_offset); // Only used by EXTRA macro
8323 res = _Py_GeneratorExp ( a , b , EXTRA );
8324 if (res == NULL && PyErr_Occurred()) {
8325 p->error_indicator = 1;
8326 return NULL;
8327 }
8328 goto done;
8329 }
8330 p->mark = mark;
8331 }
8332 { // invalid_comprehension
8333 void *invalid_comprehension_var;
8334 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008335 (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008336 )
8337 {
8338 res = invalid_comprehension_var;
8339 goto done;
8340 }
8341 p->mark = mark;
8342 }
8343 res = NULL;
8344 done:
8345 return res;
8346}
8347
8348// set: '{' expressions_list '}'
8349static expr_ty
8350set_rule(Parser *p)
8351{
8352 if (p->error_indicator) {
8353 return NULL;
8354 }
8355 expr_ty res = NULL;
8356 int mark = p->mark;
8357 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8358 p->error_indicator = 1;
8359 return NULL;
8360 }
8361 int start_lineno = p->tokens[mark]->lineno;
8362 UNUSED(start_lineno); // Only used by EXTRA macro
8363 int start_col_offset = p->tokens[mark]->col_offset;
8364 UNUSED(start_col_offset); // Only used by EXTRA macro
8365 { // '{' expressions_list '}'
8366 asdl_seq* a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008367 Token * literal;
8368 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008369 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008370 (literal = _PyPegen_expect_token(p, 25)) // token='{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008371 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008372 (a = expressions_list_rule(p)) // expressions_list
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008373 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008374 (literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008375 )
8376 {
8377 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8378 if (token == NULL) {
8379 return NULL;
8380 }
8381 int end_lineno = token->end_lineno;
8382 UNUSED(end_lineno); // Only used by EXTRA macro
8383 int end_col_offset = token->end_col_offset;
8384 UNUSED(end_col_offset); // Only used by EXTRA macro
8385 res = _Py_Set ( a , EXTRA );
8386 if (res == NULL && PyErr_Occurred()) {
8387 p->error_indicator = 1;
8388 return NULL;
8389 }
8390 goto done;
8391 }
8392 p->mark = mark;
8393 }
8394 res = NULL;
8395 done:
8396 return res;
8397}
8398
8399// setcomp: '{' expression for_if_clauses '}' | invalid_comprehension
8400static expr_ty
8401setcomp_rule(Parser *p)
8402{
8403 if (p->error_indicator) {
8404 return NULL;
8405 }
8406 expr_ty res = NULL;
8407 int mark = p->mark;
8408 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8409 p->error_indicator = 1;
8410 return NULL;
8411 }
8412 int start_lineno = p->tokens[mark]->lineno;
8413 UNUSED(start_lineno); // Only used by EXTRA macro
8414 int start_col_offset = p->tokens[mark]->col_offset;
8415 UNUSED(start_col_offset); // Only used by EXTRA macro
8416 { // '{' expression for_if_clauses '}'
8417 expr_ty a;
8418 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008419 Token * literal;
8420 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008421 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008422 (literal = _PyPegen_expect_token(p, 25)) // token='{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008423 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008424 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008425 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008426 (b = for_if_clauses_rule(p)) // for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008427 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008428 (literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008429 )
8430 {
8431 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8432 if (token == NULL) {
8433 return NULL;
8434 }
8435 int end_lineno = token->end_lineno;
8436 UNUSED(end_lineno); // Only used by EXTRA macro
8437 int end_col_offset = token->end_col_offset;
8438 UNUSED(end_col_offset); // Only used by EXTRA macro
8439 res = _Py_SetComp ( a , b , EXTRA );
8440 if (res == NULL && PyErr_Occurred()) {
8441 p->error_indicator = 1;
8442 return NULL;
8443 }
8444 goto done;
8445 }
8446 p->mark = mark;
8447 }
8448 { // invalid_comprehension
8449 void *invalid_comprehension_var;
8450 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008451 (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008452 )
8453 {
8454 res = invalid_comprehension_var;
8455 goto done;
8456 }
8457 p->mark = mark;
8458 }
8459 res = NULL;
8460 done:
8461 return res;
8462}
8463
8464// dict: '{' kvpairs? '}'
8465static expr_ty
8466dict_rule(Parser *p)
8467{
8468 if (p->error_indicator) {
8469 return NULL;
8470 }
8471 expr_ty res = NULL;
8472 int mark = p->mark;
8473 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8474 p->error_indicator = 1;
8475 return NULL;
8476 }
8477 int start_lineno = p->tokens[mark]->lineno;
8478 UNUSED(start_lineno); // Only used by EXTRA macro
8479 int start_col_offset = p->tokens[mark]->col_offset;
8480 UNUSED(start_col_offset); // Only used by EXTRA macro
8481 { // '{' kvpairs? '}'
8482 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008483 Token * literal;
8484 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008485 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008486 (literal = _PyPegen_expect_token(p, 25)) // token='{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008487 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008488 (a = kvpairs_rule(p), 1) // kvpairs?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008489 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008490 (literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008491 )
8492 {
8493 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8494 if (token == NULL) {
8495 return NULL;
8496 }
8497 int end_lineno = token->end_lineno;
8498 UNUSED(end_lineno); // Only used by EXTRA macro
8499 int end_col_offset = token->end_col_offset;
8500 UNUSED(end_col_offset); // Only used by EXTRA macro
8501 res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA );
8502 if (res == NULL && PyErr_Occurred()) {
8503 p->error_indicator = 1;
8504 return NULL;
8505 }
8506 goto done;
8507 }
8508 p->mark = mark;
8509 }
8510 res = NULL;
8511 done:
8512 return res;
8513}
8514
8515// dictcomp: '{' kvpair for_if_clauses '}'
8516static expr_ty
8517dictcomp_rule(Parser *p)
8518{
8519 if (p->error_indicator) {
8520 return NULL;
8521 }
8522 expr_ty res = NULL;
8523 int mark = p->mark;
8524 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8525 p->error_indicator = 1;
8526 return NULL;
8527 }
8528 int start_lineno = p->tokens[mark]->lineno;
8529 UNUSED(start_lineno); // Only used by EXTRA macro
8530 int start_col_offset = p->tokens[mark]->col_offset;
8531 UNUSED(start_col_offset); // Only used by EXTRA macro
8532 { // '{' kvpair for_if_clauses '}'
8533 KeyValuePair* a;
8534 asdl_seq* b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008535 Token * literal;
8536 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008537 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008538 (literal = _PyPegen_expect_token(p, 25)) // token='{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008539 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008540 (a = kvpair_rule(p)) // kvpair
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008541 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008542 (b = for_if_clauses_rule(p)) // for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008543 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008544 (literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008545 )
8546 {
8547 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8548 if (token == NULL) {
8549 return NULL;
8550 }
8551 int end_lineno = token->end_lineno;
8552 UNUSED(end_lineno); // Only used by EXTRA macro
8553 int end_col_offset = token->end_col_offset;
8554 UNUSED(end_col_offset); // Only used by EXTRA macro
8555 res = _Py_DictComp ( a -> key , a -> value , b , EXTRA );
8556 if (res == NULL && PyErr_Occurred()) {
8557 p->error_indicator = 1;
8558 return NULL;
8559 }
8560 goto done;
8561 }
8562 p->mark = mark;
8563 }
8564 res = NULL;
8565 done:
8566 return res;
8567}
8568
8569// kvpairs: ','.kvpair+ ','?
8570static asdl_seq*
8571kvpairs_rule(Parser *p)
8572{
8573 if (p->error_indicator) {
8574 return NULL;
8575 }
8576 asdl_seq* res = NULL;
8577 int mark = p->mark;
8578 { // ','.kvpair+ ','?
8579 asdl_seq * a;
8580 void *opt_var;
8581 UNUSED(opt_var); // Silence compiler warnings
8582 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008583 (a = _gather_102_rule(p)) // ','.kvpair+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008584 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008585 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008586 )
8587 {
8588 res = a;
8589 if (res == NULL && PyErr_Occurred()) {
8590 p->error_indicator = 1;
8591 return NULL;
8592 }
8593 goto done;
8594 }
8595 p->mark = mark;
8596 }
8597 res = NULL;
8598 done:
8599 return res;
8600}
8601
8602// kvpair: '**' bitwise_or | expression ':' expression
8603static KeyValuePair*
8604kvpair_rule(Parser *p)
8605{
8606 if (p->error_indicator) {
8607 return NULL;
8608 }
8609 KeyValuePair* res = NULL;
8610 int mark = p->mark;
8611 { // '**' bitwise_or
8612 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008613 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008614 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008615 (literal = _PyPegen_expect_token(p, 35)) // token='**'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008616 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008617 (a = bitwise_or_rule(p)) // bitwise_or
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008618 )
8619 {
8620 res = _PyPegen_key_value_pair ( p , NULL , a );
8621 if (res == NULL && PyErr_Occurred()) {
8622 p->error_indicator = 1;
8623 return NULL;
8624 }
8625 goto done;
8626 }
8627 p->mark = mark;
8628 }
8629 { // expression ':' expression
8630 expr_ty a;
8631 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008632 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008633 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008634 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008635 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008636 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008637 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008638 (b = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008639 )
8640 {
8641 res = _PyPegen_key_value_pair ( p , a , b );
8642 if (res == NULL && PyErr_Occurred()) {
8643 p->error_indicator = 1;
8644 return NULL;
8645 }
8646 goto done;
8647 }
8648 p->mark = mark;
8649 }
8650 res = NULL;
8651 done:
8652 return res;
8653}
8654
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008655// for_if_clauses: for_if_clause+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008656static asdl_seq*
8657for_if_clauses_rule(Parser *p)
8658{
8659 if (p->error_indicator) {
8660 return NULL;
8661 }
8662 asdl_seq* res = NULL;
8663 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008664 { // for_if_clause+
Guido van Rossum3941d972020-05-01 09:42:03 -07008665 asdl_seq * _loop1_104_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008666 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008667 (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008668 )
8669 {
Guido van Rossum3941d972020-05-01 09:42:03 -07008670 res = _loop1_104_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008671 goto done;
8672 }
8673 p->mark = mark;
8674 }
8675 res = NULL;
8676 done:
8677 return res;
8678}
8679
8680// for_if_clause:
8681// | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
8682// | 'for' star_targets 'in' disjunction (('if' disjunction))*
8683static comprehension_ty
8684for_if_clause_rule(Parser *p)
8685{
8686 if (p->error_indicator) {
8687 return NULL;
8688 }
8689 comprehension_ty res = NULL;
8690 int mark = p->mark;
8691 { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
8692 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008693 Token * async_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008694 expr_ty b;
8695 asdl_seq * c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008696 Token * keyword;
8697 Token * keyword_1;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008698 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008699 (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008700 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008701 (keyword = _PyPegen_expect_token(p, 517)) // token='for'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008702 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008703 (a = star_targets_rule(p)) // star_targets
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008704 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008705 (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008706 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008707 (b = disjunction_rule(p)) // disjunction
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008708 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008709 (c = _loop0_105_rule(p)) // (('if' disjunction))*
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008710 )
8711 {
8712 res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) );
8713 if (res == NULL && PyErr_Occurred()) {
8714 p->error_indicator = 1;
8715 return NULL;
8716 }
8717 goto done;
8718 }
8719 p->mark = mark;
8720 }
8721 { // 'for' star_targets 'in' disjunction (('if' disjunction))*
8722 expr_ty a;
8723 expr_ty b;
8724 asdl_seq * c;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008725 Token * keyword;
8726 Token * keyword_1;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008727 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008728 (keyword = _PyPegen_expect_token(p, 517)) // token='for'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008729 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008730 (a = star_targets_rule(p)) // star_targets
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008731 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008732 (keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008733 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008734 (b = disjunction_rule(p)) // disjunction
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008735 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008736 (c = _loop0_106_rule(p)) // (('if' disjunction))*
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +03008737 )
8738 {
8739 res = _Py_comprehension ( a , b , c , 0 , p -> arena );
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008740 if (res == NULL && PyErr_Occurred()) {
8741 p->error_indicator = 1;
8742 return NULL;
8743 }
8744 goto done;
8745 }
8746 p->mark = mark;
8747 }
8748 res = NULL;
8749 done:
8750 return res;
8751}
8752
8753// yield_expr: 'yield' 'from' expression | 'yield' star_expressions?
8754static expr_ty
8755yield_expr_rule(Parser *p)
8756{
8757 if (p->error_indicator) {
8758 return NULL;
8759 }
8760 expr_ty res = NULL;
8761 int mark = p->mark;
8762 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8763 p->error_indicator = 1;
8764 return NULL;
8765 }
8766 int start_lineno = p->tokens[mark]->lineno;
8767 UNUSED(start_lineno); // Only used by EXTRA macro
8768 int start_col_offset = p->tokens[mark]->col_offset;
8769 UNUSED(start_col_offset); // Only used by EXTRA macro
8770 { // 'yield' 'from' expression
8771 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008772 Token * keyword;
8773 Token * keyword_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008774 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008775 (keyword = _PyPegen_expect_token(p, 504)) // token='yield'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008776 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008777 (keyword_1 = _PyPegen_expect_token(p, 514)) // token='from'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008778 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008779 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008780 )
8781 {
8782 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8783 if (token == NULL) {
8784 return NULL;
8785 }
8786 int end_lineno = token->end_lineno;
8787 UNUSED(end_lineno); // Only used by EXTRA macro
8788 int end_col_offset = token->end_col_offset;
8789 UNUSED(end_col_offset); // Only used by EXTRA macro
8790 res = _Py_YieldFrom ( a , EXTRA );
8791 if (res == NULL && PyErr_Occurred()) {
8792 p->error_indicator = 1;
8793 return NULL;
8794 }
8795 goto done;
8796 }
8797 p->mark = mark;
8798 }
8799 { // 'yield' star_expressions?
8800 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008801 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008802 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008803 (keyword = _PyPegen_expect_token(p, 504)) // token='yield'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008804 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008805 (a = star_expressions_rule(p), 1) // star_expressions?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008806 )
8807 {
8808 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8809 if (token == NULL) {
8810 return NULL;
8811 }
8812 int end_lineno = token->end_lineno;
8813 UNUSED(end_lineno); // Only used by EXTRA macro
8814 int end_col_offset = token->end_col_offset;
8815 UNUSED(end_col_offset); // Only used by EXTRA macro
8816 res = _Py_Yield ( a , EXTRA );
8817 if (res == NULL && PyErr_Occurred()) {
8818 p->error_indicator = 1;
8819 return NULL;
8820 }
8821 goto done;
8822 }
8823 p->mark = mark;
8824 }
8825 res = NULL;
8826 done:
8827 return res;
8828}
8829
8830// arguments: args ','? &')' | incorrect_arguments
8831static expr_ty
8832arguments_rule(Parser *p)
8833{
8834 if (p->error_indicator) {
8835 return NULL;
8836 }
8837 expr_ty res = NULL;
8838 if (_PyPegen_is_memoized(p, arguments_type, &res))
8839 return res;
8840 int mark = p->mark;
8841 { // args ','? &')'
8842 expr_ty a;
8843 void *opt_var;
8844 UNUSED(opt_var); // Silence compiler warnings
8845 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008846 (a = args_rule(p)) // args
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008847 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008848 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008849 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008850 _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008851 )
8852 {
8853 res = a;
8854 if (res == NULL && PyErr_Occurred()) {
8855 p->error_indicator = 1;
8856 return NULL;
8857 }
8858 goto done;
8859 }
8860 p->mark = mark;
8861 }
8862 { // incorrect_arguments
8863 void *incorrect_arguments_var;
8864 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008865 (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008866 )
8867 {
8868 res = incorrect_arguments_var;
8869 goto done;
8870 }
8871 p->mark = mark;
8872 }
8873 res = NULL;
8874 done:
8875 _PyPegen_insert_memo(p, mark, arguments_type, res);
8876 return res;
8877}
8878
8879// args: starred_expression [',' args] | kwargs | named_expression [',' args]
8880static expr_ty
8881args_rule(Parser *p)
8882{
8883 if (p->error_indicator) {
8884 return NULL;
8885 }
8886 expr_ty res = NULL;
8887 int mark = p->mark;
8888 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
8889 p->error_indicator = 1;
8890 return NULL;
8891 }
8892 int start_lineno = p->tokens[mark]->lineno;
8893 UNUSED(start_lineno); // Only used by EXTRA macro
8894 int start_col_offset = p->tokens[mark]->col_offset;
8895 UNUSED(start_col_offset); // Only used by EXTRA macro
8896 { // starred_expression [',' args]
8897 expr_ty a;
8898 void *b;
8899 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008900 (a = starred_expression_rule(p)) // starred_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008901 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008902 (b = _tmp_107_rule(p), 1) // [',' args]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008903 )
8904 {
8905 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8906 if (token == NULL) {
8907 return NULL;
8908 }
8909 int end_lineno = token->end_lineno;
8910 UNUSED(end_lineno); // Only used by EXTRA macro
8911 int end_col_offset = token->end_col_offset;
8912 UNUSED(end_col_offset); // Only used by EXTRA macro
8913 res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
8914 if (res == NULL && PyErr_Occurred()) {
8915 p->error_indicator = 1;
8916 return NULL;
8917 }
8918 goto done;
8919 }
8920 p->mark = mark;
8921 }
8922 { // kwargs
8923 asdl_seq* a;
8924 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008925 (a = kwargs_rule(p)) // kwargs
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008926 )
8927 {
8928 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8929 if (token == NULL) {
8930 return NULL;
8931 }
8932 int end_lineno = token->end_lineno;
8933 UNUSED(end_lineno); // Only used by EXTRA macro
8934 int end_col_offset = token->end_col_offset;
8935 UNUSED(end_col_offset); // Only used by EXTRA macro
8936 res = _Py_Call ( _PyPegen_dummy_name ( p ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_extract_starred_exprs ( p , a ) ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_delete_starred_exprs ( p , a ) ) , EXTRA );
8937 if (res == NULL && PyErr_Occurred()) {
8938 p->error_indicator = 1;
8939 return NULL;
8940 }
8941 goto done;
8942 }
8943 p->mark = mark;
8944 }
8945 { // named_expression [',' args]
8946 expr_ty a;
8947 void *b;
8948 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008949 (a = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008950 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008951 (b = _tmp_108_rule(p), 1) // [',' args]
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008952 )
8953 {
8954 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
8955 if (token == NULL) {
8956 return NULL;
8957 }
8958 int end_lineno = token->end_lineno;
8959 UNUSED(end_lineno); // Only used by EXTRA macro
8960 int end_col_offset = token->end_col_offset;
8961 UNUSED(end_col_offset); // Only used by EXTRA macro
8962 res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
8963 if (res == NULL && PyErr_Occurred()) {
8964 p->error_indicator = 1;
8965 return NULL;
8966 }
8967 goto done;
8968 }
8969 p->mark = mark;
8970 }
8971 res = NULL;
8972 done:
8973 return res;
8974}
8975
8976// kwargs:
8977// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
8978// | ','.kwarg_or_starred+
8979// | ','.kwarg_or_double_starred+
8980static asdl_seq*
8981kwargs_rule(Parser *p)
8982{
8983 if (p->error_indicator) {
8984 return NULL;
8985 }
8986 asdl_seq* res = NULL;
8987 int mark = p->mark;
8988 { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
8989 asdl_seq * a;
8990 asdl_seq * b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01008991 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008992 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01008993 (a = _gather_109_rule(p)) // ','.kwarg_or_starred+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008994 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008995 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008996 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01008997 (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01008998 )
8999 {
9000 res = _PyPegen_join_sequences ( p , a , b );
9001 if (res == NULL && PyErr_Occurred()) {
9002 p->error_indicator = 1;
9003 return NULL;
9004 }
9005 goto done;
9006 }
9007 p->mark = mark;
9008 }
9009 { // ','.kwarg_or_starred+
Guido van Rossum3941d972020-05-01 09:42:03 -07009010 asdl_seq * _gather_113_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009011 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009012 (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009013 )
9014 {
Guido van Rossum3941d972020-05-01 09:42:03 -07009015 res = _gather_113_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009016 goto done;
9017 }
9018 p->mark = mark;
9019 }
9020 { // ','.kwarg_or_double_starred+
Guido van Rossum3941d972020-05-01 09:42:03 -07009021 asdl_seq * _gather_115_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009022 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009023 (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009024 )
9025 {
Guido van Rossum3941d972020-05-01 09:42:03 -07009026 res = _gather_115_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009027 goto done;
9028 }
9029 p->mark = mark;
9030 }
9031 res = NULL;
9032 done:
9033 return res;
9034}
9035
9036// starred_expression: '*' expression
9037static expr_ty
9038starred_expression_rule(Parser *p)
9039{
9040 if (p->error_indicator) {
9041 return NULL;
9042 }
9043 expr_ty res = NULL;
9044 int mark = p->mark;
9045 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9046 p->error_indicator = 1;
9047 return NULL;
9048 }
9049 int start_lineno = p->tokens[mark]->lineno;
9050 UNUSED(start_lineno); // Only used by EXTRA macro
9051 int start_col_offset = p->tokens[mark]->col_offset;
9052 UNUSED(start_col_offset); // Only used by EXTRA macro
9053 { // '*' expression
9054 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009055 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009056 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009057 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009058 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009059 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009060 )
9061 {
9062 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9063 if (token == NULL) {
9064 return NULL;
9065 }
9066 int end_lineno = token->end_lineno;
9067 UNUSED(end_lineno); // Only used by EXTRA macro
9068 int end_col_offset = token->end_col_offset;
9069 UNUSED(end_col_offset); // Only used by EXTRA macro
9070 res = _Py_Starred ( a , Load , EXTRA );
9071 if (res == NULL && PyErr_Occurred()) {
9072 p->error_indicator = 1;
9073 return NULL;
9074 }
9075 goto done;
9076 }
9077 p->mark = mark;
9078 }
9079 res = NULL;
9080 done:
9081 return res;
9082}
9083
Lysandros Nikolaou4638c642020-05-07 13:44:06 +03009084// kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009085static KeywordOrStarred*
9086kwarg_or_starred_rule(Parser *p)
9087{
9088 if (p->error_indicator) {
9089 return NULL;
9090 }
9091 KeywordOrStarred* res = NULL;
9092 int mark = p->mark;
9093 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9094 p->error_indicator = 1;
9095 return NULL;
9096 }
9097 int start_lineno = p->tokens[mark]->lineno;
9098 UNUSED(start_lineno); // Only used by EXTRA macro
9099 int start_col_offset = p->tokens[mark]->col_offset;
9100 UNUSED(start_col_offset); // Only used by EXTRA macro
9101 { // NAME '=' expression
9102 expr_ty a;
9103 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009104 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009105 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009106 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009107 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009108 (literal = _PyPegen_expect_token(p, 22)) // token='='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009109 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009110 (b = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009111 )
9112 {
9113 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9114 if (token == NULL) {
9115 return NULL;
9116 }
9117 int end_lineno = token->end_lineno;
9118 UNUSED(end_lineno); // Only used by EXTRA macro
9119 int end_col_offset = token->end_col_offset;
9120 UNUSED(end_col_offset); // Only used by EXTRA macro
9121 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
9122 if (res == NULL && PyErr_Occurred()) {
9123 p->error_indicator = 1;
9124 return NULL;
9125 }
9126 goto done;
9127 }
9128 p->mark = mark;
9129 }
9130 { // starred_expression
9131 expr_ty a;
9132 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009133 (a = starred_expression_rule(p)) // starred_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009134 )
9135 {
9136 res = _PyPegen_keyword_or_starred ( p , a , 0 );
9137 if (res == NULL && PyErr_Occurred()) {
9138 p->error_indicator = 1;
9139 return NULL;
9140 }
9141 goto done;
9142 }
9143 p->mark = mark;
9144 }
Lysandros Nikolaou4638c642020-05-07 13:44:06 +03009145 { // invalid_kwarg
9146 void *invalid_kwarg_var;
9147 if (
9148 (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg
9149 )
9150 {
9151 res = invalid_kwarg_var;
9152 goto done;
9153 }
9154 p->mark = mark;
9155 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009156 res = NULL;
9157 done:
9158 return res;
9159}
9160
Lysandros Nikolaou4638c642020-05-07 13:44:06 +03009161// kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009162static KeywordOrStarred*
9163kwarg_or_double_starred_rule(Parser *p)
9164{
9165 if (p->error_indicator) {
9166 return NULL;
9167 }
9168 KeywordOrStarred* res = NULL;
9169 int mark = p->mark;
9170 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9171 p->error_indicator = 1;
9172 return NULL;
9173 }
9174 int start_lineno = p->tokens[mark]->lineno;
9175 UNUSED(start_lineno); // Only used by EXTRA macro
9176 int start_col_offset = p->tokens[mark]->col_offset;
9177 UNUSED(start_col_offset); // Only used by EXTRA macro
9178 { // NAME '=' expression
9179 expr_ty a;
9180 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009181 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009182 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009183 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009184 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009185 (literal = _PyPegen_expect_token(p, 22)) // token='='
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009186 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009187 (b = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009188 )
9189 {
9190 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9191 if (token == NULL) {
9192 return NULL;
9193 }
9194 int end_lineno = token->end_lineno;
9195 UNUSED(end_lineno); // Only used by EXTRA macro
9196 int end_col_offset = token->end_col_offset;
9197 UNUSED(end_col_offset); // Only used by EXTRA macro
9198 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
9199 if (res == NULL && PyErr_Occurred()) {
9200 p->error_indicator = 1;
9201 return NULL;
9202 }
9203 goto done;
9204 }
9205 p->mark = mark;
9206 }
9207 { // '**' expression
9208 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009209 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009210 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009211 (literal = _PyPegen_expect_token(p, 35)) // token='**'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009212 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009213 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009214 )
9215 {
9216 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9217 if (token == NULL) {
9218 return NULL;
9219 }
9220 int end_lineno = token->end_lineno;
9221 UNUSED(end_lineno); // Only used by EXTRA macro
9222 int end_col_offset = token->end_col_offset;
9223 UNUSED(end_col_offset); // Only used by EXTRA macro
9224 res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 );
9225 if (res == NULL && PyErr_Occurred()) {
9226 p->error_indicator = 1;
9227 return NULL;
9228 }
9229 goto done;
9230 }
9231 p->mark = mark;
9232 }
Lysandros Nikolaou4638c642020-05-07 13:44:06 +03009233 { // invalid_kwarg
9234 void *invalid_kwarg_var;
9235 if (
9236 (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg
9237 )
9238 {
9239 res = invalid_kwarg_var;
9240 goto done;
9241 }
9242 p->mark = mark;
9243 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009244 res = NULL;
9245 done:
9246 return res;
9247}
9248
9249// star_targets: star_target !',' | star_target ((',' star_target))* ','?
9250static expr_ty
9251star_targets_rule(Parser *p)
9252{
9253 if (p->error_indicator) {
9254 return NULL;
9255 }
9256 expr_ty res = NULL;
9257 int mark = p->mark;
9258 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9259 p->error_indicator = 1;
9260 return NULL;
9261 }
9262 int start_lineno = p->tokens[mark]->lineno;
9263 UNUSED(start_lineno); // Only used by EXTRA macro
9264 int start_col_offset = p->tokens[mark]->col_offset;
9265 UNUSED(start_col_offset); // Only used by EXTRA macro
9266 { // star_target !','
9267 expr_ty a;
9268 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009269 (a = star_target_rule(p)) // star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009270 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009271 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009272 )
9273 {
9274 res = a;
9275 if (res == NULL && PyErr_Occurred()) {
9276 p->error_indicator = 1;
9277 return NULL;
9278 }
9279 goto done;
9280 }
9281 p->mark = mark;
9282 }
9283 { // star_target ((',' star_target))* ','?
9284 expr_ty a;
9285 asdl_seq * b;
9286 void *opt_var;
9287 UNUSED(opt_var); // Silence compiler warnings
9288 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009289 (a = star_target_rule(p)) // star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009290 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009291 (b = _loop0_117_rule(p)) // ((',' star_target))*
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009292 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009293 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009294 )
9295 {
9296 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9297 if (token == NULL) {
9298 return NULL;
9299 }
9300 int end_lineno = token->end_lineno;
9301 UNUSED(end_lineno); // Only used by EXTRA macro
9302 int end_col_offset = token->end_col_offset;
9303 UNUSED(end_col_offset); // Only used by EXTRA macro
9304 res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA );
9305 if (res == NULL && PyErr_Occurred()) {
9306 p->error_indicator = 1;
9307 return NULL;
9308 }
9309 goto done;
9310 }
9311 p->mark = mark;
9312 }
9313 res = NULL;
9314 done:
9315 return res;
9316}
9317
9318// star_targets_seq: ','.star_target+ ','?
9319static asdl_seq*
9320star_targets_seq_rule(Parser *p)
9321{
9322 if (p->error_indicator) {
9323 return NULL;
9324 }
9325 asdl_seq* res = NULL;
9326 int mark = p->mark;
9327 { // ','.star_target+ ','?
9328 asdl_seq * a;
9329 void *opt_var;
9330 UNUSED(opt_var); // Silence compiler warnings
9331 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009332 (a = _gather_118_rule(p)) // ','.star_target+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009333 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009334 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009335 )
9336 {
9337 res = a;
9338 if (res == NULL && PyErr_Occurred()) {
9339 p->error_indicator = 1;
9340 return NULL;
9341 }
9342 goto done;
9343 }
9344 p->mark = mark;
9345 }
9346 res = NULL;
9347 done:
9348 return res;
9349}
9350
9351// star_target:
9352// | '*' (!'*' star_target)
9353// | t_primary '.' NAME !t_lookahead
9354// | t_primary '[' slices ']' !t_lookahead
9355// | star_atom
9356static expr_ty
9357star_target_rule(Parser *p)
9358{
9359 if (p->error_indicator) {
9360 return NULL;
9361 }
9362 expr_ty res = NULL;
9363 if (_PyPegen_is_memoized(p, star_target_type, &res))
9364 return res;
9365 int mark = p->mark;
9366 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9367 p->error_indicator = 1;
9368 return NULL;
9369 }
9370 int start_lineno = p->tokens[mark]->lineno;
9371 UNUSED(start_lineno); // Only used by EXTRA macro
9372 int start_col_offset = p->tokens[mark]->col_offset;
9373 UNUSED(start_col_offset); // Only used by EXTRA macro
9374 { // '*' (!'*' star_target)
9375 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009376 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009377 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009378 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009379 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009380 (a = _tmp_120_rule(p)) // !'*' star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009381 )
9382 {
9383 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9384 if (token == NULL) {
9385 return NULL;
9386 }
9387 int end_lineno = token->end_lineno;
9388 UNUSED(end_lineno); // Only used by EXTRA macro
9389 int end_col_offset = token->end_col_offset;
9390 UNUSED(end_col_offset); // Only used by EXTRA macro
9391 res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA );
9392 if (res == NULL && PyErr_Occurred()) {
9393 p->error_indicator = 1;
9394 return NULL;
9395 }
9396 goto done;
9397 }
9398 p->mark = mark;
9399 }
9400 { // t_primary '.' NAME !t_lookahead
9401 expr_ty a;
9402 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009403 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009404 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009405 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009406 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009407 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009408 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009409 (b = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009410 &&
9411 _PyPegen_lookahead(0, t_lookahead_rule, p)
9412 )
9413 {
9414 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9415 if (token == NULL) {
9416 return NULL;
9417 }
9418 int end_lineno = token->end_lineno;
9419 UNUSED(end_lineno); // Only used by EXTRA macro
9420 int end_col_offset = token->end_col_offset;
9421 UNUSED(end_col_offset); // Only used by EXTRA macro
9422 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
9423 if (res == NULL && PyErr_Occurred()) {
9424 p->error_indicator = 1;
9425 return NULL;
9426 }
9427 goto done;
9428 }
9429 p->mark = mark;
9430 }
9431 { // t_primary '[' slices ']' !t_lookahead
9432 expr_ty a;
9433 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009434 Token * literal;
9435 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009436 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009437 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009438 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009439 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009440 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009441 (b = slices_rule(p)) // slices
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009442 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009443 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009444 &&
9445 _PyPegen_lookahead(0, t_lookahead_rule, p)
9446 )
9447 {
9448 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9449 if (token == NULL) {
9450 return NULL;
9451 }
9452 int end_lineno = token->end_lineno;
9453 UNUSED(end_lineno); // Only used by EXTRA macro
9454 int end_col_offset = token->end_col_offset;
9455 UNUSED(end_col_offset); // Only used by EXTRA macro
9456 res = _Py_Subscript ( a , b , Store , EXTRA );
9457 if (res == NULL && PyErr_Occurred()) {
9458 p->error_indicator = 1;
9459 return NULL;
9460 }
9461 goto done;
9462 }
9463 p->mark = mark;
9464 }
9465 { // star_atom
9466 expr_ty star_atom_var;
9467 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009468 (star_atom_var = star_atom_rule(p)) // star_atom
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009469 )
9470 {
9471 res = star_atom_var;
9472 goto done;
9473 }
9474 p->mark = mark;
9475 }
9476 res = NULL;
9477 done:
9478 _PyPegen_insert_memo(p, mark, star_target_type, res);
9479 return res;
9480}
9481
9482// star_atom:
9483// | NAME
9484// | '(' star_target ')'
9485// | '(' star_targets_seq? ')'
9486// | '[' star_targets_seq? ']'
9487static expr_ty
9488star_atom_rule(Parser *p)
9489{
9490 if (p->error_indicator) {
9491 return NULL;
9492 }
9493 expr_ty res = NULL;
9494 int mark = p->mark;
9495 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9496 p->error_indicator = 1;
9497 return NULL;
9498 }
9499 int start_lineno = p->tokens[mark]->lineno;
9500 UNUSED(start_lineno); // Only used by EXTRA macro
9501 int start_col_offset = p->tokens[mark]->col_offset;
9502 UNUSED(start_col_offset); // Only used by EXTRA macro
9503 { // NAME
9504 expr_ty a;
9505 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009506 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009507 )
9508 {
9509 res = _PyPegen_set_expr_context ( p , a , Store );
9510 if (res == NULL && PyErr_Occurred()) {
9511 p->error_indicator = 1;
9512 return NULL;
9513 }
9514 goto done;
9515 }
9516 p->mark = mark;
9517 }
9518 { // '(' star_target ')'
9519 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009520 Token * literal;
9521 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009522 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009523 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009524 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009525 (a = star_target_rule(p)) // star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009526 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009527 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009528 )
9529 {
9530 res = _PyPegen_set_expr_context ( p , a , Store );
9531 if (res == NULL && PyErr_Occurred()) {
9532 p->error_indicator = 1;
9533 return NULL;
9534 }
9535 goto done;
9536 }
9537 p->mark = mark;
9538 }
9539 { // '(' star_targets_seq? ')'
9540 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009541 Token * literal;
9542 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009543 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009544 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009545 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009546 (a = star_targets_seq_rule(p), 1) // star_targets_seq?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009547 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009548 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009549 )
9550 {
9551 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9552 if (token == NULL) {
9553 return NULL;
9554 }
9555 int end_lineno = token->end_lineno;
9556 UNUSED(end_lineno); // Only used by EXTRA macro
9557 int end_col_offset = token->end_col_offset;
9558 UNUSED(end_col_offset); // Only used by EXTRA macro
9559 res = _Py_Tuple ( a , Store , EXTRA );
9560 if (res == NULL && PyErr_Occurred()) {
9561 p->error_indicator = 1;
9562 return NULL;
9563 }
9564 goto done;
9565 }
9566 p->mark = mark;
9567 }
9568 { // '[' star_targets_seq? ']'
9569 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009570 Token * literal;
9571 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009572 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009573 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009574 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009575 (a = star_targets_seq_rule(p), 1) // star_targets_seq?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009576 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009577 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009578 )
9579 {
9580 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9581 if (token == NULL) {
9582 return NULL;
9583 }
9584 int end_lineno = token->end_lineno;
9585 UNUSED(end_lineno); // Only used by EXTRA macro
9586 int end_col_offset = token->end_col_offset;
9587 UNUSED(end_col_offset); // Only used by EXTRA macro
9588 res = _Py_List ( a , Store , EXTRA );
9589 if (res == NULL && PyErr_Occurred()) {
9590 p->error_indicator = 1;
9591 return NULL;
9592 }
9593 goto done;
9594 }
9595 p->mark = mark;
9596 }
9597 res = NULL;
9598 done:
9599 return res;
9600}
9601
9602// inside_paren_ann_assign_target:
9603// | ann_assign_subscript_attribute_target
9604// | NAME
9605// | '(' inside_paren_ann_assign_target ')'
9606static expr_ty
9607inside_paren_ann_assign_target_rule(Parser *p)
9608{
9609 if (p->error_indicator) {
9610 return NULL;
9611 }
9612 expr_ty res = NULL;
9613 int mark = p->mark;
9614 { // ann_assign_subscript_attribute_target
9615 expr_ty ann_assign_subscript_attribute_target_var;
9616 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009617 (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p)) // ann_assign_subscript_attribute_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009618 )
9619 {
9620 res = ann_assign_subscript_attribute_target_var;
9621 goto done;
9622 }
9623 p->mark = mark;
9624 }
9625 { // NAME
9626 expr_ty a;
9627 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009628 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009629 )
9630 {
9631 res = _PyPegen_set_expr_context ( p , a , Store );
9632 if (res == NULL && PyErr_Occurred()) {
9633 p->error_indicator = 1;
9634 return NULL;
9635 }
9636 goto done;
9637 }
9638 p->mark = mark;
9639 }
9640 { // '(' inside_paren_ann_assign_target ')'
9641 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009642 Token * literal;
9643 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009644 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009645 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009646 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009647 (a = inside_paren_ann_assign_target_rule(p)) // inside_paren_ann_assign_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009648 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009649 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009650 )
9651 {
9652 res = a;
9653 if (res == NULL && PyErr_Occurred()) {
9654 p->error_indicator = 1;
9655 return NULL;
9656 }
9657 goto done;
9658 }
9659 p->mark = mark;
9660 }
9661 res = NULL;
9662 done:
9663 return res;
9664}
9665
9666// ann_assign_subscript_attribute_target:
9667// | t_primary '.' NAME !t_lookahead
9668// | t_primary '[' slices ']' !t_lookahead
9669static expr_ty
9670ann_assign_subscript_attribute_target_rule(Parser *p)
9671{
9672 if (p->error_indicator) {
9673 return NULL;
9674 }
9675 expr_ty res = NULL;
9676 int mark = p->mark;
9677 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9678 p->error_indicator = 1;
9679 return NULL;
9680 }
9681 int start_lineno = p->tokens[mark]->lineno;
9682 UNUSED(start_lineno); // Only used by EXTRA macro
9683 int start_col_offset = p->tokens[mark]->col_offset;
9684 UNUSED(start_col_offset); // Only used by EXTRA macro
9685 { // t_primary '.' NAME !t_lookahead
9686 expr_ty a;
9687 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009688 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009689 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009690 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009691 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009692 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009693 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009694 (b = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009695 &&
9696 _PyPegen_lookahead(0, t_lookahead_rule, p)
9697 )
9698 {
9699 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9700 if (token == NULL) {
9701 return NULL;
9702 }
9703 int end_lineno = token->end_lineno;
9704 UNUSED(end_lineno); // Only used by EXTRA macro
9705 int end_col_offset = token->end_col_offset;
9706 UNUSED(end_col_offset); // Only used by EXTRA macro
9707 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
9708 if (res == NULL && PyErr_Occurred()) {
9709 p->error_indicator = 1;
9710 return NULL;
9711 }
9712 goto done;
9713 }
9714 p->mark = mark;
9715 }
9716 { // t_primary '[' slices ']' !t_lookahead
9717 expr_ty a;
9718 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009719 Token * literal;
9720 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009721 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009722 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009723 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009724 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009725 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009726 (b = slices_rule(p)) // slices
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009727 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009728 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009729 &&
9730 _PyPegen_lookahead(0, t_lookahead_rule, p)
9731 )
9732 {
9733 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9734 if (token == NULL) {
9735 return NULL;
9736 }
9737 int end_lineno = token->end_lineno;
9738 UNUSED(end_lineno); // Only used by EXTRA macro
9739 int end_col_offset = token->end_col_offset;
9740 UNUSED(end_col_offset); // Only used by EXTRA macro
9741 res = _Py_Subscript ( a , b , Store , EXTRA );
9742 if (res == NULL && PyErr_Occurred()) {
9743 p->error_indicator = 1;
9744 return NULL;
9745 }
9746 goto done;
9747 }
9748 p->mark = mark;
9749 }
9750 res = NULL;
9751 done:
9752 return res;
9753}
9754
9755// del_targets: ','.del_target+ ','?
9756static asdl_seq*
9757del_targets_rule(Parser *p)
9758{
9759 if (p->error_indicator) {
9760 return NULL;
9761 }
9762 asdl_seq* res = NULL;
9763 int mark = p->mark;
9764 { // ','.del_target+ ','?
9765 asdl_seq * a;
9766 void *opt_var;
9767 UNUSED(opt_var); // Silence compiler warnings
9768 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009769 (a = _gather_121_rule(p)) // ','.del_target+
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009770 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009771 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009772 )
9773 {
9774 res = a;
9775 if (res == NULL && PyErr_Occurred()) {
9776 p->error_indicator = 1;
9777 return NULL;
9778 }
9779 goto done;
9780 }
9781 p->mark = mark;
9782 }
9783 res = NULL;
9784 done:
9785 return res;
9786}
9787
9788// del_target:
9789// | t_primary '.' NAME !t_lookahead
9790// | t_primary '[' slices ']' !t_lookahead
9791// | del_t_atom
9792static expr_ty
9793del_target_rule(Parser *p)
9794{
9795 if (p->error_indicator) {
9796 return NULL;
9797 }
9798 expr_ty res = NULL;
9799 if (_PyPegen_is_memoized(p, del_target_type, &res))
9800 return res;
9801 int mark = p->mark;
9802 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9803 p->error_indicator = 1;
9804 return NULL;
9805 }
9806 int start_lineno = p->tokens[mark]->lineno;
9807 UNUSED(start_lineno); // Only used by EXTRA macro
9808 int start_col_offset = p->tokens[mark]->col_offset;
9809 UNUSED(start_col_offset); // Only used by EXTRA macro
9810 { // t_primary '.' NAME !t_lookahead
9811 expr_ty a;
9812 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009813 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009814 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009815 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009816 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009817 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009818 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009819 (b = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009820 &&
9821 _PyPegen_lookahead(0, t_lookahead_rule, p)
9822 )
9823 {
9824 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9825 if (token == NULL) {
9826 return NULL;
9827 }
9828 int end_lineno = token->end_lineno;
9829 UNUSED(end_lineno); // Only used by EXTRA macro
9830 int end_col_offset = token->end_col_offset;
9831 UNUSED(end_col_offset); // Only used by EXTRA macro
9832 res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA );
9833 if (res == NULL && PyErr_Occurred()) {
9834 p->error_indicator = 1;
9835 return NULL;
9836 }
9837 goto done;
9838 }
9839 p->mark = mark;
9840 }
9841 { // t_primary '[' slices ']' !t_lookahead
9842 expr_ty a;
9843 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009844 Token * literal;
9845 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009846 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009847 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009848 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009849 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009850 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009851 (b = slices_rule(p)) // slices
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009852 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009853 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009854 &&
9855 _PyPegen_lookahead(0, t_lookahead_rule, p)
9856 )
9857 {
9858 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9859 if (token == NULL) {
9860 return NULL;
9861 }
9862 int end_lineno = token->end_lineno;
9863 UNUSED(end_lineno); // Only used by EXTRA macro
9864 int end_col_offset = token->end_col_offset;
9865 UNUSED(end_col_offset); // Only used by EXTRA macro
9866 res = _Py_Subscript ( a , b , Del , EXTRA );
9867 if (res == NULL && PyErr_Occurred()) {
9868 p->error_indicator = 1;
9869 return NULL;
9870 }
9871 goto done;
9872 }
9873 p->mark = mark;
9874 }
9875 { // del_t_atom
9876 expr_ty del_t_atom_var;
9877 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009878 (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009879 )
9880 {
9881 res = del_t_atom_var;
9882 goto done;
9883 }
9884 p->mark = mark;
9885 }
9886 res = NULL;
9887 done:
9888 _PyPegen_insert_memo(p, mark, del_target_type, res);
9889 return res;
9890}
9891
9892// del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']'
9893static expr_ty
9894del_t_atom_rule(Parser *p)
9895{
9896 if (p->error_indicator) {
9897 return NULL;
9898 }
9899 expr_ty res = NULL;
9900 int mark = p->mark;
9901 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
9902 p->error_indicator = 1;
9903 return NULL;
9904 }
9905 int start_lineno = p->tokens[mark]->lineno;
9906 UNUSED(start_lineno); // Only used by EXTRA macro
9907 int start_col_offset = p->tokens[mark]->col_offset;
9908 UNUSED(start_col_offset); // Only used by EXTRA macro
9909 { // NAME
9910 expr_ty a;
9911 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009912 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009913 )
9914 {
9915 res = _PyPegen_set_expr_context ( p , a , Del );
9916 if (res == NULL && PyErr_Occurred()) {
9917 p->error_indicator = 1;
9918 return NULL;
9919 }
9920 goto done;
9921 }
9922 p->mark = mark;
9923 }
9924 { // '(' del_target ')'
9925 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009926 Token * literal;
9927 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009928 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009929 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009930 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009931 (a = del_target_rule(p)) // del_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009932 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009933 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009934 )
9935 {
9936 res = _PyPegen_set_expr_context ( p , a , Del );
9937 if (res == NULL && PyErr_Occurred()) {
9938 p->error_indicator = 1;
9939 return NULL;
9940 }
9941 goto done;
9942 }
9943 p->mark = mark;
9944 }
9945 { // '(' del_targets? ')'
9946 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009947 Token * literal;
9948 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009949 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009950 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009951 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009952 (a = del_targets_rule(p), 1) // del_targets?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009953 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009954 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009955 )
9956 {
9957 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9958 if (token == NULL) {
9959 return NULL;
9960 }
9961 int end_lineno = token->end_lineno;
9962 UNUSED(end_lineno); // Only used by EXTRA macro
9963 int end_col_offset = token->end_col_offset;
9964 UNUSED(end_col_offset); // Only used by EXTRA macro
9965 res = _Py_Tuple ( a , Del , EXTRA );
9966 if (res == NULL && PyErr_Occurred()) {
9967 p->error_indicator = 1;
9968 return NULL;
9969 }
9970 goto done;
9971 }
9972 p->mark = mark;
9973 }
9974 { // '[' del_targets? ']'
9975 void *a;
Pablo Galindob796b3f2020-05-01 12:32:26 +01009976 Token * literal;
9977 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009978 if (
Pablo Galindo470aac42020-05-06 23:14:43 +01009979 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009980 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009981 (a = del_targets_rule(p), 1) // del_targets?
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009982 &&
Pablo Galindo470aac42020-05-06 23:14:43 +01009983 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +01009984 )
9985 {
9986 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
9987 if (token == NULL) {
9988 return NULL;
9989 }
9990 int end_lineno = token->end_lineno;
9991 UNUSED(end_lineno); // Only used by EXTRA macro
9992 int end_col_offset = token->end_col_offset;
9993 UNUSED(end_col_offset); // Only used by EXTRA macro
9994 res = _Py_List ( a , Del , EXTRA );
9995 if (res == NULL && PyErr_Occurred()) {
9996 p->error_indicator = 1;
9997 return NULL;
9998 }
9999 goto done;
10000 }
10001 p->mark = mark;
10002 }
10003 res = NULL;
10004 done:
10005 return res;
10006}
10007
10008// targets: ','.target+ ','?
10009static asdl_seq*
10010targets_rule(Parser *p)
10011{
10012 if (p->error_indicator) {
10013 return NULL;
10014 }
10015 asdl_seq* res = NULL;
10016 int mark = p->mark;
10017 { // ','.target+ ','?
10018 asdl_seq * a;
10019 void *opt_var;
10020 UNUSED(opt_var); // Silence compiler warnings
10021 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010022 (a = _gather_123_rule(p)) // ','.target+
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010023 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010024 (opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010025 )
10026 {
10027 res = a;
10028 if (res == NULL && PyErr_Occurred()) {
10029 p->error_indicator = 1;
10030 return NULL;
10031 }
10032 goto done;
10033 }
10034 p->mark = mark;
10035 }
10036 res = NULL;
10037 done:
10038 return res;
10039}
10040
10041// target:
10042// | t_primary '.' NAME !t_lookahead
10043// | t_primary '[' slices ']' !t_lookahead
10044// | t_atom
10045static expr_ty
10046target_rule(Parser *p)
10047{
10048 if (p->error_indicator) {
10049 return NULL;
10050 }
10051 expr_ty res = NULL;
10052 if (_PyPegen_is_memoized(p, target_type, &res))
10053 return res;
10054 int mark = p->mark;
10055 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
10056 p->error_indicator = 1;
10057 return NULL;
10058 }
10059 int start_lineno = p->tokens[mark]->lineno;
10060 UNUSED(start_lineno); // Only used by EXTRA macro
10061 int start_col_offset = p->tokens[mark]->col_offset;
10062 UNUSED(start_col_offset); // Only used by EXTRA macro
10063 { // t_primary '.' NAME !t_lookahead
10064 expr_ty a;
10065 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010066 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010067 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010068 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010069 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010070 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010071 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010072 (b = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010073 &&
10074 _PyPegen_lookahead(0, t_lookahead_rule, p)
10075 )
10076 {
10077 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10078 if (token == NULL) {
10079 return NULL;
10080 }
10081 int end_lineno = token->end_lineno;
10082 UNUSED(end_lineno); // Only used by EXTRA macro
10083 int end_col_offset = token->end_col_offset;
10084 UNUSED(end_col_offset); // Only used by EXTRA macro
10085 res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
10086 if (res == NULL && PyErr_Occurred()) {
10087 p->error_indicator = 1;
10088 return NULL;
10089 }
10090 goto done;
10091 }
10092 p->mark = mark;
10093 }
10094 { // t_primary '[' slices ']' !t_lookahead
10095 expr_ty a;
10096 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010097 Token * literal;
10098 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010099 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010100 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010101 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010102 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010103 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010104 (b = slices_rule(p)) // slices
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010105 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010106 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010107 &&
10108 _PyPegen_lookahead(0, t_lookahead_rule, p)
10109 )
10110 {
10111 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10112 if (token == NULL) {
10113 return NULL;
10114 }
10115 int end_lineno = token->end_lineno;
10116 UNUSED(end_lineno); // Only used by EXTRA macro
10117 int end_col_offset = token->end_col_offset;
10118 UNUSED(end_col_offset); // Only used by EXTRA macro
10119 res = _Py_Subscript ( a , b , Store , EXTRA );
10120 if (res == NULL && PyErr_Occurred()) {
10121 p->error_indicator = 1;
10122 return NULL;
10123 }
10124 goto done;
10125 }
10126 p->mark = mark;
10127 }
10128 { // t_atom
10129 expr_ty t_atom_var;
10130 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010131 (t_atom_var = t_atom_rule(p)) // t_atom
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010132 )
10133 {
10134 res = t_atom_var;
10135 goto done;
10136 }
10137 p->mark = mark;
10138 }
10139 res = NULL;
10140 done:
10141 _PyPegen_insert_memo(p, mark, target_type, res);
10142 return res;
10143}
10144
10145// Left-recursive
10146// t_primary:
10147// | t_primary '.' NAME &t_lookahead
10148// | t_primary '[' slices ']' &t_lookahead
10149// | t_primary genexp &t_lookahead
10150// | t_primary '(' arguments? ')' &t_lookahead
10151// | atom &t_lookahead
10152static expr_ty t_primary_raw(Parser *);
10153static expr_ty
10154t_primary_rule(Parser *p)
10155{
10156 expr_ty res = NULL;
10157 if (_PyPegen_is_memoized(p, t_primary_type, &res))
10158 return res;
10159 int mark = p->mark;
10160 int resmark = p->mark;
10161 while (1) {
10162 int tmpvar_8 = _PyPegen_update_memo(p, mark, t_primary_type, res);
10163 if (tmpvar_8) {
10164 return res;
10165 }
10166 p->mark = mark;
10167 void *raw = t_primary_raw(p);
10168 if (raw == NULL || p->mark <= resmark)
10169 break;
10170 resmark = p->mark;
10171 res = raw;
10172 }
10173 p->mark = resmark;
10174 return res;
10175}
10176static expr_ty
10177t_primary_raw(Parser *p)
10178{
10179 if (p->error_indicator) {
10180 return NULL;
10181 }
10182 expr_ty res = NULL;
10183 int mark = p->mark;
10184 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
10185 p->error_indicator = 1;
10186 return NULL;
10187 }
10188 int start_lineno = p->tokens[mark]->lineno;
10189 UNUSED(start_lineno); // Only used by EXTRA macro
10190 int start_col_offset = p->tokens[mark]->col_offset;
10191 UNUSED(start_col_offset); // Only used by EXTRA macro
10192 { // t_primary '.' NAME &t_lookahead
10193 expr_ty a;
10194 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010195 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010196 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010197 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010198 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010199 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010200 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010201 (b = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010202 &&
10203 _PyPegen_lookahead(1, t_lookahead_rule, p)
10204 )
10205 {
10206 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10207 if (token == NULL) {
10208 return NULL;
10209 }
10210 int end_lineno = token->end_lineno;
10211 UNUSED(end_lineno); // Only used by EXTRA macro
10212 int end_col_offset = token->end_col_offset;
10213 UNUSED(end_col_offset); // Only used by EXTRA macro
10214 res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
10215 if (res == NULL && PyErr_Occurred()) {
10216 p->error_indicator = 1;
10217 return NULL;
10218 }
10219 goto done;
10220 }
10221 p->mark = mark;
10222 }
10223 { // t_primary '[' slices ']' &t_lookahead
10224 expr_ty a;
10225 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010226 Token * literal;
10227 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010228 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010229 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010230 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010231 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010232 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010233 (b = slices_rule(p)) // slices
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010234 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010235 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010236 &&
10237 _PyPegen_lookahead(1, t_lookahead_rule, p)
10238 )
10239 {
10240 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10241 if (token == NULL) {
10242 return NULL;
10243 }
10244 int end_lineno = token->end_lineno;
10245 UNUSED(end_lineno); // Only used by EXTRA macro
10246 int end_col_offset = token->end_col_offset;
10247 UNUSED(end_col_offset); // Only used by EXTRA macro
10248 res = _Py_Subscript ( a , b , Load , EXTRA );
10249 if (res == NULL && PyErr_Occurred()) {
10250 p->error_indicator = 1;
10251 return NULL;
10252 }
10253 goto done;
10254 }
10255 p->mark = mark;
10256 }
10257 { // t_primary genexp &t_lookahead
10258 expr_ty a;
10259 expr_ty b;
10260 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010261 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010262 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010263 (b = genexp_rule(p)) // genexp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010264 &&
10265 _PyPegen_lookahead(1, t_lookahead_rule, p)
10266 )
10267 {
10268 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10269 if (token == NULL) {
10270 return NULL;
10271 }
10272 int end_lineno = token->end_lineno;
10273 UNUSED(end_lineno); // Only used by EXTRA macro
10274 int end_col_offset = token->end_col_offset;
10275 UNUSED(end_col_offset); // Only used by EXTRA macro
10276 res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
10277 if (res == NULL && PyErr_Occurred()) {
10278 p->error_indicator = 1;
10279 return NULL;
10280 }
10281 goto done;
10282 }
10283 p->mark = mark;
10284 }
10285 { // t_primary '(' arguments? ')' &t_lookahead
10286 expr_ty a;
10287 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010288 Token * literal;
10289 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010290 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010291 (a = t_primary_rule(p)) // t_primary
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010292 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010293 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010294 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010295 (b = arguments_rule(p), 1) // arguments?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010296 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010297 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010298 &&
10299 _PyPegen_lookahead(1, t_lookahead_rule, p)
10300 )
10301 {
10302 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10303 if (token == NULL) {
10304 return NULL;
10305 }
10306 int end_lineno = token->end_lineno;
10307 UNUSED(end_lineno); // Only used by EXTRA macro
10308 int end_col_offset = token->end_col_offset;
10309 UNUSED(end_col_offset); // Only used by EXTRA macro
10310 res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
10311 if (res == NULL && PyErr_Occurred()) {
10312 p->error_indicator = 1;
10313 return NULL;
10314 }
10315 goto done;
10316 }
10317 p->mark = mark;
10318 }
10319 { // atom &t_lookahead
10320 expr_ty a;
10321 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010322 (a = atom_rule(p)) // atom
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010323 &&
10324 _PyPegen_lookahead(1, t_lookahead_rule, p)
10325 )
10326 {
10327 res = a;
10328 if (res == NULL && PyErr_Occurred()) {
10329 p->error_indicator = 1;
10330 return NULL;
10331 }
10332 goto done;
10333 }
10334 p->mark = mark;
10335 }
10336 res = NULL;
10337 done:
10338 return res;
10339}
10340
10341// t_lookahead: '(' | '[' | '.'
10342static void *
10343t_lookahead_rule(Parser *p)
10344{
10345 if (p->error_indicator) {
10346 return NULL;
10347 }
10348 void * res = NULL;
10349 int mark = p->mark;
10350 { // '('
Pablo Galindob796b3f2020-05-01 12:32:26 +010010351 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010352 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010353 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010354 )
10355 {
10356 res = literal;
10357 goto done;
10358 }
10359 p->mark = mark;
10360 }
10361 { // '['
Pablo Galindob796b3f2020-05-01 12:32:26 +010010362 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010363 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010364 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010365 )
10366 {
10367 res = literal;
10368 goto done;
10369 }
10370 p->mark = mark;
10371 }
10372 { // '.'
Pablo Galindob796b3f2020-05-01 12:32:26 +010010373 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010374 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010375 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010376 )
10377 {
10378 res = literal;
10379 goto done;
10380 }
10381 p->mark = mark;
10382 }
10383 res = NULL;
10384 done:
10385 return res;
10386}
10387
10388// t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']'
10389static expr_ty
10390t_atom_rule(Parser *p)
10391{
10392 if (p->error_indicator) {
10393 return NULL;
10394 }
10395 expr_ty res = NULL;
10396 int mark = p->mark;
10397 if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
10398 p->error_indicator = 1;
10399 return NULL;
10400 }
10401 int start_lineno = p->tokens[mark]->lineno;
10402 UNUSED(start_lineno); // Only used by EXTRA macro
10403 int start_col_offset = p->tokens[mark]->col_offset;
10404 UNUSED(start_col_offset); // Only used by EXTRA macro
10405 { // NAME
10406 expr_ty a;
10407 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010408 (a = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010409 )
10410 {
10411 res = _PyPegen_set_expr_context ( p , a , Store );
10412 if (res == NULL && PyErr_Occurred()) {
10413 p->error_indicator = 1;
10414 return NULL;
10415 }
10416 goto done;
10417 }
10418 p->mark = mark;
10419 }
10420 { // '(' target ')'
10421 expr_ty a;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010422 Token * literal;
10423 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010424 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010425 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010426 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010427 (a = target_rule(p)) // target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010428 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010429 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010430 )
10431 {
10432 res = _PyPegen_set_expr_context ( p , a , Store );
10433 if (res == NULL && PyErr_Occurred()) {
10434 p->error_indicator = 1;
10435 return NULL;
10436 }
10437 goto done;
10438 }
10439 p->mark = mark;
10440 }
10441 { // '(' targets? ')'
10442 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010443 Token * literal;
10444 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010445 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010446 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010447 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010448 (b = targets_rule(p), 1) // targets?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010449 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010450 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010451 )
10452 {
10453 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10454 if (token == NULL) {
10455 return NULL;
10456 }
10457 int end_lineno = token->end_lineno;
10458 UNUSED(end_lineno); // Only used by EXTRA macro
10459 int end_col_offset = token->end_col_offset;
10460 UNUSED(end_col_offset); // Only used by EXTRA macro
10461 res = _Py_Tuple ( b , Store , EXTRA );
10462 if (res == NULL && PyErr_Occurred()) {
10463 p->error_indicator = 1;
10464 return NULL;
10465 }
10466 goto done;
10467 }
10468 p->mark = mark;
10469 }
10470 { // '[' targets? ']'
10471 void *b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010472 Token * literal;
10473 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010474 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010475 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010476 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010477 (b = targets_rule(p), 1) // targets?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010478 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010479 (literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010480 )
10481 {
10482 Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
10483 if (token == NULL) {
10484 return NULL;
10485 }
10486 int end_lineno = token->end_lineno;
10487 UNUSED(end_lineno); // Only used by EXTRA macro
10488 int end_col_offset = token->end_col_offset;
10489 UNUSED(end_col_offset); // Only used by EXTRA macro
10490 res = _Py_List ( b , Store , EXTRA );
10491 if (res == NULL && PyErr_Occurred()) {
10492 p->error_indicator = 1;
10493 return NULL;
10494 }
10495 goto done;
10496 }
10497 p->mark = mark;
10498 }
10499 res = NULL;
10500 done:
10501 return res;
10502}
10503
10504// incorrect_arguments:
10505// | args ',' '*'
10506// | expression for_if_clauses ',' [args | expression for_if_clauses]
10507// | args ',' args
10508static void *
10509incorrect_arguments_rule(Parser *p)
10510{
10511 if (p->error_indicator) {
10512 return NULL;
10513 }
10514 void * res = NULL;
10515 int mark = p->mark;
10516 { // args ',' '*'
10517 expr_ty args_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010518 Token * literal;
10519 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010520 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010521 (args_var = args_rule(p)) // args
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010522 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010523 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010524 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010525 (literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010526 )
10527 {
10528 res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" );
10529 if (res == NULL && PyErr_Occurred()) {
10530 p->error_indicator = 1;
10531 return NULL;
10532 }
10533 goto done;
10534 }
10535 p->mark = mark;
10536 }
10537 { // expression for_if_clauses ',' [args | expression for_if_clauses]
10538 expr_ty expression_var;
10539 asdl_seq* for_if_clauses_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010540 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010541 void *opt_var;
10542 UNUSED(opt_var); // Silence compiler warnings
10543 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010544 (expression_var = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010545 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010546 (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010547 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010548 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010549 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010550 (opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses]
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010551 )
10552 {
10553 res = RAISE_SYNTAX_ERROR ( "Generator expression must be parenthesized" );
10554 if (res == NULL && PyErr_Occurred()) {
10555 p->error_indicator = 1;
10556 return NULL;
10557 }
10558 goto done;
10559 }
10560 p->mark = mark;
10561 }
10562 { // args ',' args
10563 expr_ty a;
10564 expr_ty args_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010565 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010566 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010567 (a = args_rule(p)) // args
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010568 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010569 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010570 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010571 (args_var = args_rule(p)) // args
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010572 )
10573 {
10574 res = _PyPegen_arguments_parsing_error ( p , a );
10575 if (res == NULL && PyErr_Occurred()) {
10576 p->error_indicator = 1;
10577 return NULL;
10578 }
10579 goto done;
10580 }
10581 p->mark = mark;
10582 }
10583 res = NULL;
10584 done:
10585 return res;
10586}
10587
Lysandros Nikolaou4638c642020-05-07 13:44:06 +030010588// invalid_kwarg: expression '='
10589static void *
10590invalid_kwarg_rule(Parser *p)
10591{
10592 if (p->error_indicator) {
10593 return NULL;
10594 }
10595 void * res = NULL;
10596 int mark = p->mark;
10597 { // expression '='
10598 expr_ty expression_var;
10599 Token * literal;
10600 if (
10601 (expression_var = expression_rule(p)) // expression
10602 &&
10603 (literal = _PyPegen_expect_token(p, 22)) // token='='
10604 )
10605 {
10606 res = RAISE_SYNTAX_ERROR ( "expression cannot contain assignment, perhaps you meant \"==\"?" );
10607 if (res == NULL && PyErr_Occurred()) {
10608 p->error_indicator = 1;
10609 return NULL;
10610 }
10611 goto done;
10612 }
10613 p->mark = mark;
10614 }
10615 res = NULL;
10616 done:
10617 return res;
10618}
10619
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010620// invalid_named_expression: expression ':=' expression
10621static void *
10622invalid_named_expression_rule(Parser *p)
10623{
10624 if (p->error_indicator) {
10625 return NULL;
10626 }
10627 void * res = NULL;
10628 int mark = p->mark;
10629 { // expression ':=' expression
10630 expr_ty a;
10631 expr_ty expression_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010632 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010633 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010634 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010635 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010636 (literal = _PyPegen_expect_token(p, 53)) // token=':='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010637 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010638 (expression_var = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010639 )
10640 {
10641 res = RAISE_SYNTAX_ERROR ( "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) );
10642 if (res == NULL && PyErr_Occurred()) {
10643 p->error_indicator = 1;
10644 return NULL;
10645 }
10646 goto done;
10647 }
10648 p->mark = mark;
10649 }
10650 res = NULL;
10651 done:
10652 return res;
10653}
10654
10655// invalid_assignment:
10656// | list ':'
10657// | tuple ':'
10658// | expression ':' expression ['=' annotated_rhs]
10659// | expression ('=' | augassign) (yield_expr | star_expressions)
10660static void *
10661invalid_assignment_rule(Parser *p)
10662{
10663 if (p->error_indicator) {
10664 return NULL;
10665 }
10666 void * res = NULL;
10667 int mark = p->mark;
10668 { // list ':'
10669 expr_ty list_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010670 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010671 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010672 (list_var = list_rule(p)) // list
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010673 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010674 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010675 )
10676 {
10677 res = RAISE_SYNTAX_ERROR ( "only single target (not list) can be annotated" );
10678 if (res == NULL && PyErr_Occurred()) {
10679 p->error_indicator = 1;
10680 return NULL;
10681 }
10682 goto done;
10683 }
10684 p->mark = mark;
10685 }
10686 { // tuple ':'
Pablo Galindob796b3f2020-05-01 12:32:26 +010010687 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010688 expr_ty tuple_var;
10689 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010690 (tuple_var = tuple_rule(p)) // tuple
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010691 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010692 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010693 )
10694 {
10695 res = RAISE_SYNTAX_ERROR ( "only single target (not tuple) can be annotated" );
10696 if (res == NULL && PyErr_Occurred()) {
10697 p->error_indicator = 1;
10698 return NULL;
10699 }
10700 goto done;
10701 }
10702 p->mark = mark;
10703 }
10704 { // expression ':' expression ['=' annotated_rhs]
10705 expr_ty expression_var;
10706 expr_ty expression_var_1;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010707 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010708 void *opt_var;
10709 UNUSED(opt_var); // Silence compiler warnings
10710 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010711 (expression_var = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010712 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010713 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010714 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010715 (expression_var_1 = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010716 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010717 (opt_var = _tmp_126_rule(p), 1) // ['=' annotated_rhs]
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010718 )
10719 {
10720 res = RAISE_SYNTAX_ERROR ( "illegal target for annotation" );
10721 if (res == NULL && PyErr_Occurred()) {
10722 p->error_indicator = 1;
10723 return NULL;
10724 }
10725 goto done;
10726 }
10727 p->mark = mark;
10728 }
10729 { // expression ('=' | augassign) (yield_expr | star_expressions)
Guido van Rossum3941d972020-05-01 09:42:03 -070010730 void *_tmp_127_var;
10731 void *_tmp_128_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010732 expr_ty a;
10733 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010734 (a = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010735 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010736 (_tmp_127_var = _tmp_127_rule(p)) // '=' | augassign
Pablo Galindo2b74c832020-04-27 18:02:07 +010010737 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010738 (_tmp_128_var = _tmp_128_rule(p)) // yield_expr | star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010739 )
10740 {
Batuhan Taskaya76c1b4d2020-05-01 16:13:43 +030010741 res = RAISE_SYNTAX_ERROR_NO_COL_OFFSET ( "cannot assign to %s" , _PyPegen_get_expr_name ( a ) );
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010742 if (res == NULL && PyErr_Occurred()) {
10743 p->error_indicator = 1;
10744 return NULL;
10745 }
10746 goto done;
10747 }
10748 p->mark = mark;
10749 }
10750 res = NULL;
10751 done:
10752 return res;
10753}
10754
10755// invalid_block: NEWLINE !INDENT
10756static void *
10757invalid_block_rule(Parser *p)
10758{
10759 if (p->error_indicator) {
10760 return NULL;
10761 }
10762 void * res = NULL;
10763 int mark = p->mark;
10764 { // NEWLINE !INDENT
Pablo Galindob796b3f2020-05-01 12:32:26 +010010765 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010766 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010767 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010768 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010769 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010770 )
10771 {
10772 res = RAISE_INDENTATION_ERROR ( "expected an indented block" );
10773 if (res == NULL && PyErr_Occurred()) {
10774 p->error_indicator = 1;
10775 return NULL;
10776 }
10777 goto done;
10778 }
10779 p->mark = mark;
10780 }
10781 res = NULL;
10782 done:
10783 return res;
10784}
10785
10786// invalid_comprehension: ('[' | '(' | '{') '*' expression for_if_clauses
10787static void *
10788invalid_comprehension_rule(Parser *p)
10789{
10790 if (p->error_indicator) {
10791 return NULL;
10792 }
10793 void * res = NULL;
10794 int mark = p->mark;
10795 { // ('[' | '(' | '{') '*' expression for_if_clauses
Guido van Rossum3941d972020-05-01 09:42:03 -070010796 void *_tmp_129_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010797 expr_ty expression_var;
10798 asdl_seq* for_if_clauses_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010010799 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010800 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010801 (_tmp_129_var = _tmp_129_rule(p)) // '[' | '(' | '{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010802 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010803 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010804 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010805 (expression_var = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010806 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010807 (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010808 )
10809 {
10810 res = RAISE_SYNTAX_ERROR ( "iterable unpacking cannot be used in comprehension" );
10811 if (res == NULL && PyErr_Occurred()) {
10812 p->error_indicator = 1;
10813 return NULL;
10814 }
10815 goto done;
10816 }
10817 p->mark = mark;
10818 }
10819 res = NULL;
10820 done:
10821 return res;
10822}
10823
10824// invalid_parameters:
Guido van Rossumc001c092020-04-30 12:12:19 -070010825// | param_no_default* (slash_with_default | param_with_default+) param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010826static void *
10827invalid_parameters_rule(Parser *p)
10828{
10829 if (p->error_indicator) {
10830 return NULL;
10831 }
10832 void * res = NULL;
10833 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070010834 { // param_no_default* (slash_with_default | param_with_default+) param_no_default
Guido van Rossum3941d972020-05-01 09:42:03 -070010835 asdl_seq * _loop0_130_var;
10836 void *_tmp_131_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070010837 arg_ty param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010838 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010839 (_loop0_130_var = _loop0_130_rule(p)) // param_no_default*
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010840 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010841 (_tmp_131_var = _tmp_131_rule(p)) // slash_with_default | param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010842 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010843 (param_no_default_var = param_no_default_rule(p)) // param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010844 )
10845 {
10846 res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" );
10847 if (res == NULL && PyErr_Occurred()) {
10848 p->error_indicator = 1;
10849 return NULL;
10850 }
10851 goto done;
10852 }
10853 p->mark = mark;
10854 }
10855 res = NULL;
10856 done:
10857 return res;
10858}
10859
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030010860// invalid_star_etc: '*' (')' | ',' (')' | '**'))
10861static void *
10862invalid_star_etc_rule(Parser *p)
10863{
10864 if (p->error_indicator) {
10865 return NULL;
10866 }
10867 void * res = NULL;
10868 int mark = p->mark;
10869 { // '*' (')' | ',' (')' | '**'))
10870 void *_tmp_132_var;
10871 Token * literal;
10872 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010873 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030010874 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010875 (_tmp_132_var = _tmp_132_rule(p)) // ')' | ',' (')' | '**')
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030010876 )
10877 {
10878 res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
10879 if (res == NULL && PyErr_Occurred()) {
10880 p->error_indicator = 1;
10881 return NULL;
10882 }
10883 goto done;
10884 }
10885 p->mark = mark;
10886 }
10887 res = NULL;
10888 done:
10889 return res;
10890}
10891
10892// invalid_lambda_star_etc: '*' (':' | ',' (':' | '**'))
10893static void *
10894invalid_lambda_star_etc_rule(Parser *p)
10895{
10896 if (p->error_indicator) {
10897 return NULL;
10898 }
10899 void * res = NULL;
10900 int mark = p->mark;
10901 { // '*' (':' | ',' (':' | '**'))
10902 void *_tmp_133_var;
10903 Token * literal;
10904 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010905 (literal = _PyPegen_expect_token(p, 16)) // token='*'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030010906 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010907 (_tmp_133_var = _tmp_133_rule(p)) // ':' | ',' (':' | '**')
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030010908 )
10909 {
10910 res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
10911 if (res == NULL && PyErr_Occurred()) {
10912 p->error_indicator = 1;
10913 return NULL;
10914 }
10915 goto done;
10916 }
10917 p->mark = mark;
10918 }
10919 res = NULL;
10920 done:
10921 return res;
10922}
10923
Guido van Rossumc001c092020-04-30 12:12:19 -070010924// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
10925static void *
10926invalid_double_type_comments_rule(Parser *p)
10927{
10928 if (p->error_indicator) {
10929 return NULL;
10930 }
10931 void * res = NULL;
10932 int mark = p->mark;
10933 { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
Pablo Galindob796b3f2020-05-01 12:32:26 +010010934 Token * indent_var;
10935 Token * newline_var;
10936 Token * newline_var_1;
10937 Token * type_comment_var;
10938 Token * type_comment_var_1;
Guido van Rossumc001c092020-04-30 12:12:19 -070010939 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010010940 (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
Guido van Rossumc001c092020-04-30 12:12:19 -070010941 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010942 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Guido van Rossumc001c092020-04-30 12:12:19 -070010943 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010944 (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
Guido van Rossumc001c092020-04-30 12:12:19 -070010945 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010946 (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Guido van Rossumc001c092020-04-30 12:12:19 -070010947 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010010948 (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
Guido van Rossumc001c092020-04-30 12:12:19 -070010949 )
10950 {
10951 res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" );
10952 if (res == NULL && PyErr_Occurred()) {
10953 p->error_indicator = 1;
10954 return NULL;
10955 }
10956 goto done;
10957 }
10958 p->mark = mark;
10959 }
10960 res = NULL;
10961 done:
10962 return res;
10963}
10964
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010965// _loop0_1: NEWLINE
10966static asdl_seq *
10967_loop0_1_rule(Parser *p)
10968{
10969 if (p->error_indicator) {
10970 return NULL;
10971 }
10972 void *res = NULL;
10973 int mark = p->mark;
10974 int start_mark = p->mark;
10975 void **children = PyMem_Malloc(sizeof(void *));
10976 if (!children) {
10977 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
10978 return NULL;
10979 }
10980 ssize_t children_capacity = 1;
10981 ssize_t n = 0;
10982 { // NEWLINE
Pablo Galindob796b3f2020-05-01 12:32:26 +010010983 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010984 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010010985 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010010986 )
10987 {
10988 res = newline_var;
10989 if (n == children_capacity) {
10990 children_capacity *= 2;
10991 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
10992 if (!children) {
10993 PyErr_Format(PyExc_MemoryError, "realloc None");
10994 return NULL;
10995 }
10996 }
10997 children[n++] = res;
10998 mark = p->mark;
10999 }
11000 p->mark = mark;
11001 }
11002 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11003 if (!seq) {
11004 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1");
11005 PyMem_Free(children);
11006 return NULL;
11007 }
11008 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11009 PyMem_Free(children);
11010 _PyPegen_insert_memo(p, start_mark, _loop0_1_type, seq);
11011 return seq;
11012}
11013
Guido van Rossumc001c092020-04-30 12:12:19 -070011014// _loop0_2: NEWLINE
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011015static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011016_loop0_2_rule(Parser *p)
11017{
11018 if (p->error_indicator) {
11019 return NULL;
11020 }
11021 void *res = NULL;
11022 int mark = p->mark;
11023 int start_mark = p->mark;
11024 void **children = PyMem_Malloc(sizeof(void *));
11025 if (!children) {
11026 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11027 return NULL;
11028 }
11029 ssize_t children_capacity = 1;
11030 ssize_t n = 0;
11031 { // NEWLINE
Pablo Galindob796b3f2020-05-01 12:32:26 +010011032 Token * newline_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070011033 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011034 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Guido van Rossumc001c092020-04-30 12:12:19 -070011035 )
11036 {
11037 res = newline_var;
11038 if (n == children_capacity) {
11039 children_capacity *= 2;
11040 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11041 if (!children) {
11042 PyErr_Format(PyExc_MemoryError, "realloc None");
11043 return NULL;
11044 }
11045 }
11046 children[n++] = res;
11047 mark = p->mark;
11048 }
11049 p->mark = mark;
11050 }
11051 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11052 if (!seq) {
11053 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2");
11054 PyMem_Free(children);
11055 return NULL;
11056 }
11057 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11058 PyMem_Free(children);
11059 _PyPegen_insert_memo(p, start_mark, _loop0_2_type, seq);
11060 return seq;
11061}
11062
11063// _loop0_4: ',' expression
11064static asdl_seq *
11065_loop0_4_rule(Parser *p)
11066{
11067 if (p->error_indicator) {
11068 return NULL;
11069 }
11070 void *res = NULL;
11071 int mark = p->mark;
11072 int start_mark = p->mark;
11073 void **children = PyMem_Malloc(sizeof(void *));
11074 if (!children) {
11075 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11076 return NULL;
11077 }
11078 ssize_t children_capacity = 1;
11079 ssize_t n = 0;
11080 { // ',' expression
11081 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011082 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011083 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011084 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070011085 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011086 (elem = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070011087 )
11088 {
11089 res = elem;
11090 if (res == NULL && PyErr_Occurred()) {
11091 p->error_indicator = 1;
11092 PyMem_Free(children);
11093 return NULL;
11094 }
11095 if (n == children_capacity) {
11096 children_capacity *= 2;
11097 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11098 if (!children) {
11099 PyErr_Format(PyExc_MemoryError, "realloc None");
11100 return NULL;
11101 }
11102 }
11103 children[n++] = res;
11104 mark = p->mark;
11105 }
11106 p->mark = mark;
11107 }
11108 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11109 if (!seq) {
11110 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4");
11111 PyMem_Free(children);
11112 return NULL;
11113 }
11114 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11115 PyMem_Free(children);
11116 _PyPegen_insert_memo(p, start_mark, _loop0_4_type, seq);
11117 return seq;
11118}
11119
11120// _gather_3: expression _loop0_4
11121static asdl_seq *
11122_gather_3_rule(Parser *p)
11123{
11124 if (p->error_indicator) {
11125 return NULL;
11126 }
11127 asdl_seq * res = NULL;
11128 int mark = p->mark;
11129 { // expression _loop0_4
11130 expr_ty elem;
11131 asdl_seq * seq;
11132 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011133 (elem = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070011134 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011135 (seq = _loop0_4_rule(p)) // _loop0_4
Guido van Rossumc001c092020-04-30 12:12:19 -070011136 )
11137 {
11138 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11139 goto done;
11140 }
11141 p->mark = mark;
11142 }
11143 res = NULL;
11144 done:
11145 return res;
11146}
11147
11148// _loop0_6: ',' expression
11149static asdl_seq *
11150_loop0_6_rule(Parser *p)
11151{
11152 if (p->error_indicator) {
11153 return NULL;
11154 }
11155 void *res = NULL;
11156 int mark = p->mark;
11157 int start_mark = p->mark;
11158 void **children = PyMem_Malloc(sizeof(void *));
11159 if (!children) {
11160 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11161 return NULL;
11162 }
11163 ssize_t children_capacity = 1;
11164 ssize_t n = 0;
11165 { // ',' expression
11166 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011167 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011168 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011169 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070011170 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011171 (elem = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070011172 )
11173 {
11174 res = elem;
11175 if (res == NULL && PyErr_Occurred()) {
11176 p->error_indicator = 1;
11177 PyMem_Free(children);
11178 return NULL;
11179 }
11180 if (n == children_capacity) {
11181 children_capacity *= 2;
11182 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11183 if (!children) {
11184 PyErr_Format(PyExc_MemoryError, "realloc None");
11185 return NULL;
11186 }
11187 }
11188 children[n++] = res;
11189 mark = p->mark;
11190 }
11191 p->mark = mark;
11192 }
11193 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11194 if (!seq) {
11195 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6");
11196 PyMem_Free(children);
11197 return NULL;
11198 }
11199 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11200 PyMem_Free(children);
11201 _PyPegen_insert_memo(p, start_mark, _loop0_6_type, seq);
11202 return seq;
11203}
11204
11205// _gather_5: expression _loop0_6
11206static asdl_seq *
11207_gather_5_rule(Parser *p)
11208{
11209 if (p->error_indicator) {
11210 return NULL;
11211 }
11212 asdl_seq * res = NULL;
11213 int mark = p->mark;
11214 { // expression _loop0_6
11215 expr_ty elem;
11216 asdl_seq * seq;
11217 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011218 (elem = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070011219 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011220 (seq = _loop0_6_rule(p)) // _loop0_6
Guido van Rossumc001c092020-04-30 12:12:19 -070011221 )
11222 {
11223 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11224 goto done;
11225 }
11226 p->mark = mark;
11227 }
11228 res = NULL;
11229 done:
11230 return res;
11231}
11232
11233// _loop0_8: ',' expression
11234static asdl_seq *
11235_loop0_8_rule(Parser *p)
11236{
11237 if (p->error_indicator) {
11238 return NULL;
11239 }
11240 void *res = NULL;
11241 int mark = p->mark;
11242 int start_mark = p->mark;
11243 void **children = PyMem_Malloc(sizeof(void *));
11244 if (!children) {
11245 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11246 return NULL;
11247 }
11248 ssize_t children_capacity = 1;
11249 ssize_t n = 0;
11250 { // ',' expression
11251 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011252 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011253 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011254 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070011255 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011256 (elem = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070011257 )
11258 {
11259 res = elem;
11260 if (res == NULL && PyErr_Occurred()) {
11261 p->error_indicator = 1;
11262 PyMem_Free(children);
11263 return NULL;
11264 }
11265 if (n == children_capacity) {
11266 children_capacity *= 2;
11267 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11268 if (!children) {
11269 PyErr_Format(PyExc_MemoryError, "realloc None");
11270 return NULL;
11271 }
11272 }
11273 children[n++] = res;
11274 mark = p->mark;
11275 }
11276 p->mark = mark;
11277 }
11278 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11279 if (!seq) {
11280 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8");
11281 PyMem_Free(children);
11282 return NULL;
11283 }
11284 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11285 PyMem_Free(children);
11286 _PyPegen_insert_memo(p, start_mark, _loop0_8_type, seq);
11287 return seq;
11288}
11289
11290// _gather_7: expression _loop0_8
11291static asdl_seq *
11292_gather_7_rule(Parser *p)
11293{
11294 if (p->error_indicator) {
11295 return NULL;
11296 }
11297 asdl_seq * res = NULL;
11298 int mark = p->mark;
11299 { // expression _loop0_8
11300 expr_ty elem;
11301 asdl_seq * seq;
11302 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011303 (elem = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070011304 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011305 (seq = _loop0_8_rule(p)) // _loop0_8
Guido van Rossumc001c092020-04-30 12:12:19 -070011306 )
11307 {
11308 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11309 goto done;
11310 }
11311 p->mark = mark;
11312 }
11313 res = NULL;
11314 done:
11315 return res;
11316}
11317
11318// _loop0_10: ',' expression
11319static asdl_seq *
11320_loop0_10_rule(Parser *p)
11321{
11322 if (p->error_indicator) {
11323 return NULL;
11324 }
11325 void *res = NULL;
11326 int mark = p->mark;
11327 int start_mark = p->mark;
11328 void **children = PyMem_Malloc(sizeof(void *));
11329 if (!children) {
11330 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11331 return NULL;
11332 }
11333 ssize_t children_capacity = 1;
11334 ssize_t n = 0;
11335 { // ',' expression
11336 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011337 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011338 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011339 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070011340 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011341 (elem = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070011342 )
11343 {
11344 res = elem;
11345 if (res == NULL && PyErr_Occurred()) {
11346 p->error_indicator = 1;
11347 PyMem_Free(children);
11348 return NULL;
11349 }
11350 if (n == children_capacity) {
11351 children_capacity *= 2;
11352 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11353 if (!children) {
11354 PyErr_Format(PyExc_MemoryError, "realloc None");
11355 return NULL;
11356 }
11357 }
11358 children[n++] = res;
11359 mark = p->mark;
11360 }
11361 p->mark = mark;
11362 }
11363 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11364 if (!seq) {
11365 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10");
11366 PyMem_Free(children);
11367 return NULL;
11368 }
11369 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11370 PyMem_Free(children);
11371 _PyPegen_insert_memo(p, start_mark, _loop0_10_type, seq);
11372 return seq;
11373}
11374
11375// _gather_9: expression _loop0_10
11376static asdl_seq *
11377_gather_9_rule(Parser *p)
11378{
11379 if (p->error_indicator) {
11380 return NULL;
11381 }
11382 asdl_seq * res = NULL;
11383 int mark = p->mark;
11384 { // expression _loop0_10
11385 expr_ty elem;
11386 asdl_seq * seq;
11387 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011388 (elem = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070011389 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011390 (seq = _loop0_10_rule(p)) // _loop0_10
Guido van Rossumc001c092020-04-30 12:12:19 -070011391 )
11392 {
11393 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11394 goto done;
11395 }
11396 p->mark = mark;
11397 }
11398 res = NULL;
11399 done:
11400 return res;
11401}
11402
11403// _loop1_11: statement
11404static asdl_seq *
11405_loop1_11_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011406{
11407 if (p->error_indicator) {
11408 return NULL;
11409 }
11410 void *res = NULL;
11411 int mark = p->mark;
11412 int start_mark = p->mark;
11413 void **children = PyMem_Malloc(sizeof(void *));
11414 if (!children) {
11415 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11416 return NULL;
11417 }
11418 ssize_t children_capacity = 1;
11419 ssize_t n = 0;
11420 { // statement
11421 asdl_seq* statement_var;
11422 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011423 (statement_var = statement_rule(p)) // statement
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011424 )
11425 {
11426 res = statement_var;
11427 if (n == children_capacity) {
11428 children_capacity *= 2;
11429 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11430 if (!children) {
11431 PyErr_Format(PyExc_MemoryError, "realloc None");
11432 return NULL;
11433 }
11434 }
11435 children[n++] = res;
11436 mark = p->mark;
11437 }
11438 p->mark = mark;
11439 }
11440 if (n == 0) {
11441 PyMem_Free(children);
11442 return NULL;
11443 }
11444 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11445 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070011446 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011447 PyMem_Free(children);
11448 return NULL;
11449 }
11450 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11451 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070011452 _PyPegen_insert_memo(p, start_mark, _loop1_11_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011453 return seq;
11454}
11455
Guido van Rossumc001c092020-04-30 12:12:19 -070011456// _loop0_13: ';' small_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011457static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011458_loop0_13_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011459{
11460 if (p->error_indicator) {
11461 return NULL;
11462 }
11463 void *res = NULL;
11464 int mark = p->mark;
11465 int start_mark = p->mark;
11466 void **children = PyMem_Malloc(sizeof(void *));
11467 if (!children) {
11468 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11469 return NULL;
11470 }
11471 ssize_t children_capacity = 1;
11472 ssize_t n = 0;
11473 { // ';' small_stmt
11474 stmt_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011475 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011476 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011477 (literal = _PyPegen_expect_token(p, 13)) // token=';'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011478 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011479 (elem = small_stmt_rule(p)) // small_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011480 )
11481 {
11482 res = elem;
11483 if (res == NULL && PyErr_Occurred()) {
11484 p->error_indicator = 1;
11485 PyMem_Free(children);
11486 return NULL;
11487 }
11488 if (n == children_capacity) {
11489 children_capacity *= 2;
11490 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11491 if (!children) {
11492 PyErr_Format(PyExc_MemoryError, "realloc None");
11493 return NULL;
11494 }
11495 }
11496 children[n++] = res;
11497 mark = p->mark;
11498 }
11499 p->mark = mark;
11500 }
11501 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11502 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070011503 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011504 PyMem_Free(children);
11505 return NULL;
11506 }
11507 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11508 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070011509 _PyPegen_insert_memo(p, start_mark, _loop0_13_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011510 return seq;
11511}
11512
Guido van Rossumc001c092020-04-30 12:12:19 -070011513// _gather_12: small_stmt _loop0_13
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011514static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011515_gather_12_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011516{
11517 if (p->error_indicator) {
11518 return NULL;
11519 }
11520 asdl_seq * res = NULL;
11521 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070011522 { // small_stmt _loop0_13
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011523 stmt_ty elem;
11524 asdl_seq * seq;
11525 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011526 (elem = small_stmt_rule(p)) // small_stmt
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011527 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011528 (seq = _loop0_13_rule(p)) // _loop0_13
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011529 )
11530 {
11531 res = _PyPegen_seq_insert_in_front(p, elem, seq);
11532 goto done;
11533 }
11534 p->mark = mark;
11535 }
11536 res = NULL;
11537 done:
11538 return res;
11539}
11540
Guido van Rossumc001c092020-04-30 12:12:19 -070011541// _tmp_14: 'import' | 'from'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011542static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011543_tmp_14_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011544{
11545 if (p->error_indicator) {
11546 return NULL;
11547 }
11548 void * res = NULL;
11549 int mark = p->mark;
11550 { // 'import'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011551 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011552 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011553 (keyword = _PyPegen_expect_token(p, 513)) // token='import'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011554 )
11555 {
11556 res = keyword;
11557 goto done;
11558 }
11559 p->mark = mark;
11560 }
11561 { // 'from'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011562 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011563 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011564 (keyword = _PyPegen_expect_token(p, 514)) // token='from'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011565 )
11566 {
11567 res = keyword;
11568 goto done;
11569 }
11570 p->mark = mark;
11571 }
11572 res = NULL;
11573 done:
11574 return res;
11575}
11576
Guido van Rossumc001c092020-04-30 12:12:19 -070011577// _tmp_15: 'def' | '@' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011578static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011579_tmp_15_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011580{
11581 if (p->error_indicator) {
11582 return NULL;
11583 }
11584 void * res = NULL;
11585 int mark = p->mark;
11586 { // 'def'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011587 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011588 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011589 (keyword = _PyPegen_expect_token(p, 522)) // token='def'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011590 )
11591 {
11592 res = keyword;
11593 goto done;
11594 }
11595 p->mark = mark;
11596 }
11597 { // '@'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011598 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011599 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011600 (literal = _PyPegen_expect_token(p, 49)) // token='@'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011601 )
11602 {
11603 res = literal;
11604 goto done;
11605 }
11606 p->mark = mark;
11607 }
11608 { // ASYNC
Pablo Galindob796b3f2020-05-01 12:32:26 +010011609 Token * async_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011610 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011611 (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011612 )
11613 {
11614 res = async_var;
11615 goto done;
11616 }
11617 p->mark = mark;
11618 }
11619 res = NULL;
11620 done:
11621 return res;
11622}
11623
Guido van Rossumc001c092020-04-30 12:12:19 -070011624// _tmp_16: 'class' | '@'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011625static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011626_tmp_16_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011627{
11628 if (p->error_indicator) {
11629 return NULL;
11630 }
11631 void * res = NULL;
11632 int mark = p->mark;
11633 { // 'class'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011634 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011635 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011636 (keyword = _PyPegen_expect_token(p, 523)) // token='class'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011637 )
11638 {
11639 res = keyword;
11640 goto done;
11641 }
11642 p->mark = mark;
11643 }
11644 { // '@'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011645 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011646 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011647 (literal = _PyPegen_expect_token(p, 49)) // token='@'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011648 )
11649 {
11650 res = literal;
11651 goto done;
11652 }
11653 p->mark = mark;
11654 }
11655 res = NULL;
11656 done:
11657 return res;
11658}
11659
Guido van Rossumc001c092020-04-30 12:12:19 -070011660// _tmp_17: 'with' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011661static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011662_tmp_17_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011663{
11664 if (p->error_indicator) {
11665 return NULL;
11666 }
11667 void * res = NULL;
11668 int mark = p->mark;
11669 { // 'with'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011670 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011671 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011672 (keyword = _PyPegen_expect_token(p, 519)) // token='with'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011673 )
11674 {
11675 res = keyword;
11676 goto done;
11677 }
11678 p->mark = mark;
11679 }
11680 { // ASYNC
Pablo Galindob796b3f2020-05-01 12:32:26 +010011681 Token * async_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011682 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011683 (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011684 )
11685 {
11686 res = async_var;
11687 goto done;
11688 }
11689 p->mark = mark;
11690 }
11691 res = NULL;
11692 done:
11693 return res;
11694}
11695
Guido van Rossumc001c092020-04-30 12:12:19 -070011696// _tmp_18: 'for' | ASYNC
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011697static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011698_tmp_18_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011699{
11700 if (p->error_indicator) {
11701 return NULL;
11702 }
11703 void * res = NULL;
11704 int mark = p->mark;
11705 { // 'for'
Pablo Galindob796b3f2020-05-01 12:32:26 +010011706 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011707 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011708 (keyword = _PyPegen_expect_token(p, 517)) // token='for'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011709 )
11710 {
11711 res = keyword;
11712 goto done;
11713 }
11714 p->mark = mark;
11715 }
11716 { // ASYNC
Pablo Galindob796b3f2020-05-01 12:32:26 +010011717 Token * async_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011718 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011719 (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011720 )
11721 {
11722 res = async_var;
11723 goto done;
11724 }
11725 p->mark = mark;
11726 }
11727 res = NULL;
11728 done:
11729 return res;
11730}
11731
Guido van Rossumc001c092020-04-30 12:12:19 -070011732// _tmp_19: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011733static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011734_tmp_19_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011735{
11736 if (p->error_indicator) {
11737 return NULL;
11738 }
11739 void * res = NULL;
11740 int mark = p->mark;
11741 { // '=' annotated_rhs
11742 expr_ty d;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011743 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011744 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011745 (literal = _PyPegen_expect_token(p, 22)) // token='='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011746 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011747 (d = annotated_rhs_rule(p)) // annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011748 )
11749 {
11750 res = d;
11751 if (res == NULL && PyErr_Occurred()) {
11752 p->error_indicator = 1;
11753 return NULL;
11754 }
11755 goto done;
11756 }
11757 p->mark = mark;
11758 }
11759 res = NULL;
11760 done:
11761 return res;
11762}
11763
Guido van Rossumc001c092020-04-30 12:12:19 -070011764// _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011765static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011766_tmp_20_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011767{
11768 if (p->error_indicator) {
11769 return NULL;
11770 }
11771 void * res = NULL;
11772 int mark = p->mark;
11773 { // '(' inside_paren_ann_assign_target ')'
11774 expr_ty b;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011775 Token * literal;
11776 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011777 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011778 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011779 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011780 (b = inside_paren_ann_assign_target_rule(p)) // inside_paren_ann_assign_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011781 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011782 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011783 )
11784 {
11785 res = b;
11786 if (res == NULL && PyErr_Occurred()) {
11787 p->error_indicator = 1;
11788 return NULL;
11789 }
11790 goto done;
11791 }
11792 p->mark = mark;
11793 }
11794 { // ann_assign_subscript_attribute_target
11795 expr_ty ann_assign_subscript_attribute_target_var;
11796 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011797 (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p)) // ann_assign_subscript_attribute_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011798 )
11799 {
11800 res = ann_assign_subscript_attribute_target_var;
11801 goto done;
11802 }
11803 p->mark = mark;
11804 }
11805 res = NULL;
11806 done:
11807 return res;
11808}
11809
Guido van Rossumc001c092020-04-30 12:12:19 -070011810// _tmp_21: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011811static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070011812_tmp_21_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011813{
11814 if (p->error_indicator) {
11815 return NULL;
11816 }
11817 void * res = NULL;
11818 int mark = p->mark;
11819 { // '=' annotated_rhs
11820 expr_ty d;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011821 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011822 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011823 (literal = _PyPegen_expect_token(p, 22)) // token='='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011824 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011825 (d = annotated_rhs_rule(p)) // annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011826 )
11827 {
11828 res = d;
11829 if (res == NULL && PyErr_Occurred()) {
11830 p->error_indicator = 1;
11831 return NULL;
11832 }
11833 goto done;
11834 }
11835 p->mark = mark;
11836 }
11837 res = NULL;
11838 done:
11839 return res;
11840}
11841
Guido van Rossumc001c092020-04-30 12:12:19 -070011842// _loop1_22: (star_targets '=')
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011843static asdl_seq *
11844_loop1_22_rule(Parser *p)
11845{
11846 if (p->error_indicator) {
11847 return NULL;
11848 }
11849 void *res = NULL;
11850 int mark = p->mark;
11851 int start_mark = p->mark;
11852 void **children = PyMem_Malloc(sizeof(void *));
11853 if (!children) {
11854 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11855 return NULL;
11856 }
11857 ssize_t children_capacity = 1;
11858 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070011859 { // (star_targets '=')
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030011860 void *_tmp_134_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011861 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011862 (_tmp_134_var = _tmp_134_rule(p)) // star_targets '='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011863 )
11864 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030011865 res = _tmp_134_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011866 if (n == children_capacity) {
11867 children_capacity *= 2;
11868 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
11869 if (!children) {
11870 PyErr_Format(PyExc_MemoryError, "realloc None");
11871 return NULL;
11872 }
11873 }
11874 children[n++] = res;
11875 mark = p->mark;
11876 }
11877 p->mark = mark;
11878 }
11879 if (n == 0) {
11880 PyMem_Free(children);
11881 return NULL;
11882 }
11883 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
11884 if (!seq) {
11885 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22");
11886 PyMem_Free(children);
11887 return NULL;
11888 }
11889 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
11890 PyMem_Free(children);
11891 _PyPegen_insert_memo(p, start_mark, _loop1_22_type, seq);
11892 return seq;
11893}
11894
Guido van Rossumc001c092020-04-30 12:12:19 -070011895// _tmp_23: yield_expr | star_expressions
11896static void *
11897_tmp_23_rule(Parser *p)
11898{
11899 if (p->error_indicator) {
11900 return NULL;
11901 }
11902 void * res = NULL;
11903 int mark = p->mark;
11904 { // yield_expr
11905 expr_ty yield_expr_var;
11906 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011907 (yield_expr_var = yield_expr_rule(p)) // yield_expr
Guido van Rossumc001c092020-04-30 12:12:19 -070011908 )
11909 {
11910 res = yield_expr_var;
11911 goto done;
11912 }
11913 p->mark = mark;
11914 }
11915 { // star_expressions
11916 expr_ty star_expressions_var;
11917 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011918 (star_expressions_var = star_expressions_rule(p)) // star_expressions
Guido van Rossumc001c092020-04-30 12:12:19 -070011919 )
11920 {
11921 res = star_expressions_var;
11922 goto done;
11923 }
11924 p->mark = mark;
11925 }
11926 res = NULL;
11927 done:
11928 return res;
11929}
11930
11931// _tmp_24: yield_expr | star_expressions
11932static void *
11933_tmp_24_rule(Parser *p)
11934{
11935 if (p->error_indicator) {
11936 return NULL;
11937 }
11938 void * res = NULL;
11939 int mark = p->mark;
11940 { // yield_expr
11941 expr_ty yield_expr_var;
11942 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011943 (yield_expr_var = yield_expr_rule(p)) // yield_expr
Guido van Rossumc001c092020-04-30 12:12:19 -070011944 )
11945 {
11946 res = yield_expr_var;
11947 goto done;
11948 }
11949 p->mark = mark;
11950 }
11951 { // star_expressions
11952 expr_ty star_expressions_var;
11953 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010011954 (star_expressions_var = star_expressions_rule(p)) // star_expressions
Guido van Rossumc001c092020-04-30 12:12:19 -070011955 )
11956 {
11957 res = star_expressions_var;
11958 goto done;
11959 }
11960 p->mark = mark;
11961 }
11962 res = NULL;
11963 done:
11964 return res;
11965}
11966
11967// _loop0_26: ',' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010011968static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070011969_loop0_26_rule(Parser *p)
11970{
11971 if (p->error_indicator) {
11972 return NULL;
11973 }
11974 void *res = NULL;
11975 int mark = p->mark;
11976 int start_mark = p->mark;
11977 void **children = PyMem_Malloc(sizeof(void *));
11978 if (!children) {
11979 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
11980 return NULL;
11981 }
11982 ssize_t children_capacity = 1;
11983 ssize_t n = 0;
11984 { // ',' NAME
11985 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010011986 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070011987 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010011988 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070011989 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010011990 (elem = _PyPegen_name_token(p)) // NAME
Guido van Rossumc001c092020-04-30 12:12:19 -070011991 )
11992 {
11993 res = elem;
11994 if (res == NULL && PyErr_Occurred()) {
11995 p->error_indicator = 1;
11996 PyMem_Free(children);
11997 return NULL;
11998 }
11999 if (n == children_capacity) {
12000 children_capacity *= 2;
12001 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12002 if (!children) {
12003 PyErr_Format(PyExc_MemoryError, "realloc None");
12004 return NULL;
12005 }
12006 }
12007 children[n++] = res;
12008 mark = p->mark;
12009 }
12010 p->mark = mark;
12011 }
12012 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12013 if (!seq) {
12014 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26");
12015 PyMem_Free(children);
12016 return NULL;
12017 }
12018 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12019 PyMem_Free(children);
12020 _PyPegen_insert_memo(p, start_mark, _loop0_26_type, seq);
12021 return seq;
12022}
12023
12024// _gather_25: NAME _loop0_26
12025static asdl_seq *
12026_gather_25_rule(Parser *p)
12027{
12028 if (p->error_indicator) {
12029 return NULL;
12030 }
12031 asdl_seq * res = NULL;
12032 int mark = p->mark;
12033 { // NAME _loop0_26
12034 expr_ty elem;
12035 asdl_seq * seq;
12036 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012037 (elem = _PyPegen_name_token(p)) // NAME
Guido van Rossumc001c092020-04-30 12:12:19 -070012038 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012039 (seq = _loop0_26_rule(p)) // _loop0_26
Guido van Rossumc001c092020-04-30 12:12:19 -070012040 )
12041 {
12042 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12043 goto done;
12044 }
12045 p->mark = mark;
12046 }
12047 res = NULL;
12048 done:
12049 return res;
12050}
12051
12052// _loop0_28: ',' NAME
12053static asdl_seq *
12054_loop0_28_rule(Parser *p)
12055{
12056 if (p->error_indicator) {
12057 return NULL;
12058 }
12059 void *res = NULL;
12060 int mark = p->mark;
12061 int start_mark = p->mark;
12062 void **children = PyMem_Malloc(sizeof(void *));
12063 if (!children) {
12064 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12065 return NULL;
12066 }
12067 ssize_t children_capacity = 1;
12068 ssize_t n = 0;
12069 { // ',' NAME
12070 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012071 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070012072 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012073 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070012074 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012075 (elem = _PyPegen_name_token(p)) // NAME
Guido van Rossumc001c092020-04-30 12:12:19 -070012076 )
12077 {
12078 res = elem;
12079 if (res == NULL && PyErr_Occurred()) {
12080 p->error_indicator = 1;
12081 PyMem_Free(children);
12082 return NULL;
12083 }
12084 if (n == children_capacity) {
12085 children_capacity *= 2;
12086 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12087 if (!children) {
12088 PyErr_Format(PyExc_MemoryError, "realloc None");
12089 return NULL;
12090 }
12091 }
12092 children[n++] = res;
12093 mark = p->mark;
12094 }
12095 p->mark = mark;
12096 }
12097 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12098 if (!seq) {
12099 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28");
12100 PyMem_Free(children);
12101 return NULL;
12102 }
12103 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12104 PyMem_Free(children);
12105 _PyPegen_insert_memo(p, start_mark, _loop0_28_type, seq);
12106 return seq;
12107}
12108
12109// _gather_27: NAME _loop0_28
12110static asdl_seq *
12111_gather_27_rule(Parser *p)
12112{
12113 if (p->error_indicator) {
12114 return NULL;
12115 }
12116 asdl_seq * res = NULL;
12117 int mark = p->mark;
12118 { // NAME _loop0_28
12119 expr_ty elem;
12120 asdl_seq * seq;
12121 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012122 (elem = _PyPegen_name_token(p)) // NAME
Guido van Rossumc001c092020-04-30 12:12:19 -070012123 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012124 (seq = _loop0_28_rule(p)) // _loop0_28
Guido van Rossumc001c092020-04-30 12:12:19 -070012125 )
12126 {
12127 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12128 goto done;
12129 }
12130 p->mark = mark;
12131 }
12132 res = NULL;
12133 done:
12134 return res;
12135}
12136
12137// _tmp_29: ',' expression
12138static void *
12139_tmp_29_rule(Parser *p)
12140{
12141 if (p->error_indicator) {
12142 return NULL;
12143 }
12144 void * res = NULL;
12145 int mark = p->mark;
12146 { // ',' expression
Pablo Galindob796b3f2020-05-01 12:32:26 +010012147 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070012148 expr_ty z;
12149 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012150 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070012151 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012152 (z = expression_rule(p)) // expression
Guido van Rossumc001c092020-04-30 12:12:19 -070012153 )
12154 {
12155 res = z;
12156 if (res == NULL && PyErr_Occurred()) {
12157 p->error_indicator = 1;
12158 return NULL;
12159 }
12160 goto done;
12161 }
12162 p->mark = mark;
12163 }
12164 res = NULL;
12165 done:
12166 return res;
12167}
12168
12169// _loop0_30: ('.' | '...')
12170static asdl_seq *
12171_loop0_30_rule(Parser *p)
12172{
12173 if (p->error_indicator) {
12174 return NULL;
12175 }
12176 void *res = NULL;
12177 int mark = p->mark;
12178 int start_mark = p->mark;
12179 void **children = PyMem_Malloc(sizeof(void *));
12180 if (!children) {
12181 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12182 return NULL;
12183 }
12184 ssize_t children_capacity = 1;
12185 ssize_t n = 0;
12186 { // ('.' | '...')
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012187 void *_tmp_135_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070012188 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012189 (_tmp_135_var = _tmp_135_rule(p)) // '.' | '...'
Guido van Rossumc001c092020-04-30 12:12:19 -070012190 )
12191 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012192 res = _tmp_135_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070012193 if (n == children_capacity) {
12194 children_capacity *= 2;
12195 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12196 if (!children) {
12197 PyErr_Format(PyExc_MemoryError, "realloc None");
12198 return NULL;
12199 }
12200 }
12201 children[n++] = res;
12202 mark = p->mark;
12203 }
12204 p->mark = mark;
12205 }
12206 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12207 if (!seq) {
12208 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30");
12209 PyMem_Free(children);
12210 return NULL;
12211 }
12212 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12213 PyMem_Free(children);
12214 _PyPegen_insert_memo(p, start_mark, _loop0_30_type, seq);
12215 return seq;
12216}
12217
12218// _loop1_31: ('.' | '...')
12219static asdl_seq *
12220_loop1_31_rule(Parser *p)
12221{
12222 if (p->error_indicator) {
12223 return NULL;
12224 }
12225 void *res = NULL;
12226 int mark = p->mark;
12227 int start_mark = p->mark;
12228 void **children = PyMem_Malloc(sizeof(void *));
12229 if (!children) {
12230 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12231 return NULL;
12232 }
12233 ssize_t children_capacity = 1;
12234 ssize_t n = 0;
12235 { // ('.' | '...')
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012236 void *_tmp_136_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070012237 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012238 (_tmp_136_var = _tmp_136_rule(p)) // '.' | '...'
Guido van Rossumc001c092020-04-30 12:12:19 -070012239 )
12240 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030012241 res = _tmp_136_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070012242 if (n == children_capacity) {
12243 children_capacity *= 2;
12244 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12245 if (!children) {
12246 PyErr_Format(PyExc_MemoryError, "realloc None");
12247 return NULL;
12248 }
12249 }
12250 children[n++] = res;
12251 mark = p->mark;
12252 }
12253 p->mark = mark;
12254 }
12255 if (n == 0) {
12256 PyMem_Free(children);
12257 return NULL;
12258 }
12259 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12260 if (!seq) {
12261 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31");
12262 PyMem_Free(children);
12263 return NULL;
12264 }
12265 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12266 PyMem_Free(children);
12267 _PyPegen_insert_memo(p, start_mark, _loop1_31_type, seq);
12268 return seq;
12269}
12270
12271// _loop0_33: ',' import_from_as_name
12272static asdl_seq *
12273_loop0_33_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012274{
12275 if (p->error_indicator) {
12276 return NULL;
12277 }
12278 void *res = NULL;
12279 int mark = p->mark;
12280 int start_mark = p->mark;
12281 void **children = PyMem_Malloc(sizeof(void *));
12282 if (!children) {
12283 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12284 return NULL;
12285 }
12286 ssize_t children_capacity = 1;
12287 ssize_t n = 0;
12288 { // ',' import_from_as_name
12289 alias_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012290 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012291 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012292 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012293 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012294 (elem = import_from_as_name_rule(p)) // import_from_as_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012295 )
12296 {
12297 res = elem;
12298 if (res == NULL && PyErr_Occurred()) {
12299 p->error_indicator = 1;
12300 PyMem_Free(children);
12301 return NULL;
12302 }
12303 if (n == children_capacity) {
12304 children_capacity *= 2;
12305 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12306 if (!children) {
12307 PyErr_Format(PyExc_MemoryError, "realloc None");
12308 return NULL;
12309 }
12310 }
12311 children[n++] = res;
12312 mark = p->mark;
12313 }
12314 p->mark = mark;
12315 }
12316 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12317 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012318 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012319 PyMem_Free(children);
12320 return NULL;
12321 }
12322 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12323 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012324 _PyPegen_insert_memo(p, start_mark, _loop0_33_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012325 return seq;
12326}
12327
Guido van Rossumc001c092020-04-30 12:12:19 -070012328// _gather_32: import_from_as_name _loop0_33
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012329static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012330_gather_32_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012331{
12332 if (p->error_indicator) {
12333 return NULL;
12334 }
12335 asdl_seq * res = NULL;
12336 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012337 { // import_from_as_name _loop0_33
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012338 alias_ty elem;
12339 asdl_seq * seq;
12340 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012341 (elem = import_from_as_name_rule(p)) // import_from_as_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012342 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012343 (seq = _loop0_33_rule(p)) // _loop0_33
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012344 )
12345 {
12346 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12347 goto done;
12348 }
12349 p->mark = mark;
12350 }
12351 res = NULL;
12352 done:
12353 return res;
12354}
12355
Guido van Rossumc001c092020-04-30 12:12:19 -070012356// _tmp_34: 'as' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012357static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070012358_tmp_34_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012359{
12360 if (p->error_indicator) {
12361 return NULL;
12362 }
12363 void * res = NULL;
12364 int mark = p->mark;
12365 { // 'as' NAME
Pablo Galindob796b3f2020-05-01 12:32:26 +010012366 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012367 expr_ty z;
12368 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012369 (keyword = _PyPegen_expect_token(p, 531)) // token='as'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012370 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012371 (z = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012372 )
12373 {
12374 res = z;
12375 if (res == NULL && PyErr_Occurred()) {
12376 p->error_indicator = 1;
12377 return NULL;
12378 }
12379 goto done;
12380 }
12381 p->mark = mark;
12382 }
12383 res = NULL;
12384 done:
12385 return res;
12386}
12387
Guido van Rossumc001c092020-04-30 12:12:19 -070012388// _loop0_36: ',' dotted_as_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012389static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012390_loop0_36_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012391{
12392 if (p->error_indicator) {
12393 return NULL;
12394 }
12395 void *res = NULL;
12396 int mark = p->mark;
12397 int start_mark = p->mark;
12398 void **children = PyMem_Malloc(sizeof(void *));
12399 if (!children) {
12400 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12401 return NULL;
12402 }
12403 ssize_t children_capacity = 1;
12404 ssize_t n = 0;
12405 { // ',' dotted_as_name
12406 alias_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012407 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012408 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012409 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012410 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012411 (elem = dotted_as_name_rule(p)) // dotted_as_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012412 )
12413 {
12414 res = elem;
12415 if (res == NULL && PyErr_Occurred()) {
12416 p->error_indicator = 1;
12417 PyMem_Free(children);
12418 return NULL;
12419 }
12420 if (n == children_capacity) {
12421 children_capacity *= 2;
12422 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12423 if (!children) {
12424 PyErr_Format(PyExc_MemoryError, "realloc None");
12425 return NULL;
12426 }
12427 }
12428 children[n++] = res;
12429 mark = p->mark;
12430 }
12431 p->mark = mark;
12432 }
12433 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12434 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012435 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012436 PyMem_Free(children);
12437 return NULL;
12438 }
12439 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12440 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012441 _PyPegen_insert_memo(p, start_mark, _loop0_36_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012442 return seq;
12443}
12444
Guido van Rossumc001c092020-04-30 12:12:19 -070012445// _gather_35: dotted_as_name _loop0_36
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012446static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012447_gather_35_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012448{
12449 if (p->error_indicator) {
12450 return NULL;
12451 }
12452 asdl_seq * res = NULL;
12453 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012454 { // dotted_as_name _loop0_36
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012455 alias_ty elem;
12456 asdl_seq * seq;
12457 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012458 (elem = dotted_as_name_rule(p)) // dotted_as_name
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012459 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012460 (seq = _loop0_36_rule(p)) // _loop0_36
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012461 )
12462 {
12463 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12464 goto done;
12465 }
12466 p->mark = mark;
12467 }
12468 res = NULL;
12469 done:
12470 return res;
12471}
12472
Guido van Rossumc001c092020-04-30 12:12:19 -070012473// _tmp_37: 'as' NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012474static void *
Guido van Rossumc001c092020-04-30 12:12:19 -070012475_tmp_37_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012476{
12477 if (p->error_indicator) {
12478 return NULL;
12479 }
12480 void * res = NULL;
12481 int mark = p->mark;
12482 { // 'as' NAME
Pablo Galindob796b3f2020-05-01 12:32:26 +010012483 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012484 expr_ty z;
12485 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012486 (keyword = _PyPegen_expect_token(p, 531)) // token='as'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012487 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012488 (z = _PyPegen_name_token(p)) // NAME
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012489 )
12490 {
12491 res = z;
12492 if (res == NULL && PyErr_Occurred()) {
12493 p->error_indicator = 1;
12494 return NULL;
12495 }
12496 goto done;
12497 }
12498 p->mark = mark;
12499 }
12500 res = NULL;
12501 done:
12502 return res;
12503}
12504
Guido van Rossumc001c092020-04-30 12:12:19 -070012505// _loop0_39: ',' with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012506static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012507_loop0_39_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012508{
12509 if (p->error_indicator) {
12510 return NULL;
12511 }
12512 void *res = NULL;
12513 int mark = p->mark;
12514 int start_mark = p->mark;
12515 void **children = PyMem_Malloc(sizeof(void *));
12516 if (!children) {
12517 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12518 return NULL;
12519 }
12520 ssize_t children_capacity = 1;
12521 ssize_t n = 0;
12522 { // ',' with_item
12523 withitem_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012524 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012525 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012526 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012527 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012528 (elem = with_item_rule(p)) // with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012529 )
12530 {
12531 res = elem;
12532 if (res == NULL && PyErr_Occurred()) {
12533 p->error_indicator = 1;
12534 PyMem_Free(children);
12535 return NULL;
12536 }
12537 if (n == children_capacity) {
12538 children_capacity *= 2;
12539 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12540 if (!children) {
12541 PyErr_Format(PyExc_MemoryError, "realloc None");
12542 return NULL;
12543 }
12544 }
12545 children[n++] = res;
12546 mark = p->mark;
12547 }
12548 p->mark = mark;
12549 }
12550 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12551 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012552 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012553 PyMem_Free(children);
12554 return NULL;
12555 }
12556 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12557 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012558 _PyPegen_insert_memo(p, start_mark, _loop0_39_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012559 return seq;
12560}
12561
Guido van Rossumc001c092020-04-30 12:12:19 -070012562// _gather_38: with_item _loop0_39
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012563static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012564_gather_38_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012565{
12566 if (p->error_indicator) {
12567 return NULL;
12568 }
12569 asdl_seq * res = NULL;
12570 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012571 { // with_item _loop0_39
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012572 withitem_ty elem;
12573 asdl_seq * seq;
12574 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012575 (elem = with_item_rule(p)) // with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012576 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012577 (seq = _loop0_39_rule(p)) // _loop0_39
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012578 )
12579 {
12580 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12581 goto done;
12582 }
12583 p->mark = mark;
12584 }
12585 res = NULL;
12586 done:
12587 return res;
12588}
12589
Guido van Rossumc001c092020-04-30 12:12:19 -070012590// _loop0_41: ',' with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012591static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012592_loop0_41_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012593{
12594 if (p->error_indicator) {
12595 return NULL;
12596 }
12597 void *res = NULL;
12598 int mark = p->mark;
12599 int start_mark = p->mark;
12600 void **children = PyMem_Malloc(sizeof(void *));
12601 if (!children) {
12602 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12603 return NULL;
12604 }
12605 ssize_t children_capacity = 1;
12606 ssize_t n = 0;
12607 { // ',' with_item
12608 withitem_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012609 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012610 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012611 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012612 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012613 (elem = with_item_rule(p)) // with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012614 )
12615 {
12616 res = elem;
12617 if (res == NULL && PyErr_Occurred()) {
12618 p->error_indicator = 1;
12619 PyMem_Free(children);
12620 return NULL;
12621 }
12622 if (n == children_capacity) {
12623 children_capacity *= 2;
12624 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12625 if (!children) {
12626 PyErr_Format(PyExc_MemoryError, "realloc None");
12627 return NULL;
12628 }
12629 }
12630 children[n++] = res;
12631 mark = p->mark;
12632 }
12633 p->mark = mark;
12634 }
12635 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12636 if (!seq) {
Guido van Rossumc001c092020-04-30 12:12:19 -070012637 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012638 PyMem_Free(children);
12639 return NULL;
12640 }
12641 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12642 PyMem_Free(children);
Guido van Rossumc001c092020-04-30 12:12:19 -070012643 _PyPegen_insert_memo(p, start_mark, _loop0_41_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012644 return seq;
12645}
12646
Guido van Rossumc001c092020-04-30 12:12:19 -070012647// _gather_40: with_item _loop0_41
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012648static asdl_seq *
Guido van Rossumc001c092020-04-30 12:12:19 -070012649_gather_40_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012650{
12651 if (p->error_indicator) {
12652 return NULL;
12653 }
12654 asdl_seq * res = NULL;
12655 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070012656 { // with_item _loop0_41
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012657 withitem_ty elem;
12658 asdl_seq * seq;
12659 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012660 (elem = with_item_rule(p)) // with_item
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012661 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012662 (seq = _loop0_41_rule(p)) // _loop0_41
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012663 )
12664 {
12665 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12666 goto done;
12667 }
12668 p->mark = mark;
12669 }
12670 res = NULL;
12671 done:
12672 return res;
12673}
12674
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012675// _loop0_43: ',' with_item
12676static asdl_seq *
12677_loop0_43_rule(Parser *p)
12678{
12679 if (p->error_indicator) {
12680 return NULL;
12681 }
12682 void *res = NULL;
12683 int mark = p->mark;
12684 int start_mark = p->mark;
12685 void **children = PyMem_Malloc(sizeof(void *));
12686 if (!children) {
12687 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12688 return NULL;
12689 }
12690 ssize_t children_capacity = 1;
12691 ssize_t n = 0;
12692 { // ',' with_item
12693 withitem_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012694 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012695 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012696 (literal = _PyPegen_expect_token(p, 12)) // token=','
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012697 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012698 (elem = with_item_rule(p)) // with_item
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012699 )
12700 {
12701 res = elem;
12702 if (res == NULL && PyErr_Occurred()) {
12703 p->error_indicator = 1;
12704 PyMem_Free(children);
12705 return NULL;
12706 }
12707 if (n == children_capacity) {
12708 children_capacity *= 2;
12709 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12710 if (!children) {
12711 PyErr_Format(PyExc_MemoryError, "realloc None");
12712 return NULL;
12713 }
12714 }
12715 children[n++] = res;
12716 mark = p->mark;
12717 }
12718 p->mark = mark;
12719 }
12720 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12721 if (!seq) {
12722 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43");
12723 PyMem_Free(children);
12724 return NULL;
12725 }
12726 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12727 PyMem_Free(children);
12728 _PyPegen_insert_memo(p, start_mark, _loop0_43_type, seq);
12729 return seq;
12730}
12731
12732// _gather_42: with_item _loop0_43
12733static asdl_seq *
12734_gather_42_rule(Parser *p)
12735{
12736 if (p->error_indicator) {
12737 return NULL;
12738 }
12739 asdl_seq * res = NULL;
12740 int mark = p->mark;
12741 { // with_item _loop0_43
12742 withitem_ty elem;
12743 asdl_seq * seq;
12744 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012745 (elem = with_item_rule(p)) // with_item
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012746 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012747 (seq = _loop0_43_rule(p)) // _loop0_43
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012748 )
12749 {
12750 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12751 goto done;
12752 }
12753 p->mark = mark;
12754 }
12755 res = NULL;
12756 done:
12757 return res;
12758}
12759
12760// _loop0_45: ',' with_item
12761static asdl_seq *
12762_loop0_45_rule(Parser *p)
12763{
12764 if (p->error_indicator) {
12765 return NULL;
12766 }
12767 void *res = NULL;
12768 int mark = p->mark;
12769 int start_mark = p->mark;
12770 void **children = PyMem_Malloc(sizeof(void *));
12771 if (!children) {
12772 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12773 return NULL;
12774 }
12775 ssize_t children_capacity = 1;
12776 ssize_t n = 0;
12777 { // ',' with_item
12778 withitem_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010012779 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012780 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012781 (literal = _PyPegen_expect_token(p, 12)) // token=','
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012782 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012783 (elem = with_item_rule(p)) // with_item
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012784 )
12785 {
12786 res = elem;
12787 if (res == NULL && PyErr_Occurred()) {
12788 p->error_indicator = 1;
12789 PyMem_Free(children);
12790 return NULL;
12791 }
12792 if (n == children_capacity) {
12793 children_capacity *= 2;
12794 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12795 if (!children) {
12796 PyErr_Format(PyExc_MemoryError, "realloc None");
12797 return NULL;
12798 }
12799 }
12800 children[n++] = res;
12801 mark = p->mark;
12802 }
12803 p->mark = mark;
12804 }
12805 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12806 if (!seq) {
12807 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45");
12808 PyMem_Free(children);
12809 return NULL;
12810 }
12811 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12812 PyMem_Free(children);
12813 _PyPegen_insert_memo(p, start_mark, _loop0_45_type, seq);
12814 return seq;
12815}
12816
12817// _gather_44: with_item _loop0_45
12818static asdl_seq *
12819_gather_44_rule(Parser *p)
12820{
12821 if (p->error_indicator) {
12822 return NULL;
12823 }
12824 asdl_seq * res = NULL;
12825 int mark = p->mark;
12826 { // with_item _loop0_45
12827 withitem_ty elem;
12828 asdl_seq * seq;
12829 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012830 (elem = with_item_rule(p)) // with_item
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012831 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012832 (seq = _loop0_45_rule(p)) // _loop0_45
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012833 )
12834 {
12835 res = _PyPegen_seq_insert_in_front(p, elem, seq);
12836 goto done;
12837 }
12838 p->mark = mark;
12839 }
12840 res = NULL;
12841 done:
12842 return res;
12843}
12844
12845// _tmp_46: 'as' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012846static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012847_tmp_46_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012848{
12849 if (p->error_indicator) {
12850 return NULL;
12851 }
12852 void * res = NULL;
12853 int mark = p->mark;
12854 { // 'as' target
Pablo Galindob796b3f2020-05-01 12:32:26 +010012855 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012856 expr_ty t;
12857 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012858 (keyword = _PyPegen_expect_token(p, 531)) // token='as'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012859 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012860 (t = target_rule(p)) // target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012861 )
12862 {
12863 res = t;
12864 if (res == NULL && PyErr_Occurred()) {
12865 p->error_indicator = 1;
12866 return NULL;
12867 }
12868 goto done;
12869 }
12870 p->mark = mark;
12871 }
12872 res = NULL;
12873 done:
12874 return res;
12875}
12876
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012877// _loop1_47: except_block
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012878static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012879_loop1_47_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012880{
12881 if (p->error_indicator) {
12882 return NULL;
12883 }
12884 void *res = NULL;
12885 int mark = p->mark;
12886 int start_mark = p->mark;
12887 void **children = PyMem_Malloc(sizeof(void *));
12888 if (!children) {
12889 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
12890 return NULL;
12891 }
12892 ssize_t children_capacity = 1;
12893 ssize_t n = 0;
12894 { // except_block
12895 excepthandler_ty except_block_var;
12896 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010012897 (except_block_var = except_block_rule(p)) // except_block
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012898 )
12899 {
12900 res = except_block_var;
12901 if (n == children_capacity) {
12902 children_capacity *= 2;
12903 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
12904 if (!children) {
12905 PyErr_Format(PyExc_MemoryError, "realloc None");
12906 return NULL;
12907 }
12908 }
12909 children[n++] = res;
12910 mark = p->mark;
12911 }
12912 p->mark = mark;
12913 }
12914 if (n == 0) {
12915 PyMem_Free(children);
12916 return NULL;
12917 }
12918 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
12919 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012920 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012921 PyMem_Free(children);
12922 return NULL;
12923 }
12924 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
12925 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012926 _PyPegen_insert_memo(p, start_mark, _loop1_47_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012927 return seq;
12928}
12929
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012930// _tmp_48: 'as' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012931static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012932_tmp_48_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012933{
12934 if (p->error_indicator) {
12935 return NULL;
12936 }
12937 void * res = NULL;
12938 int mark = p->mark;
12939 { // 'as' target
Pablo Galindob796b3f2020-05-01 12:32:26 +010012940 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012941 expr_ty z;
12942 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012943 (keyword = _PyPegen_expect_token(p, 531)) // token='as'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012944 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012945 (z = target_rule(p)) // target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012946 )
12947 {
12948 res = z;
12949 if (res == NULL && PyErr_Occurred()) {
12950 p->error_indicator = 1;
12951 return NULL;
12952 }
12953 goto done;
12954 }
12955 p->mark = mark;
12956 }
12957 res = NULL;
12958 done:
12959 return res;
12960}
12961
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012962// _tmp_49: 'from' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012963static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012964_tmp_49_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012965{
12966 if (p->error_indicator) {
12967 return NULL;
12968 }
12969 void * res = NULL;
12970 int mark = p->mark;
12971 { // 'from' expression
Pablo Galindob796b3f2020-05-01 12:32:26 +010012972 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012973 expr_ty z;
12974 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010012975 (keyword = _PyPegen_expect_token(p, 514)) // token='from'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012976 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010012977 (z = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012978 )
12979 {
12980 res = z;
12981 if (res == NULL && PyErr_Occurred()) {
12982 p->error_indicator = 1;
12983 return NULL;
12984 }
12985 goto done;
12986 }
12987 p->mark = mark;
12988 }
12989 res = NULL;
12990 done:
12991 return res;
12992}
12993
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012994// _tmp_50: '->' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012995static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030012996_tmp_50_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010012997{
12998 if (p->error_indicator) {
12999 return NULL;
13000 }
13001 void * res = NULL;
13002 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070013003 { // '->' expression
Pablo Galindob796b3f2020-05-01 12:32:26 +010013004 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070013005 expr_ty z;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013006 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010013007 (literal = _PyPegen_expect_token(p, 51)) // token='->'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013008 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010013009 (z = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013010 )
13011 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013012 res = z;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013013 if (res == NULL && PyErr_Occurred()) {
13014 p->error_indicator = 1;
13015 return NULL;
13016 }
13017 goto done;
13018 }
13019 p->mark = mark;
13020 }
13021 res = NULL;
13022 done:
13023 return res;
13024}
13025
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013026// _tmp_51: '->' expression
Guido van Rossumc001c092020-04-30 12:12:19 -070013027static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013028_tmp_51_rule(Parser *p)
13029{
13030 if (p->error_indicator) {
13031 return NULL;
13032 }
13033 void * res = NULL;
13034 int mark = p->mark;
13035 { // '->' expression
Pablo Galindob796b3f2020-05-01 12:32:26 +010013036 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013037 expr_ty z;
13038 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010013039 (literal = _PyPegen_expect_token(p, 51)) // token='->'
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013040 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010013041 (z = expression_rule(p)) // expression
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013042 )
13043 {
13044 res = z;
13045 if (res == NULL && PyErr_Occurred()) {
13046 p->error_indicator = 1;
13047 return NULL;
13048 }
13049 goto done;
13050 }
13051 p->mark = mark;
13052 }
13053 res = NULL;
13054 done:
13055 return res;
13056}
13057
13058// _tmp_52: NEWLINE INDENT
13059static void *
13060_tmp_52_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013061{
13062 if (p->error_indicator) {
13063 return NULL;
13064 }
13065 void * res = NULL;
13066 int mark = p->mark;
13067 { // NEWLINE INDENT
Pablo Galindob796b3f2020-05-01 12:32:26 +010013068 Token * indent_var;
13069 Token * newline_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013070 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010013071 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Guido van Rossumc001c092020-04-30 12:12:19 -070013072 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010013073 (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
Guido van Rossumc001c092020-04-30 12:12:19 -070013074 )
13075 {
13076 res = _PyPegen_dummy_name(p, newline_var, indent_var);
13077 goto done;
13078 }
13079 p->mark = mark;
13080 }
13081 res = NULL;
13082 done:
13083 return res;
13084}
13085
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013086// _loop0_53: param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013087static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013088_loop0_53_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013089{
13090 if (p->error_indicator) {
13091 return NULL;
13092 }
13093 void *res = NULL;
13094 int mark = p->mark;
13095 int start_mark = p->mark;
13096 void **children = PyMem_Malloc(sizeof(void *));
13097 if (!children) {
13098 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13099 return NULL;
13100 }
13101 ssize_t children_capacity = 1;
13102 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013103 { // param_no_default
13104 arg_ty param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013105 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013106 (param_no_default_var = param_no_default_rule(p)) // param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013107 )
13108 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013109 res = param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013110 if (n == children_capacity) {
13111 children_capacity *= 2;
13112 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13113 if (!children) {
13114 PyErr_Format(PyExc_MemoryError, "realloc None");
13115 return NULL;
13116 }
13117 }
13118 children[n++] = res;
13119 mark = p->mark;
13120 }
13121 p->mark = mark;
13122 }
13123 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13124 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013125 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013126 PyMem_Free(children);
13127 return NULL;
13128 }
13129 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13130 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013131 _PyPegen_insert_memo(p, start_mark, _loop0_53_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013132 return seq;
13133}
13134
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013135// _loop0_54: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013136static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013137_loop0_54_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013138{
13139 if (p->error_indicator) {
13140 return NULL;
13141 }
13142 void *res = NULL;
13143 int mark = p->mark;
13144 int start_mark = p->mark;
13145 void **children = PyMem_Malloc(sizeof(void *));
13146 if (!children) {
13147 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13148 return NULL;
13149 }
13150 ssize_t children_capacity = 1;
13151 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013152 { // param_with_default
13153 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013154 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013155 (param_with_default_var = param_with_default_rule(p)) // param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013156 )
13157 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013158 res = param_with_default_var;
13159 if (n == children_capacity) {
13160 children_capacity *= 2;
13161 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13162 if (!children) {
13163 PyErr_Format(PyExc_MemoryError, "realloc None");
13164 return NULL;
13165 }
13166 }
13167 children[n++] = res;
13168 mark = p->mark;
13169 }
13170 p->mark = mark;
13171 }
13172 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13173 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013174 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54");
Guido van Rossumc001c092020-04-30 12:12:19 -070013175 PyMem_Free(children);
13176 return NULL;
13177 }
13178 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13179 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013180 _PyPegen_insert_memo(p, start_mark, _loop0_54_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013181 return seq;
13182}
13183
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013184// _loop0_55: param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013185static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013186_loop0_55_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013187{
13188 if (p->error_indicator) {
13189 return NULL;
13190 }
13191 void *res = NULL;
13192 int mark = p->mark;
13193 int start_mark = p->mark;
13194 void **children = PyMem_Malloc(sizeof(void *));
13195 if (!children) {
13196 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13197 return NULL;
13198 }
13199 ssize_t children_capacity = 1;
13200 ssize_t n = 0;
13201 { // param_with_default
13202 NameDefaultPair* param_with_default_var;
13203 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013204 (param_with_default_var = param_with_default_rule(p)) // param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013205 )
13206 {
13207 res = param_with_default_var;
13208 if (n == children_capacity) {
13209 children_capacity *= 2;
13210 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13211 if (!children) {
13212 PyErr_Format(PyExc_MemoryError, "realloc None");
13213 return NULL;
13214 }
13215 }
13216 children[n++] = res;
13217 mark = p->mark;
13218 }
13219 p->mark = mark;
13220 }
13221 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13222 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013223 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55");
Guido van Rossumc001c092020-04-30 12:12:19 -070013224 PyMem_Free(children);
13225 return NULL;
13226 }
13227 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13228 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013229 _PyPegen_insert_memo(p, start_mark, _loop0_55_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013230 return seq;
13231}
13232
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013233// _loop1_56: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013234static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013235_loop1_56_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013236{
13237 if (p->error_indicator) {
13238 return NULL;
13239 }
13240 void *res = NULL;
13241 int mark = p->mark;
13242 int start_mark = p->mark;
13243 void **children = PyMem_Malloc(sizeof(void *));
13244 if (!children) {
13245 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13246 return NULL;
13247 }
13248 ssize_t children_capacity = 1;
13249 ssize_t n = 0;
13250 { // param_no_default
13251 arg_ty param_no_default_var;
13252 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013253 (param_no_default_var = param_no_default_rule(p)) // param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013254 )
13255 {
13256 res = param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013257 if (n == children_capacity) {
13258 children_capacity *= 2;
13259 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13260 if (!children) {
13261 PyErr_Format(PyExc_MemoryError, "realloc None");
13262 return NULL;
13263 }
13264 }
13265 children[n++] = res;
13266 mark = p->mark;
13267 }
13268 p->mark = mark;
13269 }
13270 if (n == 0) {
13271 PyMem_Free(children);
13272 return NULL;
13273 }
13274 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13275 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013276 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013277 PyMem_Free(children);
13278 return NULL;
13279 }
13280 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13281 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013282 _PyPegen_insert_memo(p, start_mark, _loop1_56_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013283 return seq;
13284}
13285
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013286// _loop0_57: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013287static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013288_loop0_57_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013289{
13290 if (p->error_indicator) {
13291 return NULL;
13292 }
13293 void *res = NULL;
13294 int mark = p->mark;
13295 int start_mark = p->mark;
13296 void **children = PyMem_Malloc(sizeof(void *));
13297 if (!children) {
13298 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13299 return NULL;
13300 }
13301 ssize_t children_capacity = 1;
13302 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013303 { // param_with_default
13304 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013305 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013306 (param_with_default_var = param_with_default_rule(p)) // param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013307 )
13308 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013309 res = param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013310 if (n == children_capacity) {
13311 children_capacity *= 2;
13312 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13313 if (!children) {
13314 PyErr_Format(PyExc_MemoryError, "realloc None");
13315 return NULL;
13316 }
13317 }
13318 children[n++] = res;
13319 mark = p->mark;
13320 }
13321 p->mark = mark;
13322 }
13323 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13324 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013325 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013326 PyMem_Free(children);
13327 return NULL;
13328 }
13329 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13330 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013331 _PyPegen_insert_memo(p, start_mark, _loop0_57_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013332 return seq;
13333}
13334
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013335// _loop1_58: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013336static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013337_loop1_58_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013338{
13339 if (p->error_indicator) {
13340 return NULL;
13341 }
13342 void *res = NULL;
13343 int mark = p->mark;
13344 int start_mark = p->mark;
13345 void **children = PyMem_Malloc(sizeof(void *));
13346 if (!children) {
13347 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13348 return NULL;
13349 }
13350 ssize_t children_capacity = 1;
13351 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070013352 { // param_with_default
13353 NameDefaultPair* param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013354 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013355 (param_with_default_var = param_with_default_rule(p)) // param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013356 )
13357 {
Guido van Rossumc001c092020-04-30 12:12:19 -070013358 res = param_with_default_var;
13359 if (n == children_capacity) {
13360 children_capacity *= 2;
13361 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13362 if (!children) {
13363 PyErr_Format(PyExc_MemoryError, "realloc None");
13364 return NULL;
13365 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013366 }
Guido van Rossumc001c092020-04-30 12:12:19 -070013367 children[n++] = res;
13368 mark = p->mark;
13369 }
13370 p->mark = mark;
13371 }
13372 if (n == 0) {
13373 PyMem_Free(children);
13374 return NULL;
13375 }
13376 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13377 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013378 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58");
Guido van Rossumc001c092020-04-30 12:12:19 -070013379 PyMem_Free(children);
13380 return NULL;
13381 }
13382 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13383 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013384 _PyPegen_insert_memo(p, start_mark, _loop1_58_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013385 return seq;
13386}
13387
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013388// _loop1_59: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013389static asdl_seq *
13390_loop1_59_rule(Parser *p)
13391{
13392 if (p->error_indicator) {
13393 return NULL;
13394 }
13395 void *res = NULL;
13396 int mark = p->mark;
13397 int start_mark = p->mark;
13398 void **children = PyMem_Malloc(sizeof(void *));
13399 if (!children) {
13400 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13401 return NULL;
13402 }
13403 ssize_t children_capacity = 1;
13404 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013405 { // param_no_default
13406 arg_ty param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013407 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013408 (param_no_default_var = param_no_default_rule(p)) // param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013409 )
13410 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013411 res = param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013412 if (n == children_capacity) {
13413 children_capacity *= 2;
13414 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13415 if (!children) {
13416 PyErr_Format(PyExc_MemoryError, "realloc None");
13417 return NULL;
13418 }
13419 }
13420 children[n++] = res;
13421 mark = p->mark;
13422 }
13423 p->mark = mark;
13424 }
13425 if (n == 0) {
13426 PyMem_Free(children);
13427 return NULL;
13428 }
13429 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13430 if (!seq) {
13431 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59");
13432 PyMem_Free(children);
13433 return NULL;
13434 }
13435 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13436 PyMem_Free(children);
13437 _PyPegen_insert_memo(p, start_mark, _loop1_59_type, seq);
13438 return seq;
13439}
13440
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013441// _loop1_60: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013442static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013443_loop1_60_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070013444{
13445 if (p->error_indicator) {
13446 return NULL;
13447 }
13448 void *res = NULL;
13449 int mark = p->mark;
13450 int start_mark = p->mark;
13451 void **children = PyMem_Malloc(sizeof(void *));
13452 if (!children) {
13453 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13454 return NULL;
13455 }
13456 ssize_t children_capacity = 1;
13457 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013458 { // param_no_default
13459 arg_ty param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013460 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013461 (param_no_default_var = param_no_default_rule(p)) // param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013462 )
13463 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013464 res = param_no_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013465 if (n == children_capacity) {
13466 children_capacity *= 2;
13467 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13468 if (!children) {
13469 PyErr_Format(PyExc_MemoryError, "realloc None");
13470 return NULL;
13471 }
13472 }
13473 children[n++] = res;
13474 mark = p->mark;
13475 }
13476 p->mark = mark;
13477 }
13478 if (n == 0) {
13479 PyMem_Free(children);
13480 return NULL;
13481 }
13482 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13483 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013484 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60");
Guido van Rossumc001c092020-04-30 12:12:19 -070013485 PyMem_Free(children);
13486 return NULL;
13487 }
13488 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13489 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013490 _PyPegen_insert_memo(p, start_mark, _loop1_60_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070013491 return seq;
13492}
13493
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013494// _loop0_61: param_no_default
13495static asdl_seq *
13496_loop0_61_rule(Parser *p)
13497{
13498 if (p->error_indicator) {
13499 return NULL;
13500 }
13501 void *res = NULL;
13502 int mark = p->mark;
13503 int start_mark = p->mark;
13504 void **children = PyMem_Malloc(sizeof(void *));
13505 if (!children) {
13506 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13507 return NULL;
13508 }
13509 ssize_t children_capacity = 1;
13510 ssize_t n = 0;
13511 { // param_no_default
13512 arg_ty param_no_default_var;
13513 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013514 (param_no_default_var = param_no_default_rule(p)) // param_no_default
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013515 )
13516 {
13517 res = param_no_default_var;
13518 if (n == children_capacity) {
13519 children_capacity *= 2;
13520 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13521 if (!children) {
13522 PyErr_Format(PyExc_MemoryError, "realloc None");
13523 return NULL;
13524 }
13525 }
13526 children[n++] = res;
13527 mark = p->mark;
13528 }
13529 p->mark = mark;
13530 }
13531 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13532 if (!seq) {
13533 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61");
13534 PyMem_Free(children);
13535 return NULL;
13536 }
13537 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13538 PyMem_Free(children);
13539 _PyPegen_insert_memo(p, start_mark, _loop0_61_type, seq);
13540 return seq;
13541}
13542
13543// _loop1_62: param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013544static asdl_seq *
13545_loop1_62_rule(Parser *p)
13546{
13547 if (p->error_indicator) {
13548 return NULL;
13549 }
13550 void *res = NULL;
13551 int mark = p->mark;
13552 int start_mark = p->mark;
13553 void **children = PyMem_Malloc(sizeof(void *));
13554 if (!children) {
13555 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13556 return NULL;
13557 }
13558 ssize_t children_capacity = 1;
13559 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013560 { // param_with_default
13561 NameDefaultPair* param_with_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013562 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013563 (param_with_default_var = param_with_default_rule(p)) // param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070013564 )
13565 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013566 res = param_with_default_var;
Guido van Rossumc001c092020-04-30 12:12:19 -070013567 if (n == children_capacity) {
13568 children_capacity *= 2;
13569 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13570 if (!children) {
13571 PyErr_Format(PyExc_MemoryError, "realloc None");
13572 return NULL;
13573 }
13574 }
13575 children[n++] = res;
13576 mark = p->mark;
13577 }
13578 p->mark = mark;
13579 }
13580 if (n == 0) {
13581 PyMem_Free(children);
13582 return NULL;
13583 }
13584 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13585 if (!seq) {
13586 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62");
13587 PyMem_Free(children);
13588 return NULL;
13589 }
13590 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13591 PyMem_Free(children);
13592 _PyPegen_insert_memo(p, start_mark, _loop1_62_type, seq);
13593 return seq;
13594}
13595
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013596// _loop0_63: param_no_default
13597static asdl_seq *
13598_loop0_63_rule(Parser *p)
13599{
13600 if (p->error_indicator) {
13601 return NULL;
13602 }
13603 void *res = NULL;
13604 int mark = p->mark;
13605 int start_mark = p->mark;
13606 void **children = PyMem_Malloc(sizeof(void *));
13607 if (!children) {
13608 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13609 return NULL;
13610 }
13611 ssize_t children_capacity = 1;
13612 ssize_t n = 0;
13613 { // param_no_default
13614 arg_ty param_no_default_var;
13615 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013616 (param_no_default_var = param_no_default_rule(p)) // param_no_default
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013617 )
13618 {
13619 res = param_no_default_var;
13620 if (n == children_capacity) {
13621 children_capacity *= 2;
13622 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13623 if (!children) {
13624 PyErr_Format(PyExc_MemoryError, "realloc None");
13625 return NULL;
13626 }
13627 }
13628 children[n++] = res;
13629 mark = p->mark;
13630 }
13631 p->mark = mark;
13632 }
13633 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13634 if (!seq) {
13635 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63");
13636 PyMem_Free(children);
13637 return NULL;
13638 }
13639 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13640 PyMem_Free(children);
13641 _PyPegen_insert_memo(p, start_mark, _loop0_63_type, seq);
13642 return seq;
13643}
13644
13645// _loop1_64: param_with_default
13646static asdl_seq *
13647_loop1_64_rule(Parser *p)
13648{
13649 if (p->error_indicator) {
13650 return NULL;
13651 }
13652 void *res = NULL;
13653 int mark = p->mark;
13654 int start_mark = p->mark;
13655 void **children = PyMem_Malloc(sizeof(void *));
13656 if (!children) {
13657 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13658 return NULL;
13659 }
13660 ssize_t children_capacity = 1;
13661 ssize_t n = 0;
13662 { // param_with_default
13663 NameDefaultPair* param_with_default_var;
13664 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013665 (param_with_default_var = param_with_default_rule(p)) // param_with_default
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013666 )
13667 {
13668 res = param_with_default_var;
13669 if (n == children_capacity) {
13670 children_capacity *= 2;
13671 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13672 if (!children) {
13673 PyErr_Format(PyExc_MemoryError, "realloc None");
13674 return NULL;
13675 }
13676 }
13677 children[n++] = res;
13678 mark = p->mark;
13679 }
13680 p->mark = mark;
13681 }
13682 if (n == 0) {
13683 PyMem_Free(children);
13684 return NULL;
13685 }
13686 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13687 if (!seq) {
13688 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64");
13689 PyMem_Free(children);
13690 return NULL;
13691 }
13692 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13693 PyMem_Free(children);
13694 _PyPegen_insert_memo(p, start_mark, _loop1_64_type, seq);
13695 return seq;
13696}
13697
13698// _loop0_65: param_maybe_default
13699static asdl_seq *
13700_loop0_65_rule(Parser *p)
13701{
13702 if (p->error_indicator) {
13703 return NULL;
13704 }
13705 void *res = NULL;
13706 int mark = p->mark;
13707 int start_mark = p->mark;
13708 void **children = PyMem_Malloc(sizeof(void *));
13709 if (!children) {
13710 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13711 return NULL;
13712 }
13713 ssize_t children_capacity = 1;
13714 ssize_t n = 0;
13715 { // param_maybe_default
13716 NameDefaultPair* param_maybe_default_var;
13717 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013718 (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013719 )
13720 {
13721 res = param_maybe_default_var;
13722 if (n == children_capacity) {
13723 children_capacity *= 2;
13724 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13725 if (!children) {
13726 PyErr_Format(PyExc_MemoryError, "realloc None");
13727 return NULL;
13728 }
13729 }
13730 children[n++] = res;
13731 mark = p->mark;
13732 }
13733 p->mark = mark;
13734 }
13735 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13736 if (!seq) {
13737 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65");
13738 PyMem_Free(children);
13739 return NULL;
13740 }
13741 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13742 PyMem_Free(children);
13743 _PyPegen_insert_memo(p, start_mark, _loop0_65_type, seq);
13744 return seq;
13745}
13746
13747// _loop1_66: param_maybe_default
13748static asdl_seq *
13749_loop1_66_rule(Parser *p)
13750{
13751 if (p->error_indicator) {
13752 return NULL;
13753 }
13754 void *res = NULL;
13755 int mark = p->mark;
13756 int start_mark = p->mark;
13757 void **children = PyMem_Malloc(sizeof(void *));
13758 if (!children) {
13759 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13760 return NULL;
13761 }
13762 ssize_t children_capacity = 1;
13763 ssize_t n = 0;
13764 { // param_maybe_default
13765 NameDefaultPair* param_maybe_default_var;
13766 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013767 (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013768 )
13769 {
13770 res = param_maybe_default_var;
13771 if (n == children_capacity) {
13772 children_capacity *= 2;
13773 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13774 if (!children) {
13775 PyErr_Format(PyExc_MemoryError, "realloc None");
13776 return NULL;
13777 }
13778 }
13779 children[n++] = res;
13780 mark = p->mark;
13781 }
13782 p->mark = mark;
13783 }
13784 if (n == 0) {
13785 PyMem_Free(children);
13786 return NULL;
13787 }
13788 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13789 if (!seq) {
13790 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66");
13791 PyMem_Free(children);
13792 return NULL;
13793 }
13794 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13795 PyMem_Free(children);
13796 _PyPegen_insert_memo(p, start_mark, _loop1_66_type, seq);
13797 return seq;
13798}
13799
13800// _loop1_67: ('@' named_expression NEWLINE)
13801static asdl_seq *
13802_loop1_67_rule(Parser *p)
13803{
13804 if (p->error_indicator) {
13805 return NULL;
13806 }
13807 void *res = NULL;
13808 int mark = p->mark;
13809 int start_mark = p->mark;
13810 void **children = PyMem_Malloc(sizeof(void *));
13811 if (!children) {
13812 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13813 return NULL;
13814 }
13815 ssize_t children_capacity = 1;
13816 ssize_t n = 0;
13817 { // ('@' named_expression NEWLINE)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013818 void *_tmp_137_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013819 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013820 (_tmp_137_var = _tmp_137_rule(p)) // '@' named_expression NEWLINE
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013821 )
13822 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013823 res = _tmp_137_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013824 if (n == children_capacity) {
13825 children_capacity *= 2;
13826 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13827 if (!children) {
13828 PyErr_Format(PyExc_MemoryError, "realloc None");
13829 return NULL;
13830 }
13831 }
13832 children[n++] = res;
13833 mark = p->mark;
13834 }
13835 p->mark = mark;
13836 }
13837 if (n == 0) {
13838 PyMem_Free(children);
13839 return NULL;
13840 }
13841 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13842 if (!seq) {
13843 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67");
13844 PyMem_Free(children);
13845 return NULL;
13846 }
13847 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13848 PyMem_Free(children);
13849 _PyPegen_insert_memo(p, start_mark, _loop1_67_type, seq);
13850 return seq;
13851}
13852
13853// _tmp_68: '(' arguments? ')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013854static void *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013855_tmp_68_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013856{
13857 if (p->error_indicator) {
13858 return NULL;
13859 }
13860 void * res = NULL;
13861 int mark = p->mark;
13862 { // '(' arguments? ')'
Pablo Galindob796b3f2020-05-01 12:32:26 +010013863 Token * literal;
13864 Token * literal_1;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013865 void *z;
13866 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010013867 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013868 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010013869 (z = arguments_rule(p), 1) // arguments?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013870 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010013871 (literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013872 )
13873 {
13874 res = z;
13875 if (res == NULL && PyErr_Occurred()) {
13876 p->error_indicator = 1;
13877 return NULL;
13878 }
13879 goto done;
13880 }
13881 p->mark = mark;
13882 }
13883 res = NULL;
13884 done:
13885 return res;
13886}
13887
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013888// _loop0_70: ',' star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013889static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013890_loop0_70_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013891{
13892 if (p->error_indicator) {
13893 return NULL;
13894 }
13895 void *res = NULL;
13896 int mark = p->mark;
13897 int start_mark = p->mark;
13898 void **children = PyMem_Malloc(sizeof(void *));
13899 if (!children) {
13900 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13901 return NULL;
13902 }
13903 ssize_t children_capacity = 1;
13904 ssize_t n = 0;
13905 { // ',' star_expression
13906 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010013907 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013908 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013909 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013910 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010013911 (elem = star_expression_rule(p)) // star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013912 )
13913 {
13914 res = elem;
13915 if (res == NULL && PyErr_Occurred()) {
13916 p->error_indicator = 1;
13917 PyMem_Free(children);
13918 return NULL;
13919 }
13920 if (n == children_capacity) {
13921 children_capacity *= 2;
13922 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
13923 if (!children) {
13924 PyErr_Format(PyExc_MemoryError, "realloc None");
13925 return NULL;
13926 }
13927 }
13928 children[n++] = res;
13929 mark = p->mark;
13930 }
13931 p->mark = mark;
13932 }
13933 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
13934 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013935 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013936 PyMem_Free(children);
13937 return NULL;
13938 }
13939 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
13940 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013941 _PyPegen_insert_memo(p, start_mark, _loop0_70_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013942 return seq;
13943}
13944
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013945// _gather_69: star_expression _loop0_70
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013946static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013947_gather_69_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013948{
13949 if (p->error_indicator) {
13950 return NULL;
13951 }
13952 asdl_seq * res = NULL;
13953 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013954 { // star_expression _loop0_70
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013955 expr_ty elem;
13956 asdl_seq * seq;
13957 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010013958 (elem = star_expression_rule(p)) // star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013959 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010013960 (seq = _loop0_70_rule(p)) // _loop0_70
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013961 )
13962 {
13963 res = _PyPegen_seq_insert_in_front(p, elem, seq);
13964 goto done;
13965 }
13966 p->mark = mark;
13967 }
13968 res = NULL;
13969 done:
13970 return res;
13971}
13972
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013973// _loop1_71: (',' star_expression)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013974static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030013975_loop1_71_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013976{
13977 if (p->error_indicator) {
13978 return NULL;
13979 }
13980 void *res = NULL;
13981 int mark = p->mark;
13982 int start_mark = p->mark;
13983 void **children = PyMem_Malloc(sizeof(void *));
13984 if (!children) {
13985 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
13986 return NULL;
13987 }
13988 ssize_t children_capacity = 1;
13989 ssize_t n = 0;
13990 { // (',' star_expression)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013991 void *_tmp_138_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013992 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010013993 (_tmp_138_var = _tmp_138_rule(p)) // ',' star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013994 )
13995 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030013996 res = _tmp_138_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010013997 if (n == children_capacity) {
13998 children_capacity *= 2;
13999 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14000 if (!children) {
14001 PyErr_Format(PyExc_MemoryError, "realloc None");
14002 return NULL;
14003 }
14004 }
14005 children[n++] = res;
14006 mark = p->mark;
14007 }
14008 p->mark = mark;
14009 }
14010 if (n == 0) {
14011 PyMem_Free(children);
14012 return NULL;
14013 }
14014 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14015 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014016 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014017 PyMem_Free(children);
14018 return NULL;
14019 }
14020 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14021 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014022 _PyPegen_insert_memo(p, start_mark, _loop1_71_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014023 return seq;
14024}
14025
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014026// _loop0_73: ',' star_named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014027static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014028_loop0_73_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014029{
14030 if (p->error_indicator) {
14031 return NULL;
14032 }
14033 void *res = NULL;
14034 int mark = p->mark;
14035 int start_mark = p->mark;
14036 void **children = PyMem_Malloc(sizeof(void *));
14037 if (!children) {
14038 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14039 return NULL;
14040 }
14041 ssize_t children_capacity = 1;
14042 ssize_t n = 0;
14043 { // ',' star_named_expression
14044 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010014045 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014046 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014047 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014048 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010014049 (elem = star_named_expression_rule(p)) // star_named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014050 )
14051 {
14052 res = elem;
14053 if (res == NULL && PyErr_Occurred()) {
14054 p->error_indicator = 1;
14055 PyMem_Free(children);
14056 return NULL;
14057 }
14058 if (n == children_capacity) {
14059 children_capacity *= 2;
14060 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14061 if (!children) {
14062 PyErr_Format(PyExc_MemoryError, "realloc None");
14063 return NULL;
14064 }
14065 }
14066 children[n++] = res;
14067 mark = p->mark;
14068 }
14069 p->mark = mark;
14070 }
14071 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14072 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014073 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014074 PyMem_Free(children);
14075 return NULL;
14076 }
14077 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14078 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014079 _PyPegen_insert_memo(p, start_mark, _loop0_73_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014080 return seq;
14081}
14082
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014083// _gather_72: star_named_expression _loop0_73
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014084static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014085_gather_72_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014086{
14087 if (p->error_indicator) {
14088 return NULL;
14089 }
14090 asdl_seq * res = NULL;
14091 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014092 { // star_named_expression _loop0_73
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014093 expr_ty elem;
14094 asdl_seq * seq;
14095 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010014096 (elem = star_named_expression_rule(p)) // star_named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014097 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010014098 (seq = _loop0_73_rule(p)) // _loop0_73
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014099 )
14100 {
14101 res = _PyPegen_seq_insert_in_front(p, elem, seq);
14102 goto done;
14103 }
14104 p->mark = mark;
14105 }
14106 res = NULL;
14107 done:
14108 return res;
14109}
14110
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014111// _loop1_74: (',' expression)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014112static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014113_loop1_74_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014114{
14115 if (p->error_indicator) {
14116 return NULL;
14117 }
14118 void *res = NULL;
14119 int mark = p->mark;
14120 int start_mark = p->mark;
14121 void **children = PyMem_Malloc(sizeof(void *));
14122 if (!children) {
14123 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14124 return NULL;
14125 }
14126 ssize_t children_capacity = 1;
14127 ssize_t n = 0;
14128 { // (',' expression)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014129 void *_tmp_139_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014130 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014131 (_tmp_139_var = _tmp_139_rule(p)) // ',' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014132 )
14133 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014134 res = _tmp_139_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014135 if (n == children_capacity) {
14136 children_capacity *= 2;
14137 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14138 if (!children) {
14139 PyErr_Format(PyExc_MemoryError, "realloc None");
14140 return NULL;
14141 }
14142 }
14143 children[n++] = res;
14144 mark = p->mark;
14145 }
14146 p->mark = mark;
14147 }
14148 if (n == 0) {
14149 PyMem_Free(children);
14150 return NULL;
14151 }
14152 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14153 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014154 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014155 PyMem_Free(children);
14156 return NULL;
14157 }
14158 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14159 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014160 _PyPegen_insert_memo(p, start_mark, _loop1_74_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014161 return seq;
14162}
14163
Guido van Rossum3941d972020-05-01 09:42:03 -070014164// _loop0_75: lambda_param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014165static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014166_loop0_75_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014167{
14168 if (p->error_indicator) {
14169 return NULL;
14170 }
14171 void *res = NULL;
14172 int mark = p->mark;
14173 int start_mark = p->mark;
14174 void **children = PyMem_Malloc(sizeof(void *));
14175 if (!children) {
14176 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14177 return NULL;
14178 }
14179 ssize_t children_capacity = 1;
14180 ssize_t n = 0;
Guido van Rossum3941d972020-05-01 09:42:03 -070014181 { // lambda_param_no_default
14182 arg_ty lambda_param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014183 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014184 (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014185 )
14186 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014187 res = lambda_param_no_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014188 if (n == children_capacity) {
14189 children_capacity *= 2;
14190 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14191 if (!children) {
14192 PyErr_Format(PyExc_MemoryError, "realloc None");
14193 return NULL;
14194 }
14195 }
14196 children[n++] = res;
14197 mark = p->mark;
14198 }
14199 p->mark = mark;
14200 }
14201 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14202 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014203 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014204 PyMem_Free(children);
14205 return NULL;
14206 }
14207 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14208 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014209 _PyPegen_insert_memo(p, start_mark, _loop0_75_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014210 return seq;
14211}
14212
Guido van Rossum3941d972020-05-01 09:42:03 -070014213// _loop0_76: lambda_param_with_default
14214static asdl_seq *
14215_loop0_76_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014216{
14217 if (p->error_indicator) {
14218 return NULL;
14219 }
Guido van Rossum3941d972020-05-01 09:42:03 -070014220 void *res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014221 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070014222 int start_mark = p->mark;
14223 void **children = PyMem_Malloc(sizeof(void *));
14224 if (!children) {
14225 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14226 return NULL;
14227 }
14228 ssize_t children_capacity = 1;
14229 ssize_t n = 0;
14230 { // lambda_param_with_default
14231 NameDefaultPair* lambda_param_with_default_var;
14232 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014233 (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014234 )
14235 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014236 res = lambda_param_with_default_var;
14237 if (n == children_capacity) {
14238 children_capacity *= 2;
14239 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14240 if (!children) {
14241 PyErr_Format(PyExc_MemoryError, "realloc None");
14242 return NULL;
14243 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014244 }
Guido van Rossum3941d972020-05-01 09:42:03 -070014245 children[n++] = res;
14246 mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014247 }
14248 p->mark = mark;
14249 }
Guido van Rossum3941d972020-05-01 09:42:03 -070014250 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14251 if (!seq) {
14252 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76");
14253 PyMem_Free(children);
14254 return NULL;
14255 }
14256 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14257 PyMem_Free(children);
14258 _PyPegen_insert_memo(p, start_mark, _loop0_76_type, seq);
14259 return seq;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014260}
14261
Guido van Rossum3941d972020-05-01 09:42:03 -070014262// _loop0_77: lambda_param_with_default
14263static asdl_seq *
14264_loop0_77_rule(Parser *p)
14265{
14266 if (p->error_indicator) {
14267 return NULL;
14268 }
14269 void *res = NULL;
14270 int mark = p->mark;
14271 int start_mark = p->mark;
14272 void **children = PyMem_Malloc(sizeof(void *));
14273 if (!children) {
14274 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14275 return NULL;
14276 }
14277 ssize_t children_capacity = 1;
14278 ssize_t n = 0;
14279 { // lambda_param_with_default
14280 NameDefaultPair* lambda_param_with_default_var;
14281 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014282 (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014283 )
14284 {
14285 res = lambda_param_with_default_var;
14286 if (n == children_capacity) {
14287 children_capacity *= 2;
14288 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14289 if (!children) {
14290 PyErr_Format(PyExc_MemoryError, "realloc None");
14291 return NULL;
14292 }
14293 }
14294 children[n++] = res;
14295 mark = p->mark;
14296 }
14297 p->mark = mark;
14298 }
14299 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14300 if (!seq) {
14301 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77");
14302 PyMem_Free(children);
14303 return NULL;
14304 }
14305 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14306 PyMem_Free(children);
14307 _PyPegen_insert_memo(p, start_mark, _loop0_77_type, seq);
14308 return seq;
14309}
14310
14311// _loop1_78: lambda_param_no_default
14312static asdl_seq *
14313_loop1_78_rule(Parser *p)
14314{
14315 if (p->error_indicator) {
14316 return NULL;
14317 }
14318 void *res = NULL;
14319 int mark = p->mark;
14320 int start_mark = p->mark;
14321 void **children = PyMem_Malloc(sizeof(void *));
14322 if (!children) {
14323 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14324 return NULL;
14325 }
14326 ssize_t children_capacity = 1;
14327 ssize_t n = 0;
14328 { // lambda_param_no_default
14329 arg_ty lambda_param_no_default_var;
14330 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014331 (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014332 )
14333 {
14334 res = lambda_param_no_default_var;
14335 if (n == children_capacity) {
14336 children_capacity *= 2;
14337 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14338 if (!children) {
14339 PyErr_Format(PyExc_MemoryError, "realloc None");
14340 return NULL;
14341 }
14342 }
14343 children[n++] = res;
14344 mark = p->mark;
14345 }
14346 p->mark = mark;
14347 }
14348 if (n == 0) {
14349 PyMem_Free(children);
14350 return NULL;
14351 }
14352 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14353 if (!seq) {
14354 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78");
14355 PyMem_Free(children);
14356 return NULL;
14357 }
14358 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14359 PyMem_Free(children);
14360 _PyPegen_insert_memo(p, start_mark, _loop1_78_type, seq);
14361 return seq;
14362}
14363
14364// _loop0_79: lambda_param_with_default
14365static asdl_seq *
14366_loop0_79_rule(Parser *p)
14367{
14368 if (p->error_indicator) {
14369 return NULL;
14370 }
14371 void *res = NULL;
14372 int mark = p->mark;
14373 int start_mark = p->mark;
14374 void **children = PyMem_Malloc(sizeof(void *));
14375 if (!children) {
14376 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14377 return NULL;
14378 }
14379 ssize_t children_capacity = 1;
14380 ssize_t n = 0;
14381 { // lambda_param_with_default
14382 NameDefaultPair* lambda_param_with_default_var;
14383 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014384 (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014385 )
14386 {
14387 res = lambda_param_with_default_var;
14388 if (n == children_capacity) {
14389 children_capacity *= 2;
14390 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14391 if (!children) {
14392 PyErr_Format(PyExc_MemoryError, "realloc None");
14393 return NULL;
14394 }
14395 }
14396 children[n++] = res;
14397 mark = p->mark;
14398 }
14399 p->mark = mark;
14400 }
14401 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14402 if (!seq) {
14403 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79");
14404 PyMem_Free(children);
14405 return NULL;
14406 }
14407 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14408 PyMem_Free(children);
14409 _PyPegen_insert_memo(p, start_mark, _loop0_79_type, seq);
14410 return seq;
14411}
14412
14413// _loop1_80: lambda_param_with_default
14414static asdl_seq *
14415_loop1_80_rule(Parser *p)
14416{
14417 if (p->error_indicator) {
14418 return NULL;
14419 }
14420 void *res = NULL;
14421 int mark = p->mark;
14422 int start_mark = p->mark;
14423 void **children = PyMem_Malloc(sizeof(void *));
14424 if (!children) {
14425 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14426 return NULL;
14427 }
14428 ssize_t children_capacity = 1;
14429 ssize_t n = 0;
14430 { // lambda_param_with_default
14431 NameDefaultPair* lambda_param_with_default_var;
14432 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014433 (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014434 )
14435 {
14436 res = lambda_param_with_default_var;
14437 if (n == children_capacity) {
14438 children_capacity *= 2;
14439 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14440 if (!children) {
14441 PyErr_Format(PyExc_MemoryError, "realloc None");
14442 return NULL;
14443 }
14444 }
14445 children[n++] = res;
14446 mark = p->mark;
14447 }
14448 p->mark = mark;
14449 }
14450 if (n == 0) {
14451 PyMem_Free(children);
14452 return NULL;
14453 }
14454 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14455 if (!seq) {
14456 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80");
14457 PyMem_Free(children);
14458 return NULL;
14459 }
14460 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14461 PyMem_Free(children);
14462 _PyPegen_insert_memo(p, start_mark, _loop1_80_type, seq);
14463 return seq;
14464}
14465
14466// _loop1_81: lambda_param_no_default
14467static asdl_seq *
14468_loop1_81_rule(Parser *p)
14469{
14470 if (p->error_indicator) {
14471 return NULL;
14472 }
14473 void *res = NULL;
14474 int mark = p->mark;
14475 int start_mark = p->mark;
14476 void **children = PyMem_Malloc(sizeof(void *));
14477 if (!children) {
14478 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14479 return NULL;
14480 }
14481 ssize_t children_capacity = 1;
14482 ssize_t n = 0;
14483 { // lambda_param_no_default
14484 arg_ty lambda_param_no_default_var;
14485 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014486 (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014487 )
14488 {
14489 res = lambda_param_no_default_var;
14490 if (n == children_capacity) {
14491 children_capacity *= 2;
14492 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14493 if (!children) {
14494 PyErr_Format(PyExc_MemoryError, "realloc None");
14495 return NULL;
14496 }
14497 }
14498 children[n++] = res;
14499 mark = p->mark;
14500 }
14501 p->mark = mark;
14502 }
14503 if (n == 0) {
14504 PyMem_Free(children);
14505 return NULL;
14506 }
14507 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14508 if (!seq) {
14509 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81");
14510 PyMem_Free(children);
14511 return NULL;
14512 }
14513 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14514 PyMem_Free(children);
14515 _PyPegen_insert_memo(p, start_mark, _loop1_81_type, seq);
14516 return seq;
14517}
14518
14519// _loop1_82: lambda_param_no_default
14520static asdl_seq *
14521_loop1_82_rule(Parser *p)
14522{
14523 if (p->error_indicator) {
14524 return NULL;
14525 }
14526 void *res = NULL;
14527 int mark = p->mark;
14528 int start_mark = p->mark;
14529 void **children = PyMem_Malloc(sizeof(void *));
14530 if (!children) {
14531 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14532 return NULL;
14533 }
14534 ssize_t children_capacity = 1;
14535 ssize_t n = 0;
14536 { // lambda_param_no_default
14537 arg_ty lambda_param_no_default_var;
14538 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014539 (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014540 )
14541 {
14542 res = lambda_param_no_default_var;
14543 if (n == children_capacity) {
14544 children_capacity *= 2;
14545 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14546 if (!children) {
14547 PyErr_Format(PyExc_MemoryError, "realloc None");
14548 return NULL;
14549 }
14550 }
14551 children[n++] = res;
14552 mark = p->mark;
14553 }
14554 p->mark = mark;
14555 }
14556 if (n == 0) {
14557 PyMem_Free(children);
14558 return NULL;
14559 }
14560 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14561 if (!seq) {
14562 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82");
14563 PyMem_Free(children);
14564 return NULL;
14565 }
14566 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14567 PyMem_Free(children);
14568 _PyPegen_insert_memo(p, start_mark, _loop1_82_type, seq);
14569 return seq;
14570}
14571
14572// _loop0_83: lambda_param_no_default
14573static asdl_seq *
14574_loop0_83_rule(Parser *p)
14575{
14576 if (p->error_indicator) {
14577 return NULL;
14578 }
14579 void *res = NULL;
14580 int mark = p->mark;
14581 int start_mark = p->mark;
14582 void **children = PyMem_Malloc(sizeof(void *));
14583 if (!children) {
14584 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14585 return NULL;
14586 }
14587 ssize_t children_capacity = 1;
14588 ssize_t n = 0;
14589 { // lambda_param_no_default
14590 arg_ty lambda_param_no_default_var;
14591 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014592 (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014593 )
14594 {
14595 res = lambda_param_no_default_var;
14596 if (n == children_capacity) {
14597 children_capacity *= 2;
14598 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14599 if (!children) {
14600 PyErr_Format(PyExc_MemoryError, "realloc None");
14601 return NULL;
14602 }
14603 }
14604 children[n++] = res;
14605 mark = p->mark;
14606 }
14607 p->mark = mark;
14608 }
14609 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14610 if (!seq) {
14611 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83");
14612 PyMem_Free(children);
14613 return NULL;
14614 }
14615 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14616 PyMem_Free(children);
14617 _PyPegen_insert_memo(p, start_mark, _loop0_83_type, seq);
14618 return seq;
14619}
14620
14621// _loop1_84: lambda_param_with_default
14622static asdl_seq *
14623_loop1_84_rule(Parser *p)
14624{
14625 if (p->error_indicator) {
14626 return NULL;
14627 }
14628 void *res = NULL;
14629 int mark = p->mark;
14630 int start_mark = p->mark;
14631 void **children = PyMem_Malloc(sizeof(void *));
14632 if (!children) {
14633 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14634 return NULL;
14635 }
14636 ssize_t children_capacity = 1;
14637 ssize_t n = 0;
14638 { // lambda_param_with_default
14639 NameDefaultPair* lambda_param_with_default_var;
14640 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014641 (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014642 )
14643 {
14644 res = lambda_param_with_default_var;
14645 if (n == children_capacity) {
14646 children_capacity *= 2;
14647 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14648 if (!children) {
14649 PyErr_Format(PyExc_MemoryError, "realloc None");
14650 return NULL;
14651 }
14652 }
14653 children[n++] = res;
14654 mark = p->mark;
14655 }
14656 p->mark = mark;
14657 }
14658 if (n == 0) {
14659 PyMem_Free(children);
14660 return NULL;
14661 }
14662 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14663 if (!seq) {
14664 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84");
14665 PyMem_Free(children);
14666 return NULL;
14667 }
14668 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14669 PyMem_Free(children);
14670 _PyPegen_insert_memo(p, start_mark, _loop1_84_type, seq);
14671 return seq;
14672}
14673
14674// _loop0_85: lambda_param_no_default
14675static asdl_seq *
14676_loop0_85_rule(Parser *p)
14677{
14678 if (p->error_indicator) {
14679 return NULL;
14680 }
14681 void *res = NULL;
14682 int mark = p->mark;
14683 int start_mark = p->mark;
14684 void **children = PyMem_Malloc(sizeof(void *));
14685 if (!children) {
14686 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14687 return NULL;
14688 }
14689 ssize_t children_capacity = 1;
14690 ssize_t n = 0;
14691 { // lambda_param_no_default
14692 arg_ty lambda_param_no_default_var;
14693 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014694 (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
Guido van Rossum3941d972020-05-01 09:42:03 -070014695 )
14696 {
14697 res = lambda_param_no_default_var;
14698 if (n == children_capacity) {
14699 children_capacity *= 2;
14700 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14701 if (!children) {
14702 PyErr_Format(PyExc_MemoryError, "realloc None");
14703 return NULL;
14704 }
14705 }
14706 children[n++] = res;
14707 mark = p->mark;
14708 }
14709 p->mark = mark;
14710 }
14711 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14712 if (!seq) {
14713 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85");
14714 PyMem_Free(children);
14715 return NULL;
14716 }
14717 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14718 PyMem_Free(children);
14719 _PyPegen_insert_memo(p, start_mark, _loop0_85_type, seq);
14720 return seq;
14721}
14722
14723// _loop1_86: lambda_param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014724static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014725_loop1_86_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014726{
14727 if (p->error_indicator) {
14728 return NULL;
14729 }
14730 void *res = NULL;
14731 int mark = p->mark;
14732 int start_mark = p->mark;
14733 void **children = PyMem_Malloc(sizeof(void *));
14734 if (!children) {
14735 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14736 return NULL;
14737 }
14738 ssize_t children_capacity = 1;
14739 ssize_t n = 0;
Guido van Rossum3941d972020-05-01 09:42:03 -070014740 { // lambda_param_with_default
14741 NameDefaultPair* lambda_param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014742 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014743 (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014744 )
14745 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014746 res = lambda_param_with_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014747 if (n == children_capacity) {
14748 children_capacity *= 2;
14749 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14750 if (!children) {
14751 PyErr_Format(PyExc_MemoryError, "realloc None");
14752 return NULL;
14753 }
14754 }
14755 children[n++] = res;
14756 mark = p->mark;
14757 }
14758 p->mark = mark;
14759 }
14760 if (n == 0) {
14761 PyMem_Free(children);
14762 return NULL;
14763 }
14764 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14765 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014766 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014767 PyMem_Free(children);
14768 return NULL;
14769 }
14770 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14771 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030014772 _PyPegen_insert_memo(p, start_mark, _loop1_86_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014773 return seq;
14774}
14775
Guido van Rossum3941d972020-05-01 09:42:03 -070014776// _loop0_87: lambda_param_maybe_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014777static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014778_loop0_87_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014779{
14780 if (p->error_indicator) {
14781 return NULL;
14782 }
14783 void *res = NULL;
14784 int mark = p->mark;
14785 int start_mark = p->mark;
14786 void **children = PyMem_Malloc(sizeof(void *));
14787 if (!children) {
14788 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14789 return NULL;
14790 }
14791 ssize_t children_capacity = 1;
14792 ssize_t n = 0;
Guido van Rossum3941d972020-05-01 09:42:03 -070014793 { // lambda_param_maybe_default
14794 NameDefaultPair* lambda_param_maybe_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014795 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014796 (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014797 )
14798 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014799 res = lambda_param_maybe_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014800 if (n == children_capacity) {
14801 children_capacity *= 2;
14802 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14803 if (!children) {
14804 PyErr_Format(PyExc_MemoryError, "realloc None");
14805 return NULL;
14806 }
14807 }
14808 children[n++] = res;
14809 mark = p->mark;
14810 }
14811 p->mark = mark;
14812 }
14813 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14814 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014815 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014816 PyMem_Free(children);
14817 return NULL;
14818 }
14819 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14820 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014821 _PyPegen_insert_memo(p, start_mark, _loop0_87_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014822 return seq;
14823}
14824
Guido van Rossum3941d972020-05-01 09:42:03 -070014825// _loop1_88: lambda_param_maybe_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014826static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014827_loop1_88_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014828{
14829 if (p->error_indicator) {
14830 return NULL;
14831 }
14832 void *res = NULL;
14833 int mark = p->mark;
14834 int start_mark = p->mark;
14835 void **children = PyMem_Malloc(sizeof(void *));
14836 if (!children) {
14837 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14838 return NULL;
14839 }
14840 ssize_t children_capacity = 1;
14841 ssize_t n = 0;
Guido van Rossum3941d972020-05-01 09:42:03 -070014842 { // lambda_param_maybe_default
14843 NameDefaultPair* lambda_param_maybe_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014844 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014845 (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014846 )
14847 {
Guido van Rossum3941d972020-05-01 09:42:03 -070014848 res = lambda_param_maybe_default_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014849 if (n == children_capacity) {
14850 children_capacity *= 2;
14851 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14852 if (!children) {
14853 PyErr_Format(PyExc_MemoryError, "realloc None");
14854 return NULL;
14855 }
14856 }
14857 children[n++] = res;
14858 mark = p->mark;
14859 }
14860 p->mark = mark;
14861 }
Guido van Rossum3941d972020-05-01 09:42:03 -070014862 if (n == 0) {
14863 PyMem_Free(children);
14864 return NULL;
14865 }
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014866 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14867 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014868 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014869 PyMem_Free(children);
14870 return NULL;
14871 }
14872 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14873 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014874 _PyPegen_insert_memo(p, start_mark, _loop1_88_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014875 return seq;
14876}
14877
Guido van Rossum3941d972020-05-01 09:42:03 -070014878// _loop1_89: ('or' conjunction)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014879static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014880_loop1_89_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014881{
14882 if (p->error_indicator) {
14883 return NULL;
14884 }
14885 void *res = NULL;
14886 int mark = p->mark;
14887 int start_mark = p->mark;
14888 void **children = PyMem_Malloc(sizeof(void *));
14889 if (!children) {
14890 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14891 return NULL;
14892 }
14893 ssize_t children_capacity = 1;
14894 ssize_t n = 0;
14895 { // ('or' conjunction)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014896 void *_tmp_140_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014897 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014898 (_tmp_140_var = _tmp_140_rule(p)) // 'or' conjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014899 )
14900 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014901 res = _tmp_140_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014902 if (n == children_capacity) {
14903 children_capacity *= 2;
14904 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14905 if (!children) {
14906 PyErr_Format(PyExc_MemoryError, "realloc None");
14907 return NULL;
14908 }
14909 }
14910 children[n++] = res;
14911 mark = p->mark;
14912 }
14913 p->mark = mark;
14914 }
14915 if (n == 0) {
14916 PyMem_Free(children);
14917 return NULL;
14918 }
14919 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14920 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014921 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014922 PyMem_Free(children);
14923 return NULL;
14924 }
14925 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14926 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014927 _PyPegen_insert_memo(p, start_mark, _loop1_89_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014928 return seq;
14929}
14930
Guido van Rossum3941d972020-05-01 09:42:03 -070014931// _loop1_90: ('and' inversion)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014932static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014933_loop1_90_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014934{
14935 if (p->error_indicator) {
14936 return NULL;
14937 }
14938 void *res = NULL;
14939 int mark = p->mark;
14940 int start_mark = p->mark;
14941 void **children = PyMem_Malloc(sizeof(void *));
14942 if (!children) {
14943 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14944 return NULL;
14945 }
14946 ssize_t children_capacity = 1;
14947 ssize_t n = 0;
14948 { // ('and' inversion)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014949 void *_tmp_141_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014950 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010014951 (_tmp_141_var = _tmp_141_rule(p)) // 'and' inversion
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014952 )
14953 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030014954 res = _tmp_141_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014955 if (n == children_capacity) {
14956 children_capacity *= 2;
14957 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
14958 if (!children) {
14959 PyErr_Format(PyExc_MemoryError, "realloc None");
14960 return NULL;
14961 }
14962 }
14963 children[n++] = res;
14964 mark = p->mark;
14965 }
14966 p->mark = mark;
14967 }
14968 if (n == 0) {
14969 PyMem_Free(children);
14970 return NULL;
14971 }
14972 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
14973 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070014974 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014975 PyMem_Free(children);
14976 return NULL;
14977 }
14978 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
14979 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070014980 _PyPegen_insert_memo(p, start_mark, _loop1_90_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014981 return seq;
14982}
14983
Guido van Rossum3941d972020-05-01 09:42:03 -070014984// _loop1_91: compare_op_bitwise_or_pair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014985static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070014986_loop1_91_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010014987{
14988 if (p->error_indicator) {
14989 return NULL;
14990 }
14991 void *res = NULL;
14992 int mark = p->mark;
14993 int start_mark = p->mark;
14994 void **children = PyMem_Malloc(sizeof(void *));
14995 if (!children) {
14996 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
14997 return NULL;
14998 }
14999 ssize_t children_capacity = 1;
15000 ssize_t n = 0;
15001 { // compare_op_bitwise_or_pair
15002 CmpopExprPair* compare_op_bitwise_or_pair_var;
15003 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015004 (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015005 )
15006 {
15007 res = compare_op_bitwise_or_pair_var;
15008 if (n == children_capacity) {
15009 children_capacity *= 2;
15010 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15011 if (!children) {
15012 PyErr_Format(PyExc_MemoryError, "realloc None");
15013 return NULL;
15014 }
15015 }
15016 children[n++] = res;
15017 mark = p->mark;
15018 }
15019 p->mark = mark;
15020 }
15021 if (n == 0) {
15022 PyMem_Free(children);
15023 return NULL;
15024 }
15025 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15026 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015027 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015028 PyMem_Free(children);
15029 return NULL;
15030 }
15031 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15032 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015033 _PyPegen_insert_memo(p, start_mark, _loop1_91_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015034 return seq;
15035}
15036
Guido van Rossum3941d972020-05-01 09:42:03 -070015037// _tmp_92: '!='
Pablo Galindo2b74c832020-04-27 18:02:07 +010015038static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015039_tmp_92_rule(Parser *p)
Pablo Galindo2b74c832020-04-27 18:02:07 +010015040{
15041 if (p->error_indicator) {
15042 return NULL;
15043 }
15044 void * res = NULL;
15045 int mark = p->mark;
15046 { // '!='
Pablo Galindob796b3f2020-05-01 12:32:26 +010015047 Token * tok;
Pablo Galindo2b74c832020-04-27 18:02:07 +010015048 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015049 (tok = _PyPegen_expect_token(p, 28)) // token='!='
Pablo Galindo2b74c832020-04-27 18:02:07 +010015050 )
15051 {
15052 res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok;
15053 if (res == NULL && PyErr_Occurred()) {
15054 p->error_indicator = 1;
15055 return NULL;
15056 }
15057 goto done;
15058 }
15059 p->mark = mark;
15060 }
15061 res = NULL;
15062 done:
15063 return res;
15064}
15065
Guido van Rossum3941d972020-05-01 09:42:03 -070015066// _loop0_94: ',' slice
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015067static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015068_loop0_94_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015069{
15070 if (p->error_indicator) {
15071 return NULL;
15072 }
15073 void *res = NULL;
15074 int mark = p->mark;
15075 int start_mark = p->mark;
15076 void **children = PyMem_Malloc(sizeof(void *));
15077 if (!children) {
15078 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15079 return NULL;
15080 }
15081 ssize_t children_capacity = 1;
15082 ssize_t n = 0;
15083 { // ',' slice
15084 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015085 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015086 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015087 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015088 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015089 (elem = slice_rule(p)) // slice
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015090 )
15091 {
15092 res = elem;
15093 if (res == NULL && PyErr_Occurred()) {
15094 p->error_indicator = 1;
15095 PyMem_Free(children);
15096 return NULL;
15097 }
15098 if (n == children_capacity) {
15099 children_capacity *= 2;
15100 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15101 if (!children) {
15102 PyErr_Format(PyExc_MemoryError, "realloc None");
15103 return NULL;
15104 }
15105 }
15106 children[n++] = res;
15107 mark = p->mark;
15108 }
15109 p->mark = mark;
15110 }
15111 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15112 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015113 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015114 PyMem_Free(children);
15115 return NULL;
15116 }
15117 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15118 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015119 _PyPegen_insert_memo(p, start_mark, _loop0_94_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015120 return seq;
15121}
15122
Guido van Rossum3941d972020-05-01 09:42:03 -070015123// _gather_93: slice _loop0_94
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015124static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015125_gather_93_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015126{
15127 if (p->error_indicator) {
15128 return NULL;
15129 }
15130 asdl_seq * res = NULL;
15131 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070015132 { // slice _loop0_94
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015133 expr_ty elem;
15134 asdl_seq * seq;
15135 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015136 (elem = slice_rule(p)) // slice
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015137 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015138 (seq = _loop0_94_rule(p)) // _loop0_94
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015139 )
15140 {
15141 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15142 goto done;
15143 }
15144 p->mark = mark;
15145 }
15146 res = NULL;
15147 done:
15148 return res;
15149}
15150
Guido van Rossum3941d972020-05-01 09:42:03 -070015151// _tmp_95: ':' expression?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015152static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015153_tmp_95_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015154{
15155 if (p->error_indicator) {
15156 return NULL;
15157 }
15158 void * res = NULL;
15159 int mark = p->mark;
15160 { // ':' expression?
15161 void *d;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015162 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015163 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015164 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015165 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015166 (d = expression_rule(p), 1) // expression?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015167 )
15168 {
15169 res = d;
15170 if (res == NULL && PyErr_Occurred()) {
15171 p->error_indicator = 1;
15172 return NULL;
15173 }
15174 goto done;
15175 }
15176 p->mark = mark;
15177 }
15178 res = NULL;
15179 done:
15180 return res;
15181}
15182
Guido van Rossum3941d972020-05-01 09:42:03 -070015183// _tmp_96: tuple | group | genexp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015184static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015185_tmp_96_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015186{
15187 if (p->error_indicator) {
15188 return NULL;
15189 }
15190 void * res = NULL;
15191 int mark = p->mark;
15192 { // tuple
15193 expr_ty tuple_var;
15194 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015195 (tuple_var = tuple_rule(p)) // tuple
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015196 )
15197 {
15198 res = tuple_var;
15199 goto done;
15200 }
15201 p->mark = mark;
15202 }
15203 { // group
15204 expr_ty group_var;
15205 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015206 (group_var = group_rule(p)) // group
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015207 )
15208 {
15209 res = group_var;
15210 goto done;
15211 }
15212 p->mark = mark;
15213 }
15214 { // genexp
15215 expr_ty genexp_var;
15216 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015217 (genexp_var = genexp_rule(p)) // genexp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015218 )
15219 {
15220 res = genexp_var;
15221 goto done;
15222 }
15223 p->mark = mark;
15224 }
15225 res = NULL;
15226 done:
15227 return res;
15228}
15229
Guido van Rossum3941d972020-05-01 09:42:03 -070015230// _tmp_97: list | listcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015231static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015232_tmp_97_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015233{
15234 if (p->error_indicator) {
15235 return NULL;
15236 }
15237 void * res = NULL;
15238 int mark = p->mark;
15239 { // list
15240 expr_ty list_var;
15241 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015242 (list_var = list_rule(p)) // list
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015243 )
15244 {
15245 res = list_var;
15246 goto done;
15247 }
15248 p->mark = mark;
15249 }
15250 { // listcomp
15251 expr_ty listcomp_var;
15252 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015253 (listcomp_var = listcomp_rule(p)) // listcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015254 )
15255 {
15256 res = listcomp_var;
15257 goto done;
15258 }
15259 p->mark = mark;
15260 }
15261 res = NULL;
15262 done:
15263 return res;
15264}
15265
Guido van Rossum3941d972020-05-01 09:42:03 -070015266// _tmp_98: dict | set | dictcomp | setcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015267static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015268_tmp_98_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015269{
15270 if (p->error_indicator) {
15271 return NULL;
15272 }
15273 void * res = NULL;
15274 int mark = p->mark;
15275 { // dict
15276 expr_ty dict_var;
15277 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015278 (dict_var = dict_rule(p)) // dict
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015279 )
15280 {
15281 res = dict_var;
15282 goto done;
15283 }
15284 p->mark = mark;
15285 }
15286 { // set
15287 expr_ty set_var;
15288 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015289 (set_var = set_rule(p)) // set
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015290 )
15291 {
15292 res = set_var;
15293 goto done;
15294 }
15295 p->mark = mark;
15296 }
15297 { // dictcomp
15298 expr_ty dictcomp_var;
15299 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015300 (dictcomp_var = dictcomp_rule(p)) // dictcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015301 )
15302 {
15303 res = dictcomp_var;
15304 goto done;
15305 }
15306 p->mark = mark;
15307 }
15308 { // setcomp
15309 expr_ty setcomp_var;
15310 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015311 (setcomp_var = setcomp_rule(p)) // setcomp
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015312 )
15313 {
15314 res = setcomp_var;
15315 goto done;
15316 }
15317 p->mark = mark;
15318 }
15319 res = NULL;
15320 done:
15321 return res;
15322}
15323
Guido van Rossum3941d972020-05-01 09:42:03 -070015324// _loop1_99: STRING
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015325static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015326_loop1_99_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015327{
15328 if (p->error_indicator) {
15329 return NULL;
15330 }
15331 void *res = NULL;
15332 int mark = p->mark;
15333 int start_mark = p->mark;
15334 void **children = PyMem_Malloc(sizeof(void *));
15335 if (!children) {
15336 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15337 return NULL;
15338 }
15339 ssize_t children_capacity = 1;
15340 ssize_t n = 0;
15341 { // STRING
15342 expr_ty string_var;
15343 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015344 (string_var = _PyPegen_string_token(p)) // STRING
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015345 )
15346 {
15347 res = string_var;
15348 if (n == children_capacity) {
15349 children_capacity *= 2;
15350 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15351 if (!children) {
15352 PyErr_Format(PyExc_MemoryError, "realloc None");
15353 return NULL;
15354 }
15355 }
15356 children[n++] = res;
15357 mark = p->mark;
15358 }
15359 p->mark = mark;
15360 }
15361 if (n == 0) {
15362 PyMem_Free(children);
15363 return NULL;
15364 }
15365 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15366 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015367 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015368 PyMem_Free(children);
15369 return NULL;
15370 }
15371 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15372 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015373 _PyPegen_insert_memo(p, start_mark, _loop1_99_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015374 return seq;
15375}
15376
Guido van Rossum3941d972020-05-01 09:42:03 -070015377// _tmp_100: star_named_expression ',' star_named_expressions?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015378static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015379_tmp_100_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015380{
15381 if (p->error_indicator) {
15382 return NULL;
15383 }
15384 void * res = NULL;
15385 int mark = p->mark;
15386 { // star_named_expression ',' star_named_expressions?
Pablo Galindob796b3f2020-05-01 12:32:26 +010015387 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015388 expr_ty y;
15389 void *z;
15390 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015391 (y = star_named_expression_rule(p)) // star_named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015392 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015393 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015394 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015395 (z = star_named_expressions_rule(p), 1) // star_named_expressions?
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015396 )
15397 {
15398 res = _PyPegen_seq_insert_in_front ( p , y , z );
15399 if (res == NULL && PyErr_Occurred()) {
15400 p->error_indicator = 1;
15401 return NULL;
15402 }
15403 goto done;
15404 }
15405 p->mark = mark;
15406 }
15407 res = NULL;
15408 done:
15409 return res;
15410}
15411
Guido van Rossum3941d972020-05-01 09:42:03 -070015412// _tmp_101: yield_expr | named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015413static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015414_tmp_101_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015415{
15416 if (p->error_indicator) {
15417 return NULL;
15418 }
15419 void * res = NULL;
15420 int mark = p->mark;
15421 { // yield_expr
15422 expr_ty yield_expr_var;
15423 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015424 (yield_expr_var = yield_expr_rule(p)) // yield_expr
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015425 )
15426 {
15427 res = yield_expr_var;
15428 goto done;
15429 }
15430 p->mark = mark;
15431 }
15432 { // named_expression
15433 expr_ty named_expression_var;
15434 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015435 (named_expression_var = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015436 )
15437 {
15438 res = named_expression_var;
15439 goto done;
15440 }
15441 p->mark = mark;
15442 }
15443 res = NULL;
15444 done:
15445 return res;
15446}
15447
Guido van Rossum3941d972020-05-01 09:42:03 -070015448// _loop0_103: ',' kvpair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015449static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015450_loop0_103_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015451{
15452 if (p->error_indicator) {
15453 return NULL;
15454 }
15455 void *res = NULL;
15456 int mark = p->mark;
15457 int start_mark = p->mark;
15458 void **children = PyMem_Malloc(sizeof(void *));
15459 if (!children) {
15460 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15461 return NULL;
15462 }
15463 ssize_t children_capacity = 1;
15464 ssize_t n = 0;
15465 { // ',' kvpair
15466 KeyValuePair* elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015467 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015468 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015469 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015470 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015471 (elem = kvpair_rule(p)) // kvpair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015472 )
15473 {
15474 res = elem;
15475 if (res == NULL && PyErr_Occurred()) {
15476 p->error_indicator = 1;
15477 PyMem_Free(children);
15478 return NULL;
15479 }
15480 if (n == children_capacity) {
15481 children_capacity *= 2;
15482 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15483 if (!children) {
15484 PyErr_Format(PyExc_MemoryError, "realloc None");
15485 return NULL;
15486 }
15487 }
15488 children[n++] = res;
15489 mark = p->mark;
15490 }
15491 p->mark = mark;
15492 }
15493 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15494 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015495 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015496 PyMem_Free(children);
15497 return NULL;
15498 }
15499 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15500 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015501 _PyPegen_insert_memo(p, start_mark, _loop0_103_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015502 return seq;
15503}
15504
Guido van Rossum3941d972020-05-01 09:42:03 -070015505// _gather_102: kvpair _loop0_103
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015506static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015507_gather_102_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015508{
15509 if (p->error_indicator) {
15510 return NULL;
15511 }
15512 asdl_seq * res = NULL;
15513 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070015514 { // kvpair _loop0_103
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015515 KeyValuePair* elem;
15516 asdl_seq * seq;
15517 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015518 (elem = kvpair_rule(p)) // kvpair
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015519 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015520 (seq = _loop0_103_rule(p)) // _loop0_103
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015521 )
15522 {
15523 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15524 goto done;
15525 }
15526 p->mark = mark;
15527 }
15528 res = NULL;
15529 done:
15530 return res;
15531}
15532
Guido van Rossum3941d972020-05-01 09:42:03 -070015533// _loop1_104: for_if_clause
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015534static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015535_loop1_104_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015536{
15537 if (p->error_indicator) {
15538 return NULL;
15539 }
15540 void *res = NULL;
15541 int mark = p->mark;
15542 int start_mark = p->mark;
15543 void **children = PyMem_Malloc(sizeof(void *));
15544 if (!children) {
15545 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15546 return NULL;
15547 }
15548 ssize_t children_capacity = 1;
15549 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015550 { // for_if_clause
15551 comprehension_ty for_if_clause_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015552 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015553 (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015554 )
15555 {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015556 res = for_if_clause_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015557 if (n == children_capacity) {
15558 children_capacity *= 2;
15559 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15560 if (!children) {
15561 PyErr_Format(PyExc_MemoryError, "realloc None");
15562 return NULL;
15563 }
15564 }
15565 children[n++] = res;
15566 mark = p->mark;
15567 }
15568 p->mark = mark;
15569 }
15570 if (n == 0) {
15571 PyMem_Free(children);
15572 return NULL;
15573 }
15574 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15575 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015576 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015577 PyMem_Free(children);
15578 return NULL;
15579 }
15580 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15581 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015582 _PyPegen_insert_memo(p, start_mark, _loop1_104_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015583 return seq;
15584}
15585
Guido van Rossum3941d972020-05-01 09:42:03 -070015586// _loop0_105: ('if' disjunction)
Pablo Galindo2b74c832020-04-27 18:02:07 +010015587static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015588_loop0_105_rule(Parser *p)
Pablo Galindo2b74c832020-04-27 18:02:07 +010015589{
15590 if (p->error_indicator) {
15591 return NULL;
15592 }
15593 void *res = NULL;
15594 int mark = p->mark;
15595 int start_mark = p->mark;
15596 void **children = PyMem_Malloc(sizeof(void *));
15597 if (!children) {
15598 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15599 return NULL;
15600 }
15601 ssize_t children_capacity = 1;
15602 ssize_t n = 0;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015603 { // ('if' disjunction)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015604 void *_tmp_142_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +010015605 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015606 (_tmp_142_var = _tmp_142_rule(p)) // 'if' disjunction
Pablo Galindo2b74c832020-04-27 18:02:07 +010015607 )
15608 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015609 res = _tmp_142_var;
Pablo Galindo2b74c832020-04-27 18:02:07 +010015610 if (n == children_capacity) {
15611 children_capacity *= 2;
15612 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15613 if (!children) {
15614 PyErr_Format(PyExc_MemoryError, "realloc None");
15615 return NULL;
15616 }
15617 }
15618 children[n++] = res;
15619 mark = p->mark;
15620 }
15621 p->mark = mark;
15622 }
15623 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15624 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015625 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105");
Pablo Galindo2b74c832020-04-27 18:02:07 +010015626 PyMem_Free(children);
15627 return NULL;
15628 }
15629 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15630 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015631 _PyPegen_insert_memo(p, start_mark, _loop0_105_type, seq);
Pablo Galindo2b74c832020-04-27 18:02:07 +010015632 return seq;
15633}
15634
Guido van Rossum3941d972020-05-01 09:42:03 -070015635// _loop0_106: ('if' disjunction)
Guido van Rossumc001c092020-04-30 12:12:19 -070015636static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070015637_loop0_106_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015638{
15639 if (p->error_indicator) {
15640 return NULL;
15641 }
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015642 void *res = NULL;
Guido van Rossumc001c092020-04-30 12:12:19 -070015643 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015644 int start_mark = p->mark;
15645 void **children = PyMem_Malloc(sizeof(void *));
15646 if (!children) {
15647 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15648 return NULL;
15649 }
15650 ssize_t children_capacity = 1;
15651 ssize_t n = 0;
15652 { // ('if' disjunction)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015653 void *_tmp_143_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015654 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015655 (_tmp_143_var = _tmp_143_rule(p)) // 'if' disjunction
Guido van Rossumc001c092020-04-30 12:12:19 -070015656 )
15657 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030015658 res = _tmp_143_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015659 if (n == children_capacity) {
15660 children_capacity *= 2;
15661 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15662 if (!children) {
15663 PyErr_Format(PyExc_MemoryError, "realloc None");
15664 return NULL;
15665 }
15666 }
15667 children[n++] = res;
15668 mark = p->mark;
15669 }
15670 p->mark = mark;
15671 }
15672 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15673 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070015674 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106");
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015675 PyMem_Free(children);
15676 return NULL;
15677 }
15678 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15679 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070015680 _PyPegen_insert_memo(p, start_mark, _loop0_106_type, seq);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015681 return seq;
15682}
15683
Guido van Rossum3941d972020-05-01 09:42:03 -070015684// _tmp_107: ',' args
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015685static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015686_tmp_107_rule(Parser *p)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015687{
15688 if (p->error_indicator) {
15689 return NULL;
15690 }
15691 void * res = NULL;
15692 int mark = p->mark;
15693 { // ',' args
15694 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015695 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015696 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015697 (literal = _PyPegen_expect_token(p, 12)) // token=','
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015698 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015699 (c = args_rule(p)) // args
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015700 )
15701 {
15702 res = c;
15703 if (res == NULL && PyErr_Occurred()) {
15704 p->error_indicator = 1;
15705 return NULL;
15706 }
Guido van Rossumc001c092020-04-30 12:12:19 -070015707 goto done;
15708 }
15709 p->mark = mark;
15710 }
15711 res = NULL;
15712 done:
15713 return res;
15714}
15715
Guido van Rossum3941d972020-05-01 09:42:03 -070015716// _tmp_108: ',' args
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015717static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070015718_tmp_108_rule(Parser *p)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015719{
15720 if (p->error_indicator) {
15721 return NULL;
15722 }
15723 void * res = NULL;
15724 int mark = p->mark;
15725 { // ',' args
15726 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015727 Token * literal;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015728 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015729 (literal = _PyPegen_expect_token(p, 12)) // token=','
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015730 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015731 (c = args_rule(p)) // args
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015732 )
15733 {
15734 res = c;
15735 if (res == NULL && PyErr_Occurred()) {
15736 p->error_indicator = 1;
15737 return NULL;
15738 }
15739 goto done;
15740 }
15741 p->mark = mark;
15742 }
15743 res = NULL;
15744 done:
15745 return res;
15746}
15747
Guido van Rossum3941d972020-05-01 09:42:03 -070015748// _loop0_110: ',' kwarg_or_starred
15749static asdl_seq *
15750_loop0_110_rule(Parser *p)
15751{
15752 if (p->error_indicator) {
15753 return NULL;
15754 }
15755 void *res = NULL;
15756 int mark = p->mark;
15757 int start_mark = p->mark;
15758 void **children = PyMem_Malloc(sizeof(void *));
15759 if (!children) {
15760 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15761 return NULL;
15762 }
15763 ssize_t children_capacity = 1;
15764 ssize_t n = 0;
15765 { // ',' kwarg_or_starred
15766 KeywordOrStarred* elem;
15767 Token * literal;
15768 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015769 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossum3941d972020-05-01 09:42:03 -070015770 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015771 (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
Guido van Rossum3941d972020-05-01 09:42:03 -070015772 )
15773 {
15774 res = elem;
15775 if (res == NULL && PyErr_Occurred()) {
15776 p->error_indicator = 1;
15777 PyMem_Free(children);
15778 return NULL;
15779 }
15780 if (n == children_capacity) {
15781 children_capacity *= 2;
15782 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15783 if (!children) {
15784 PyErr_Format(PyExc_MemoryError, "realloc None");
15785 return NULL;
15786 }
15787 }
15788 children[n++] = res;
15789 mark = p->mark;
15790 }
15791 p->mark = mark;
15792 }
15793 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15794 if (!seq) {
15795 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110");
15796 PyMem_Free(children);
15797 return NULL;
15798 }
15799 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15800 PyMem_Free(children);
15801 _PyPegen_insert_memo(p, start_mark, _loop0_110_type, seq);
15802 return seq;
15803}
15804
15805// _gather_109: kwarg_or_starred _loop0_110
15806static asdl_seq *
15807_gather_109_rule(Parser *p)
15808{
15809 if (p->error_indicator) {
15810 return NULL;
15811 }
15812 asdl_seq * res = NULL;
15813 int mark = p->mark;
15814 { // kwarg_or_starred _loop0_110
15815 KeywordOrStarred* elem;
15816 asdl_seq * seq;
15817 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015818 (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
Guido van Rossum3941d972020-05-01 09:42:03 -070015819 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015820 (seq = _loop0_110_rule(p)) // _loop0_110
Guido van Rossum3941d972020-05-01 09:42:03 -070015821 )
15822 {
15823 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15824 goto done;
15825 }
15826 p->mark = mark;
15827 }
15828 res = NULL;
15829 done:
15830 return res;
15831}
15832
15833// _loop0_112: ',' kwarg_or_double_starred
15834static asdl_seq *
15835_loop0_112_rule(Parser *p)
15836{
15837 if (p->error_indicator) {
15838 return NULL;
15839 }
15840 void *res = NULL;
15841 int mark = p->mark;
15842 int start_mark = p->mark;
15843 void **children = PyMem_Malloc(sizeof(void *));
15844 if (!children) {
15845 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15846 return NULL;
15847 }
15848 ssize_t children_capacity = 1;
15849 ssize_t n = 0;
15850 { // ',' kwarg_or_double_starred
15851 KeywordOrStarred* elem;
15852 Token * literal;
15853 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015854 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossum3941d972020-05-01 09:42:03 -070015855 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015856 (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
Guido van Rossum3941d972020-05-01 09:42:03 -070015857 )
15858 {
15859 res = elem;
15860 if (res == NULL && PyErr_Occurred()) {
15861 p->error_indicator = 1;
15862 PyMem_Free(children);
15863 return NULL;
15864 }
15865 if (n == children_capacity) {
15866 children_capacity *= 2;
15867 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15868 if (!children) {
15869 PyErr_Format(PyExc_MemoryError, "realloc None");
15870 return NULL;
15871 }
15872 }
15873 children[n++] = res;
15874 mark = p->mark;
15875 }
15876 p->mark = mark;
15877 }
15878 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15879 if (!seq) {
15880 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112");
15881 PyMem_Free(children);
15882 return NULL;
15883 }
15884 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15885 PyMem_Free(children);
15886 _PyPegen_insert_memo(p, start_mark, _loop0_112_type, seq);
15887 return seq;
15888}
15889
15890// _gather_111: kwarg_or_double_starred _loop0_112
15891static asdl_seq *
15892_gather_111_rule(Parser *p)
15893{
15894 if (p->error_indicator) {
15895 return NULL;
15896 }
15897 asdl_seq * res = NULL;
15898 int mark = p->mark;
15899 { // kwarg_or_double_starred _loop0_112
15900 KeywordOrStarred* elem;
15901 asdl_seq * seq;
15902 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015903 (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
Guido van Rossum3941d972020-05-01 09:42:03 -070015904 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015905 (seq = _loop0_112_rule(p)) // _loop0_112
Guido van Rossum3941d972020-05-01 09:42:03 -070015906 )
15907 {
15908 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15909 goto done;
15910 }
15911 p->mark = mark;
15912 }
15913 res = NULL;
15914 done:
15915 return res;
15916}
15917
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015918// _loop0_114: ',' kwarg_or_starred
Pablo Galindo2b74c832020-04-27 18:02:07 +010015919static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015920_loop0_114_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010015921{
15922 if (p->error_indicator) {
15923 return NULL;
15924 }
15925 void *res = NULL;
15926 int mark = p->mark;
15927 int start_mark = p->mark;
15928 void **children = PyMem_Malloc(sizeof(void *));
15929 if (!children) {
15930 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
15931 return NULL;
15932 }
15933 ssize_t children_capacity = 1;
15934 ssize_t n = 0;
Guido van Rossumc001c092020-04-30 12:12:19 -070015935 { // ',' kwarg_or_starred
15936 KeywordOrStarred* elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010015937 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070015938 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010015939 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070015940 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015941 (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
Guido van Rossumc001c092020-04-30 12:12:19 -070015942 )
15943 {
15944 res = elem;
15945 if (res == NULL && PyErr_Occurred()) {
15946 p->error_indicator = 1;
15947 PyMem_Free(children);
15948 return NULL;
15949 }
15950 if (n == children_capacity) {
15951 children_capacity *= 2;
15952 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
15953 if (!children) {
15954 PyErr_Format(PyExc_MemoryError, "realloc None");
15955 return NULL;
15956 }
15957 }
15958 children[n++] = res;
15959 mark = p->mark;
15960 }
15961 p->mark = mark;
15962 }
15963 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
15964 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015965 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114");
Guido van Rossumc001c092020-04-30 12:12:19 -070015966 PyMem_Free(children);
15967 return NULL;
15968 }
15969 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
15970 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015971 _PyPegen_insert_memo(p, start_mark, _loop0_114_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070015972 return seq;
15973}
15974
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015975// _gather_113: kwarg_or_starred _loop0_114
Guido van Rossumc001c092020-04-30 12:12:19 -070015976static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015977_gather_113_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070015978{
15979 if (p->error_indicator) {
15980 return NULL;
15981 }
15982 asdl_seq * res = NULL;
15983 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030015984 { // kwarg_or_starred _loop0_114
Guido van Rossumc001c092020-04-30 12:12:19 -070015985 KeywordOrStarred* elem;
15986 asdl_seq * seq;
15987 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010015988 (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
Guido van Rossumc001c092020-04-30 12:12:19 -070015989 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010015990 (seq = _loop0_114_rule(p)) // _loop0_114
Guido van Rossumc001c092020-04-30 12:12:19 -070015991 )
15992 {
15993 res = _PyPegen_seq_insert_in_front(p, elem, seq);
15994 goto done;
15995 }
15996 p->mark = mark;
15997 }
15998 res = NULL;
15999 done:
16000 return res;
16001}
16002
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016003// _loop0_116: ',' kwarg_or_double_starred
Guido van Rossumc001c092020-04-30 12:12:19 -070016004static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016005_loop0_116_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070016006{
16007 if (p->error_indicator) {
16008 return NULL;
16009 }
16010 void *res = NULL;
16011 int mark = p->mark;
16012 int start_mark = p->mark;
16013 void **children = PyMem_Malloc(sizeof(void *));
16014 if (!children) {
16015 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16016 return NULL;
16017 }
16018 ssize_t children_capacity = 1;
16019 ssize_t n = 0;
16020 { // ',' kwarg_or_double_starred
16021 KeywordOrStarred* elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016022 Token * literal;
Guido van Rossumc001c092020-04-30 12:12:19 -070016023 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010016024 (literal = _PyPegen_expect_token(p, 12)) // token=','
Guido van Rossumc001c092020-04-30 12:12:19 -070016025 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016026 (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
Guido van Rossumc001c092020-04-30 12:12:19 -070016027 )
16028 {
16029 res = elem;
16030 if (res == NULL && PyErr_Occurred()) {
16031 p->error_indicator = 1;
16032 PyMem_Free(children);
16033 return NULL;
16034 }
16035 if (n == children_capacity) {
16036 children_capacity *= 2;
16037 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16038 if (!children) {
16039 PyErr_Format(PyExc_MemoryError, "realloc None");
16040 return NULL;
16041 }
16042 }
16043 children[n++] = res;
16044 mark = p->mark;
16045 }
16046 p->mark = mark;
16047 }
16048 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16049 if (!seq) {
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016050 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116");
Guido van Rossumc001c092020-04-30 12:12:19 -070016051 PyMem_Free(children);
16052 return NULL;
16053 }
16054 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16055 PyMem_Free(children);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016056 _PyPegen_insert_memo(p, start_mark, _loop0_116_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070016057 return seq;
16058}
16059
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016060// _gather_115: kwarg_or_double_starred _loop0_116
Guido van Rossumc001c092020-04-30 12:12:19 -070016061static asdl_seq *
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016062_gather_115_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070016063{
16064 if (p->error_indicator) {
16065 return NULL;
16066 }
16067 asdl_seq * res = NULL;
16068 int mark = p->mark;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016069 { // kwarg_or_double_starred _loop0_116
Guido van Rossumc001c092020-04-30 12:12:19 -070016070 KeywordOrStarred* elem;
16071 asdl_seq * seq;
16072 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016073 (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
Guido van Rossumc001c092020-04-30 12:12:19 -070016074 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016075 (seq = _loop0_116_rule(p)) // _loop0_116
Guido van Rossumc001c092020-04-30 12:12:19 -070016076 )
16077 {
16078 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16079 goto done;
16080 }
16081 p->mark = mark;
16082 }
16083 res = NULL;
16084 done:
16085 return res;
16086}
16087
Guido van Rossum3941d972020-05-01 09:42:03 -070016088// _loop0_117: (',' star_target)
Guido van Rossumc001c092020-04-30 12:12:19 -070016089static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016090_loop0_117_rule(Parser *p)
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016091{
16092 if (p->error_indicator) {
16093 return NULL;
16094 }
16095 void *res = NULL;
16096 int mark = p->mark;
16097 int start_mark = p->mark;
16098 void **children = PyMem_Malloc(sizeof(void *));
16099 if (!children) {
16100 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16101 return NULL;
16102 }
16103 ssize_t children_capacity = 1;
16104 ssize_t n = 0;
16105 { // (',' star_target)
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016106 void *_tmp_144_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016107 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010016108 (_tmp_144_var = _tmp_144_rule(p)) // ',' star_target
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016109 )
16110 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016111 res = _tmp_144_var;
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016112 if (n == children_capacity) {
16113 children_capacity *= 2;
16114 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16115 if (!children) {
16116 PyErr_Format(PyExc_MemoryError, "realloc None");
16117 return NULL;
16118 }
16119 }
16120 children[n++] = res;
16121 mark = p->mark;
16122 }
16123 p->mark = mark;
16124 }
16125 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16126 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016127 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117");
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016128 PyMem_Free(children);
16129 return NULL;
16130 }
16131 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16132 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016133 _PyPegen_insert_memo(p, start_mark, _loop0_117_type, seq);
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016134 return seq;
16135}
16136
Guido van Rossum3941d972020-05-01 09:42:03 -070016137// _loop0_119: ',' star_target
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030016138static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016139_loop0_119_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070016140{
16141 if (p->error_indicator) {
16142 return NULL;
16143 }
16144 void *res = NULL;
16145 int mark = p->mark;
16146 int start_mark = p->mark;
16147 void **children = PyMem_Malloc(sizeof(void *));
16148 if (!children) {
16149 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16150 return NULL;
16151 }
16152 ssize_t children_capacity = 1;
16153 ssize_t n = 0;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016154 { // ',' star_target
16155 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016156 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016157 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010016158 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016159 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016160 (elem = star_target_rule(p)) // star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016161 )
16162 {
16163 res = elem;
16164 if (res == NULL && PyErr_Occurred()) {
16165 p->error_indicator = 1;
16166 PyMem_Free(children);
16167 return NULL;
16168 }
16169 if (n == children_capacity) {
16170 children_capacity *= 2;
16171 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16172 if (!children) {
16173 PyErr_Format(PyExc_MemoryError, "realloc None");
16174 return NULL;
16175 }
16176 }
16177 children[n++] = res;
16178 mark = p->mark;
16179 }
16180 p->mark = mark;
16181 }
16182 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16183 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016184 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016185 PyMem_Free(children);
16186 return NULL;
16187 }
16188 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16189 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016190 _PyPegen_insert_memo(p, start_mark, _loop0_119_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016191 return seq;
16192}
16193
Guido van Rossum3941d972020-05-01 09:42:03 -070016194// _gather_118: star_target _loop0_119
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016195static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016196_gather_118_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016197{
16198 if (p->error_indicator) {
16199 return NULL;
16200 }
16201 asdl_seq * res = NULL;
16202 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070016203 { // star_target _loop0_119
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016204 expr_ty elem;
16205 asdl_seq * seq;
16206 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016207 (elem = star_target_rule(p)) // star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016208 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016209 (seq = _loop0_119_rule(p)) // _loop0_119
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016210 )
16211 {
16212 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16213 goto done;
16214 }
16215 p->mark = mark;
16216 }
16217 res = NULL;
16218 done:
16219 return res;
16220}
16221
Guido van Rossum3941d972020-05-01 09:42:03 -070016222// _tmp_120: !'*' star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016223static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016224_tmp_120_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016225{
16226 if (p->error_indicator) {
16227 return NULL;
16228 }
16229 void * res = NULL;
16230 int mark = p->mark;
16231 { // !'*' star_target
16232 expr_ty star_target_var;
16233 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016234 _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016235 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016236 (star_target_var = star_target_rule(p)) // star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016237 )
16238 {
16239 res = star_target_var;
16240 goto done;
16241 }
16242 p->mark = mark;
16243 }
16244 res = NULL;
16245 done:
16246 return res;
16247}
16248
Guido van Rossum3941d972020-05-01 09:42:03 -070016249// _loop0_122: ',' del_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016250static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016251_loop0_122_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016252{
16253 if (p->error_indicator) {
16254 return NULL;
16255 }
16256 void *res = NULL;
16257 int mark = p->mark;
16258 int start_mark = p->mark;
16259 void **children = PyMem_Malloc(sizeof(void *));
16260 if (!children) {
16261 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16262 return NULL;
16263 }
16264 ssize_t children_capacity = 1;
16265 ssize_t n = 0;
16266 { // ',' del_target
16267 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016268 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016269 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010016270 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016271 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016272 (elem = del_target_rule(p)) // del_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016273 )
16274 {
16275 res = elem;
16276 if (res == NULL && PyErr_Occurred()) {
16277 p->error_indicator = 1;
16278 PyMem_Free(children);
16279 return NULL;
16280 }
16281 if (n == children_capacity) {
16282 children_capacity *= 2;
16283 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16284 if (!children) {
16285 PyErr_Format(PyExc_MemoryError, "realloc None");
16286 return NULL;
16287 }
16288 }
16289 children[n++] = res;
16290 mark = p->mark;
16291 }
16292 p->mark = mark;
16293 }
16294 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16295 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016296 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016297 PyMem_Free(children);
16298 return NULL;
16299 }
16300 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16301 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016302 _PyPegen_insert_memo(p, start_mark, _loop0_122_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016303 return seq;
16304}
16305
Guido van Rossum3941d972020-05-01 09:42:03 -070016306// _gather_121: del_target _loop0_122
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016307static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016308_gather_121_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016309{
16310 if (p->error_indicator) {
16311 return NULL;
16312 }
16313 asdl_seq * res = NULL;
16314 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070016315 { // del_target _loop0_122
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016316 expr_ty elem;
16317 asdl_seq * seq;
16318 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016319 (elem = del_target_rule(p)) // del_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016320 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016321 (seq = _loop0_122_rule(p)) // _loop0_122
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016322 )
16323 {
16324 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16325 goto done;
16326 }
16327 p->mark = mark;
16328 }
16329 res = NULL;
16330 done:
16331 return res;
16332}
16333
Guido van Rossum3941d972020-05-01 09:42:03 -070016334// _loop0_124: ',' target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016335static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016336_loop0_124_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016337{
16338 if (p->error_indicator) {
16339 return NULL;
16340 }
16341 void *res = NULL;
16342 int mark = p->mark;
16343 int start_mark = p->mark;
16344 void **children = PyMem_Malloc(sizeof(void *));
16345 if (!children) {
16346 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16347 return NULL;
16348 }
16349 ssize_t children_capacity = 1;
16350 ssize_t n = 0;
16351 { // ',' target
16352 expr_ty elem;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016353 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016354 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010016355 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016356 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016357 (elem = target_rule(p)) // target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016358 )
16359 {
16360 res = elem;
16361 if (res == NULL && PyErr_Occurred()) {
16362 p->error_indicator = 1;
16363 PyMem_Free(children);
16364 return NULL;
16365 }
16366 if (n == children_capacity) {
16367 children_capacity *= 2;
16368 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16369 if (!children) {
16370 PyErr_Format(PyExc_MemoryError, "realloc None");
16371 return NULL;
16372 }
16373 }
16374 children[n++] = res;
16375 mark = p->mark;
16376 }
16377 p->mark = mark;
16378 }
16379 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16380 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016381 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124");
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016382 PyMem_Free(children);
16383 return NULL;
16384 }
16385 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16386 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016387 _PyPegen_insert_memo(p, start_mark, _loop0_124_type, seq);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016388 return seq;
16389}
16390
Guido van Rossum3941d972020-05-01 09:42:03 -070016391// _gather_123: target _loop0_124
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016392static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016393_gather_123_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016394{
16395 if (p->error_indicator) {
16396 return NULL;
16397 }
16398 asdl_seq * res = NULL;
16399 int mark = p->mark;
Guido van Rossum3941d972020-05-01 09:42:03 -070016400 { // target _loop0_124
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016401 expr_ty elem;
16402 asdl_seq * seq;
16403 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016404 (elem = target_rule(p)) // target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016405 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016406 (seq = _loop0_124_rule(p)) // _loop0_124
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016407 )
16408 {
16409 res = _PyPegen_seq_insert_in_front(p, elem, seq);
16410 goto done;
16411 }
16412 p->mark = mark;
16413 }
16414 res = NULL;
16415 done:
16416 return res;
16417}
16418
Guido van Rossum3941d972020-05-01 09:42:03 -070016419// _tmp_125: args | expression for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016420static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016421_tmp_125_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016422{
16423 if (p->error_indicator) {
16424 return NULL;
16425 }
16426 void * res = NULL;
16427 int mark = p->mark;
16428 { // args
16429 expr_ty args_var;
16430 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016431 (args_var = args_rule(p)) // args
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016432 )
16433 {
16434 res = args_var;
16435 goto done;
16436 }
16437 p->mark = mark;
16438 }
16439 { // expression for_if_clauses
16440 expr_ty expression_var;
16441 asdl_seq* for_if_clauses_var;
16442 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016443 (expression_var = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016444 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016445 (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016446 )
16447 {
16448 res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var);
16449 goto done;
16450 }
16451 p->mark = mark;
16452 }
16453 res = NULL;
16454 done:
16455 return res;
16456}
16457
Guido van Rossum3941d972020-05-01 09:42:03 -070016458// _tmp_126: '=' annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016459static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016460_tmp_126_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016461{
16462 if (p->error_indicator) {
16463 return NULL;
16464 }
16465 void * res = NULL;
16466 int mark = p->mark;
16467 { // '=' annotated_rhs
16468 expr_ty annotated_rhs_var;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016469 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016470 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016471 (literal = _PyPegen_expect_token(p, 22)) // token='='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016472 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016473 (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016474 )
16475 {
16476 res = _PyPegen_dummy_name(p, literal, annotated_rhs_var);
16477 goto done;
16478 }
16479 p->mark = mark;
16480 }
16481 res = NULL;
16482 done:
16483 return res;
16484}
16485
Guido van Rossum3941d972020-05-01 09:42:03 -070016486// _tmp_127: '=' | augassign
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016487static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016488_tmp_127_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016489{
16490 if (p->error_indicator) {
16491 return NULL;
16492 }
16493 void * res = NULL;
16494 int mark = p->mark;
16495 { // '='
Pablo Galindob796b3f2020-05-01 12:32:26 +010016496 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016497 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016498 (literal = _PyPegen_expect_token(p, 22)) // token='='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016499 )
16500 {
16501 res = literal;
16502 goto done;
16503 }
16504 p->mark = mark;
16505 }
16506 { // augassign
16507 AugOperator* augassign_var;
16508 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016509 (augassign_var = augassign_rule(p)) // augassign
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016510 )
16511 {
16512 res = augassign_var;
16513 goto done;
16514 }
16515 p->mark = mark;
16516 }
16517 res = NULL;
16518 done:
16519 return res;
16520}
16521
Guido van Rossum3941d972020-05-01 09:42:03 -070016522// _tmp_128: yield_expr | star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016523static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016524_tmp_128_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016525{
16526 if (p->error_indicator) {
16527 return NULL;
16528 }
16529 void * res = NULL;
16530 int mark = p->mark;
16531 { // yield_expr
16532 expr_ty yield_expr_var;
16533 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016534 (yield_expr_var = yield_expr_rule(p)) // yield_expr
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016535 )
16536 {
16537 res = yield_expr_var;
16538 goto done;
16539 }
16540 p->mark = mark;
16541 }
16542 { // star_expressions
16543 expr_ty star_expressions_var;
16544 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016545 (star_expressions_var = star_expressions_rule(p)) // star_expressions
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016546 )
16547 {
16548 res = star_expressions_var;
16549 goto done;
16550 }
16551 p->mark = mark;
16552 }
16553 res = NULL;
16554 done:
16555 return res;
16556}
16557
Guido van Rossum3941d972020-05-01 09:42:03 -070016558// _tmp_129: '[' | '(' | '{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016559static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016560_tmp_129_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016561{
16562 if (p->error_indicator) {
16563 return NULL;
16564 }
16565 void * res = NULL;
16566 int mark = p->mark;
16567 { // '['
Pablo Galindob796b3f2020-05-01 12:32:26 +010016568 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016569 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016570 (literal = _PyPegen_expect_token(p, 9)) // token='['
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016571 )
16572 {
16573 res = literal;
16574 goto done;
16575 }
16576 p->mark = mark;
16577 }
16578 { // '('
Pablo Galindob796b3f2020-05-01 12:32:26 +010016579 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016580 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016581 (literal = _PyPegen_expect_token(p, 7)) // token='('
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016582 )
16583 {
16584 res = literal;
16585 goto done;
16586 }
16587 p->mark = mark;
16588 }
16589 { // '{'
Pablo Galindob796b3f2020-05-01 12:32:26 +010016590 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016591 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016592 (literal = _PyPegen_expect_token(p, 25)) // token='{'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016593 )
16594 {
16595 res = literal;
16596 goto done;
16597 }
16598 p->mark = mark;
16599 }
16600 res = NULL;
16601 done:
16602 return res;
16603}
16604
Guido van Rossum3941d972020-05-01 09:42:03 -070016605// _loop0_130: param_no_default
Guido van Rossumc001c092020-04-30 12:12:19 -070016606static asdl_seq *
Guido van Rossum3941d972020-05-01 09:42:03 -070016607_loop0_130_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016608{
16609 if (p->error_indicator) {
16610 return NULL;
16611 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016612 void *res = NULL;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016613 int mark = p->mark;
Guido van Rossumc001c092020-04-30 12:12:19 -070016614 int start_mark = p->mark;
16615 void **children = PyMem_Malloc(sizeof(void *));
16616 if (!children) {
16617 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
16618 return NULL;
16619 }
16620 ssize_t children_capacity = 1;
16621 ssize_t n = 0;
16622 { // param_no_default
16623 arg_ty param_no_default_var;
16624 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010016625 (param_no_default_var = param_no_default_rule(p)) // param_no_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016626 )
16627 {
Guido van Rossumc001c092020-04-30 12:12:19 -070016628 res = param_no_default_var;
16629 if (n == children_capacity) {
16630 children_capacity *= 2;
16631 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
16632 if (!children) {
16633 PyErr_Format(PyExc_MemoryError, "realloc None");
16634 return NULL;
16635 }
16636 }
16637 children[n++] = res;
16638 mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016639 }
16640 p->mark = mark;
16641 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016642 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
16643 if (!seq) {
Guido van Rossum3941d972020-05-01 09:42:03 -070016644 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_130");
Guido van Rossumc001c092020-04-30 12:12:19 -070016645 PyMem_Free(children);
16646 return NULL;
16647 }
16648 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
16649 PyMem_Free(children);
Guido van Rossum3941d972020-05-01 09:42:03 -070016650 _PyPegen_insert_memo(p, start_mark, _loop0_130_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070016651 return seq;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016652}
16653
Guido van Rossum3941d972020-05-01 09:42:03 -070016654// _tmp_131: slash_with_default | param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016655static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016656_tmp_131_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016657{
16658 if (p->error_indicator) {
16659 return NULL;
16660 }
16661 void * res = NULL;
16662 int mark = p->mark;
16663 { // slash_with_default
16664 SlashWithDefault* slash_with_default_var;
16665 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016666 (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016667 )
16668 {
16669 res = slash_with_default_var;
16670 goto done;
16671 }
16672 p->mark = mark;
16673 }
Guido van Rossumc001c092020-04-30 12:12:19 -070016674 { // param_with_default+
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016675 asdl_seq * _loop1_145_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016676 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016677 (_loop1_145_var = _loop1_145_rule(p)) // param_with_default+
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016678 )
16679 {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016680 res = _loop1_145_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016681 goto done;
16682 }
16683 p->mark = mark;
16684 }
16685 res = NULL;
16686 done:
16687 return res;
16688}
16689
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016690// _tmp_132: ')' | ',' (')' | '**')
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016691static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016692_tmp_132_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016693{
16694 if (p->error_indicator) {
16695 return NULL;
16696 }
16697 void * res = NULL;
16698 int mark = p->mark;
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016699 { // ')'
16700 Token * literal;
16701 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016702 (literal = _PyPegen_expect_token(p, 8)) // token=')'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016703 )
16704 {
16705 res = literal;
16706 goto done;
16707 }
16708 p->mark = mark;
16709 }
16710 { // ',' (')' | '**')
16711 void *_tmp_146_var;
16712 Token * literal;
16713 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016714 (literal = _PyPegen_expect_token(p, 12)) // token=','
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016715 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016716 (_tmp_146_var = _tmp_146_rule(p)) // ')' | '**'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016717 )
16718 {
16719 res = _PyPegen_dummy_name(p, literal, _tmp_146_var);
16720 goto done;
16721 }
16722 p->mark = mark;
16723 }
16724 res = NULL;
16725 done:
16726 return res;
16727}
16728
16729// _tmp_133: ':' | ',' (':' | '**')
16730static void *
16731_tmp_133_rule(Parser *p)
16732{
16733 if (p->error_indicator) {
16734 return NULL;
16735 }
16736 void * res = NULL;
16737 int mark = p->mark;
16738 { // ':'
16739 Token * literal;
16740 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016741 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016742 )
16743 {
16744 res = literal;
16745 goto done;
16746 }
16747 p->mark = mark;
16748 }
16749 { // ',' (':' | '**')
16750 void *_tmp_147_var;
16751 Token * literal;
16752 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016753 (literal = _PyPegen_expect_token(p, 12)) // token=','
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016754 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016755 (_tmp_147_var = _tmp_147_rule(p)) // ':' | '**'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016756 )
16757 {
16758 res = _PyPegen_dummy_name(p, literal, _tmp_147_var);
16759 goto done;
16760 }
16761 p->mark = mark;
16762 }
16763 res = NULL;
16764 done:
16765 return res;
16766}
16767
16768// _tmp_134: star_targets '='
16769static void *
16770_tmp_134_rule(Parser *p)
16771{
16772 if (p->error_indicator) {
16773 return NULL;
16774 }
16775 void * res = NULL;
16776 int mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016777 { // star_targets '='
Pablo Galindob796b3f2020-05-01 12:32:26 +010016778 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016779 expr_ty z;
16780 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016781 (z = star_targets_rule(p)) // star_targets
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016782 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016783 (literal = _PyPegen_expect_token(p, 22)) // token='='
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016784 )
16785 {
16786 res = z;
16787 if (res == NULL && PyErr_Occurred()) {
16788 p->error_indicator = 1;
16789 return NULL;
16790 }
16791 goto done;
16792 }
16793 p->mark = mark;
16794 }
16795 res = NULL;
16796 done:
16797 return res;
16798}
16799
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016800// _tmp_135: '.' | '...'
Pablo Galindo2b74c832020-04-27 18:02:07 +010016801static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070016802_tmp_135_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016803{
16804 if (p->error_indicator) {
16805 return NULL;
16806 }
16807 void * res = NULL;
16808 int mark = p->mark;
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016809 { // '.'
16810 Token * literal;
16811 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016812 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016813 )
16814 {
16815 res = literal;
16816 goto done;
16817 }
16818 p->mark = mark;
16819 }
16820 { // '...'
16821 Token * literal;
16822 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016823 (literal = _PyPegen_expect_token(p, 52)) // token='...'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016824 )
16825 {
16826 res = literal;
16827 goto done;
16828 }
16829 p->mark = mark;
16830 }
16831 res = NULL;
16832 done:
16833 return res;
16834}
16835
16836// _tmp_136: '.' | '...'
16837static void *
16838_tmp_136_rule(Parser *p)
16839{
16840 if (p->error_indicator) {
16841 return NULL;
16842 }
16843 void * res = NULL;
16844 int mark = p->mark;
16845 { // '.'
16846 Token * literal;
16847 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016848 (literal = _PyPegen_expect_token(p, 23)) // token='.'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016849 )
16850 {
16851 res = literal;
16852 goto done;
16853 }
16854 p->mark = mark;
16855 }
16856 { // '...'
16857 Token * literal;
16858 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016859 (literal = _PyPegen_expect_token(p, 52)) // token='...'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016860 )
16861 {
16862 res = literal;
16863 goto done;
16864 }
16865 p->mark = mark;
16866 }
16867 res = NULL;
16868 done:
16869 return res;
16870}
16871
16872// _tmp_137: '@' named_expression NEWLINE
16873static void *
16874_tmp_137_rule(Parser *p)
16875{
16876 if (p->error_indicator) {
16877 return NULL;
16878 }
16879 void * res = NULL;
16880 int mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016881 { // '@' named_expression NEWLINE
16882 expr_ty f;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016883 Token * literal;
16884 Token * newline_var;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016885 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016886 (literal = _PyPegen_expect_token(p, 49)) // token='@'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016887 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016888 (f = named_expression_rule(p)) // named_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016889 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016890 (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016891 )
16892 {
16893 res = f;
16894 if (res == NULL && PyErr_Occurred()) {
16895 p->error_indicator = 1;
16896 return NULL;
16897 }
16898 goto done;
16899 }
16900 p->mark = mark;
16901 }
16902 res = NULL;
16903 done:
16904 return res;
16905}
16906
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016907// _tmp_138: ',' star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016908static void *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016909_tmp_138_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016910{
16911 if (p->error_indicator) {
16912 return NULL;
16913 }
16914 void * res = NULL;
16915 int mark = p->mark;
16916 { // ',' star_expression
16917 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016918 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016919 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016920 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016921 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016922 (c = star_expression_rule(p)) // star_expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016923 )
16924 {
16925 res = c;
16926 if (res == NULL && PyErr_Occurred()) {
16927 p->error_indicator = 1;
16928 return NULL;
16929 }
16930 goto done;
16931 }
16932 p->mark = mark;
16933 }
16934 res = NULL;
16935 done:
16936 return res;
16937}
16938
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016939// _tmp_139: ',' expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016940static void *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016941_tmp_139_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016942{
16943 if (p->error_indicator) {
16944 return NULL;
16945 }
16946 void * res = NULL;
16947 int mark = p->mark;
16948 { // ',' expression
16949 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016950 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016951 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016952 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016953 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016954 (c = expression_rule(p)) // expression
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016955 )
16956 {
16957 res = c;
16958 if (res == NULL && PyErr_Occurred()) {
16959 p->error_indicator = 1;
16960 return NULL;
16961 }
16962 goto done;
16963 }
16964 p->mark = mark;
16965 }
16966 res = NULL;
16967 done:
16968 return res;
16969}
16970
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016971// _tmp_140: 'or' conjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016972static void *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030016973_tmp_140_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016974{
16975 if (p->error_indicator) {
16976 return NULL;
16977 }
16978 void * res = NULL;
16979 int mark = p->mark;
16980 { // 'or' conjunction
16981 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010016982 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016983 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010016984 (keyword = _PyPegen_expect_token(p, 532)) // token='or'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016985 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010016986 (c = conjunction_rule(p)) // conjunction
Pablo Galindoc5fc1562020-04-22 23:29:27 +010016987 )
16988 {
16989 res = c;
16990 if (res == NULL && PyErr_Occurred()) {
16991 p->error_indicator = 1;
16992 return NULL;
16993 }
16994 goto done;
16995 }
16996 p->mark = mark;
16997 }
16998 res = NULL;
16999 done:
17000 return res;
17001}
17002
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017003// _tmp_141: 'and' inversion
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017004static void *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017005_tmp_141_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017006{
17007 if (p->error_indicator) {
17008 return NULL;
17009 }
17010 void * res = NULL;
17011 int mark = p->mark;
17012 { // 'and' inversion
17013 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010017014 Token * keyword;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017015 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010017016 (keyword = _PyPegen_expect_token(p, 533)) // token='and'
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017017 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010017018 (c = inversion_rule(p)) // inversion
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017019 )
17020 {
17021 res = c;
17022 if (res == NULL && PyErr_Occurred()) {
17023 p->error_indicator = 1;
17024 return NULL;
17025 }
17026 goto done;
17027 }
17028 p->mark = mark;
17029 }
17030 res = NULL;
17031 done:
17032 return res;
17033}
17034
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017035// _tmp_142: 'if' disjunction
Lysandros Nikolaou3e0a6f32020-05-01 06:27:52 +030017036static void *
Guido van Rossum3941d972020-05-01 09:42:03 -070017037_tmp_142_rule(Parser *p)
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017038{
17039 if (p->error_indicator) {
17040 return NULL;
17041 }
17042 void * res = NULL;
17043 int mark = p->mark;
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017044 { // 'if' disjunction
17045 Token * keyword;
17046 expr_ty z;
17047 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010017048 (keyword = _PyPegen_expect_token(p, 510)) // token='if'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017049 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010017050 (z = disjunction_rule(p)) // disjunction
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017051 )
17052 {
17053 res = z;
17054 if (res == NULL && PyErr_Occurred()) {
17055 p->error_indicator = 1;
17056 return NULL;
17057 }
17058 goto done;
17059 }
17060 p->mark = mark;
17061 }
17062 res = NULL;
17063 done:
17064 return res;
17065}
17066
17067// _tmp_143: 'if' disjunction
17068static void *
17069_tmp_143_rule(Parser *p)
17070{
17071 if (p->error_indicator) {
17072 return NULL;
17073 }
17074 void * res = NULL;
17075 int mark = p->mark;
17076 { // 'if' disjunction
17077 Token * keyword;
17078 expr_ty z;
17079 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010017080 (keyword = _PyPegen_expect_token(p, 510)) // token='if'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017081 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010017082 (z = disjunction_rule(p)) // disjunction
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017083 )
17084 {
17085 res = z;
17086 if (res == NULL && PyErr_Occurred()) {
17087 p->error_indicator = 1;
17088 return NULL;
17089 }
17090 goto done;
17091 }
17092 p->mark = mark;
17093 }
17094 res = NULL;
17095 done:
17096 return res;
17097}
17098
17099// _tmp_144: ',' star_target
17100static void *
17101_tmp_144_rule(Parser *p)
17102{
17103 if (p->error_indicator) {
17104 return NULL;
17105 }
17106 void * res = NULL;
17107 int mark = p->mark;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017108 { // ',' star_target
17109 expr_ty c;
Pablo Galindob796b3f2020-05-01 12:32:26 +010017110 Token * literal;
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017111 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010017112 (literal = _PyPegen_expect_token(p, 12)) // token=','
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017113 &&
Pablo Galindo470aac42020-05-06 23:14:43 +010017114 (c = star_target_rule(p)) // star_target
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017115 )
17116 {
17117 res = c;
17118 if (res == NULL && PyErr_Occurred()) {
17119 p->error_indicator = 1;
17120 return NULL;
17121 }
17122 goto done;
17123 }
17124 p->mark = mark;
17125 }
17126 res = NULL;
17127 done:
17128 return res;
17129}
17130
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017131// _loop1_145: param_with_default
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017132static asdl_seq *
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017133_loop1_145_rule(Parser *p)
Guido van Rossumc001c092020-04-30 12:12:19 -070017134{
17135 if (p->error_indicator) {
17136 return NULL;
17137 }
17138 void *res = NULL;
17139 int mark = p->mark;
17140 int start_mark = p->mark;
17141 void **children = PyMem_Malloc(sizeof(void *));
17142 if (!children) {
17143 PyErr_Format(PyExc_MemoryError, "Parser out of memory");
17144 return NULL;
17145 }
17146 ssize_t children_capacity = 1;
17147 ssize_t n = 0;
17148 { // param_with_default
17149 NameDefaultPair* param_with_default_var;
17150 while (
Pablo Galindo470aac42020-05-06 23:14:43 +010017151 (param_with_default_var = param_with_default_rule(p)) // param_with_default
Guido van Rossumc001c092020-04-30 12:12:19 -070017152 )
17153 {
17154 res = param_with_default_var;
17155 if (n == children_capacity) {
17156 children_capacity *= 2;
17157 children = PyMem_Realloc(children, children_capacity*sizeof(void *));
17158 if (!children) {
17159 PyErr_Format(PyExc_MemoryError, "realloc None");
17160 return NULL;
17161 }
17162 }
17163 children[n++] = res;
17164 mark = p->mark;
17165 }
17166 p->mark = mark;
17167 }
17168 if (n == 0) {
17169 PyMem_Free(children);
17170 return NULL;
17171 }
17172 asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
17173 if (!seq) {
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017174 PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_145");
Guido van Rossumc001c092020-04-30 12:12:19 -070017175 PyMem_Free(children);
17176 return NULL;
17177 }
17178 for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
17179 PyMem_Free(children);
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017180 _PyPegen_insert_memo(p, start_mark, _loop1_145_type, seq);
Guido van Rossumc001c092020-04-30 12:12:19 -070017181 return seq;
17182}
17183
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017184// _tmp_146: ')' | '**'
17185static void *
17186_tmp_146_rule(Parser *p)
17187{
17188 if (p->error_indicator) {
17189 return NULL;
17190 }
17191 void * res = NULL;
17192 int mark = p->mark;
17193 { // ')'
17194 Token * literal;
17195 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010017196 (literal = _PyPegen_expect_token(p, 8)) // token=')'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017197 )
17198 {
17199 res = literal;
17200 goto done;
17201 }
17202 p->mark = mark;
17203 }
17204 { // '**'
17205 Token * literal;
17206 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010017207 (literal = _PyPegen_expect_token(p, 35)) // token='**'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017208 )
17209 {
17210 res = literal;
17211 goto done;
17212 }
17213 p->mark = mark;
17214 }
17215 res = NULL;
17216 done:
17217 return res;
17218}
17219
17220// _tmp_147: ':' | '**'
17221static void *
17222_tmp_147_rule(Parser *p)
17223{
17224 if (p->error_indicator) {
17225 return NULL;
17226 }
17227 void * res = NULL;
17228 int mark = p->mark;
17229 { // ':'
17230 Token * literal;
17231 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010017232 (literal = _PyPegen_expect_token(p, 11)) // token=':'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017233 )
17234 {
17235 res = literal;
17236 goto done;
17237 }
17238 p->mark = mark;
17239 }
17240 { // '**'
17241 Token * literal;
17242 if (
Pablo Galindo470aac42020-05-06 23:14:43 +010017243 (literal = _PyPegen_expect_token(p, 35)) // token='**'
Lysandros Nikolaoue10e7c72020-05-04 13:58:31 +030017244 )
17245 {
17246 res = literal;
17247 goto done;
17248 }
17249 p->mark = mark;
17250 }
17251 res = NULL;
17252 done:
17253 return res;
17254}
17255
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017256void *
17257_PyPegen_parse(Parser *p)
17258{
17259 // Initialize keywords
17260 p->keywords = reserved_keywords;
17261 p->n_keyword_lists = n_keyword_lists;
17262
17263 // Run parser
17264 void *result = NULL;
17265 if (p->start_rule == Py_file_input) {
17266 result = file_rule(p);
17267 } else if (p->start_rule == Py_single_input) {
17268 result = interactive_rule(p);
17269 } else if (p->start_rule == Py_eval_input) {
17270 result = eval_rule(p);
Guido van Rossumc001c092020-04-30 12:12:19 -070017271 } else if (p->start_rule == Py_func_type_input) {
17272 result = func_type_rule(p);
Pablo Galindoc5fc1562020-04-22 23:29:27 +010017273 } else if (p->start_rule == Py_fstring_input) {
17274 result = fstring_rule(p);
17275 }
17276
17277 return result;
17278}
17279
17280// The end