17281 lines
474 KiB
C
17281 lines
474 KiB
C
// @generated by pegen.py from ./Grammar/python.gram
|
|
#include "pegen.h"
|
|
static const int n_keyword_lists = 15;
|
|
static KeywordToken *reserved_keywords[] = {
|
|
NULL,
|
|
NULL,
|
|
(KeywordToken[]) {
|
|
{"if", 510},
|
|
{"in", 518},
|
|
{"is", 526},
|
|
{"as", 531},
|
|
{"or", 532},
|
|
{NULL, -1},
|
|
},
|
|
(KeywordToken[]) {
|
|
{"del", 503},
|
|
{"try", 511},
|
|
{"for", 517},
|
|
{"def", 522},
|
|
{"not", 525},
|
|
{"and", 533},
|
|
{NULL, -1},
|
|
},
|
|
(KeywordToken[]) {
|
|
{"pass", 502},
|
|
{"from", 514},
|
|
{"elif", 515},
|
|
{"else", 516},
|
|
{"with", 519},
|
|
{"True", 527},
|
|
{"None", 529},
|
|
{NULL, -1},
|
|
},
|
|
(KeywordToken[]) {
|
|
{"raise", 501},
|
|
{"yield", 504},
|
|
{"break", 506},
|
|
{"while", 512},
|
|
{"class", 523},
|
|
{"False", 528},
|
|
{NULL, -1},
|
|
},
|
|
(KeywordToken[]) {
|
|
{"return", 500},
|
|
{"assert", 505},
|
|
{"global", 508},
|
|
{"import", 513},
|
|
{"except", 520},
|
|
{"lambda", 524},
|
|
{NULL, -1},
|
|
},
|
|
(KeywordToken[]) {
|
|
{"finally", 521},
|
|
{NULL, -1},
|
|
},
|
|
(KeywordToken[]) {
|
|
{"continue", 507},
|
|
{"nonlocal", 509},
|
|
{NULL, -1},
|
|
},
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
(KeywordToken[]) {
|
|
{"__new_parser__", 530},
|
|
{NULL, -1},
|
|
},
|
|
};
|
|
#define file_type 1000
|
|
#define interactive_type 1001
|
|
#define eval_type 1002
|
|
#define func_type_type 1003
|
|
#define fstring_type 1004
|
|
#define type_expressions_type 1005
|
|
#define statements_type 1006
|
|
#define statement_type 1007
|
|
#define statement_newline_type 1008
|
|
#define simple_stmt_type 1009
|
|
#define small_stmt_type 1010
|
|
#define compound_stmt_type 1011
|
|
#define assignment_type 1012
|
|
#define augassign_type 1013
|
|
#define global_stmt_type 1014
|
|
#define nonlocal_stmt_type 1015
|
|
#define yield_stmt_type 1016
|
|
#define assert_stmt_type 1017
|
|
#define del_stmt_type 1018
|
|
#define import_stmt_type 1019
|
|
#define import_name_type 1020
|
|
#define import_from_type 1021
|
|
#define import_from_targets_type 1022
|
|
#define import_from_as_names_type 1023
|
|
#define import_from_as_name_type 1024
|
|
#define dotted_as_names_type 1025
|
|
#define dotted_as_name_type 1026
|
|
#define dotted_name_type 1027 // Left-recursive
|
|
#define if_stmt_type 1028
|
|
#define elif_stmt_type 1029
|
|
#define else_block_type 1030
|
|
#define while_stmt_type 1031
|
|
#define for_stmt_type 1032
|
|
#define with_stmt_type 1033
|
|
#define with_item_type 1034
|
|
#define try_stmt_type 1035
|
|
#define except_block_type 1036
|
|
#define finally_block_type 1037
|
|
#define return_stmt_type 1038
|
|
#define raise_stmt_type 1039
|
|
#define function_def_type 1040
|
|
#define function_def_raw_type 1041
|
|
#define func_type_comment_type 1042
|
|
#define params_type 1043
|
|
#define parameters_type 1044
|
|
#define slash_no_default_type 1045
|
|
#define slash_with_default_type 1046
|
|
#define star_etc_type 1047
|
|
#define kwds_type 1048
|
|
#define param_no_default_type 1049
|
|
#define param_with_default_type 1050
|
|
#define param_maybe_default_type 1051
|
|
#define param_type 1052
|
|
#define annotation_type 1053
|
|
#define default_type 1054
|
|
#define decorators_type 1055
|
|
#define class_def_type 1056
|
|
#define class_def_raw_type 1057
|
|
#define block_type 1058
|
|
#define expressions_list_type 1059
|
|
#define star_expressions_type 1060
|
|
#define star_expression_type 1061
|
|
#define star_named_expressions_type 1062
|
|
#define star_named_expression_type 1063
|
|
#define named_expression_type 1064
|
|
#define annotated_rhs_type 1065
|
|
#define expressions_type 1066
|
|
#define expression_type 1067
|
|
#define lambdef_type 1068
|
|
#define lambda_parameters_type 1069
|
|
#define lambda_slash_no_default_type 1070
|
|
#define lambda_slash_with_default_type 1071
|
|
#define lambda_star_etc_type 1072
|
|
#define lambda_kwds_type 1073
|
|
#define lambda_param_no_default_type 1074
|
|
#define lambda_param_with_default_type 1075
|
|
#define lambda_param_maybe_default_type 1076
|
|
#define lambda_param_type 1077
|
|
#define disjunction_type 1078
|
|
#define conjunction_type 1079
|
|
#define inversion_type 1080
|
|
#define comparison_type 1081
|
|
#define compare_op_bitwise_or_pair_type 1082
|
|
#define eq_bitwise_or_type 1083
|
|
#define noteq_bitwise_or_type 1084
|
|
#define lte_bitwise_or_type 1085
|
|
#define lt_bitwise_or_type 1086
|
|
#define gte_bitwise_or_type 1087
|
|
#define gt_bitwise_or_type 1088
|
|
#define notin_bitwise_or_type 1089
|
|
#define in_bitwise_or_type 1090
|
|
#define isnot_bitwise_or_type 1091
|
|
#define is_bitwise_or_type 1092
|
|
#define bitwise_or_type 1093 // Left-recursive
|
|
#define bitwise_xor_type 1094 // Left-recursive
|
|
#define bitwise_and_type 1095 // Left-recursive
|
|
#define shift_expr_type 1096 // Left-recursive
|
|
#define sum_type 1097 // Left-recursive
|
|
#define term_type 1098 // Left-recursive
|
|
#define factor_type 1099
|
|
#define power_type 1100
|
|
#define await_primary_type 1101
|
|
#define primary_type 1102 // Left-recursive
|
|
#define slices_type 1103
|
|
#define slice_type 1104
|
|
#define atom_type 1105
|
|
#define strings_type 1106
|
|
#define list_type 1107
|
|
#define listcomp_type 1108
|
|
#define tuple_type 1109
|
|
#define group_type 1110
|
|
#define genexp_type 1111
|
|
#define set_type 1112
|
|
#define setcomp_type 1113
|
|
#define dict_type 1114
|
|
#define dictcomp_type 1115
|
|
#define kvpairs_type 1116
|
|
#define kvpair_type 1117
|
|
#define for_if_clauses_type 1118
|
|
#define for_if_clause_type 1119
|
|
#define yield_expr_type 1120
|
|
#define arguments_type 1121
|
|
#define args_type 1122
|
|
#define kwargs_type 1123
|
|
#define starred_expression_type 1124
|
|
#define kwarg_or_starred_type 1125
|
|
#define kwarg_or_double_starred_type 1126
|
|
#define star_targets_type 1127
|
|
#define star_targets_seq_type 1128
|
|
#define star_target_type 1129
|
|
#define star_atom_type 1130
|
|
#define inside_paren_ann_assign_target_type 1131
|
|
#define ann_assign_subscript_attribute_target_type 1132
|
|
#define del_targets_type 1133
|
|
#define del_target_type 1134
|
|
#define del_t_atom_type 1135
|
|
#define targets_type 1136
|
|
#define target_type 1137
|
|
#define t_primary_type 1138 // Left-recursive
|
|
#define t_lookahead_type 1139
|
|
#define t_atom_type 1140
|
|
#define incorrect_arguments_type 1141
|
|
#define invalid_kwarg_type 1142
|
|
#define invalid_named_expression_type 1143
|
|
#define invalid_assignment_type 1144
|
|
#define invalid_block_type 1145
|
|
#define invalid_comprehension_type 1146
|
|
#define invalid_parameters_type 1147
|
|
#define invalid_star_etc_type 1148
|
|
#define invalid_lambda_star_etc_type 1149
|
|
#define invalid_double_type_comments_type 1150
|
|
#define _loop0_1_type 1151
|
|
#define _loop0_2_type 1152
|
|
#define _loop0_4_type 1153
|
|
#define _gather_3_type 1154
|
|
#define _loop0_6_type 1155
|
|
#define _gather_5_type 1156
|
|
#define _loop0_8_type 1157
|
|
#define _gather_7_type 1158
|
|
#define _loop0_10_type 1159
|
|
#define _gather_9_type 1160
|
|
#define _loop1_11_type 1161
|
|
#define _loop0_13_type 1162
|
|
#define _gather_12_type 1163
|
|
#define _tmp_14_type 1164
|
|
#define _tmp_15_type 1165
|
|
#define _tmp_16_type 1166
|
|
#define _tmp_17_type 1167
|
|
#define _tmp_18_type 1168
|
|
#define _tmp_19_type 1169
|
|
#define _tmp_20_type 1170
|
|
#define _tmp_21_type 1171
|
|
#define _loop1_22_type 1172
|
|
#define _tmp_23_type 1173
|
|
#define _tmp_24_type 1174
|
|
#define _loop0_26_type 1175
|
|
#define _gather_25_type 1176
|
|
#define _loop0_28_type 1177
|
|
#define _gather_27_type 1178
|
|
#define _tmp_29_type 1179
|
|
#define _loop0_30_type 1180
|
|
#define _loop1_31_type 1181
|
|
#define _loop0_33_type 1182
|
|
#define _gather_32_type 1183
|
|
#define _tmp_34_type 1184
|
|
#define _loop0_36_type 1185
|
|
#define _gather_35_type 1186
|
|
#define _tmp_37_type 1187
|
|
#define _loop0_39_type 1188
|
|
#define _gather_38_type 1189
|
|
#define _loop0_41_type 1190
|
|
#define _gather_40_type 1191
|
|
#define _loop0_43_type 1192
|
|
#define _gather_42_type 1193
|
|
#define _loop0_45_type 1194
|
|
#define _gather_44_type 1195
|
|
#define _tmp_46_type 1196
|
|
#define _loop1_47_type 1197
|
|
#define _tmp_48_type 1198
|
|
#define _tmp_49_type 1199
|
|
#define _tmp_50_type 1200
|
|
#define _tmp_51_type 1201
|
|
#define _tmp_52_type 1202
|
|
#define _loop0_53_type 1203
|
|
#define _loop0_54_type 1204
|
|
#define _loop0_55_type 1205
|
|
#define _loop1_56_type 1206
|
|
#define _loop0_57_type 1207
|
|
#define _loop1_58_type 1208
|
|
#define _loop1_59_type 1209
|
|
#define _loop1_60_type 1210
|
|
#define _loop0_61_type 1211
|
|
#define _loop1_62_type 1212
|
|
#define _loop0_63_type 1213
|
|
#define _loop1_64_type 1214
|
|
#define _loop0_65_type 1215
|
|
#define _loop1_66_type 1216
|
|
#define _loop1_67_type 1217
|
|
#define _tmp_68_type 1218
|
|
#define _loop0_70_type 1219
|
|
#define _gather_69_type 1220
|
|
#define _loop1_71_type 1221
|
|
#define _loop0_73_type 1222
|
|
#define _gather_72_type 1223
|
|
#define _loop1_74_type 1224
|
|
#define _loop0_75_type 1225
|
|
#define _loop0_76_type 1226
|
|
#define _loop0_77_type 1227
|
|
#define _loop1_78_type 1228
|
|
#define _loop0_79_type 1229
|
|
#define _loop1_80_type 1230
|
|
#define _loop1_81_type 1231
|
|
#define _loop1_82_type 1232
|
|
#define _loop0_83_type 1233
|
|
#define _loop1_84_type 1234
|
|
#define _loop0_85_type 1235
|
|
#define _loop1_86_type 1236
|
|
#define _loop0_87_type 1237
|
|
#define _loop1_88_type 1238
|
|
#define _loop1_89_type 1239
|
|
#define _loop1_90_type 1240
|
|
#define _loop1_91_type 1241
|
|
#define _tmp_92_type 1242
|
|
#define _loop0_94_type 1243
|
|
#define _gather_93_type 1244
|
|
#define _tmp_95_type 1245
|
|
#define _tmp_96_type 1246
|
|
#define _tmp_97_type 1247
|
|
#define _tmp_98_type 1248
|
|
#define _loop1_99_type 1249
|
|
#define _tmp_100_type 1250
|
|
#define _tmp_101_type 1251
|
|
#define _loop0_103_type 1252
|
|
#define _gather_102_type 1253
|
|
#define _loop1_104_type 1254
|
|
#define _loop0_105_type 1255
|
|
#define _loop0_106_type 1256
|
|
#define _tmp_107_type 1257
|
|
#define _tmp_108_type 1258
|
|
#define _loop0_110_type 1259
|
|
#define _gather_109_type 1260
|
|
#define _loop0_112_type 1261
|
|
#define _gather_111_type 1262
|
|
#define _loop0_114_type 1263
|
|
#define _gather_113_type 1264
|
|
#define _loop0_116_type 1265
|
|
#define _gather_115_type 1266
|
|
#define _loop0_117_type 1267
|
|
#define _loop0_119_type 1268
|
|
#define _gather_118_type 1269
|
|
#define _tmp_120_type 1270
|
|
#define _loop0_122_type 1271
|
|
#define _gather_121_type 1272
|
|
#define _loop0_124_type 1273
|
|
#define _gather_123_type 1274
|
|
#define _tmp_125_type 1275
|
|
#define _tmp_126_type 1276
|
|
#define _tmp_127_type 1277
|
|
#define _tmp_128_type 1278
|
|
#define _tmp_129_type 1279
|
|
#define _loop0_130_type 1280
|
|
#define _tmp_131_type 1281
|
|
#define _tmp_132_type 1282
|
|
#define _tmp_133_type 1283
|
|
#define _tmp_134_type 1284
|
|
#define _tmp_135_type 1285
|
|
#define _tmp_136_type 1286
|
|
#define _tmp_137_type 1287
|
|
#define _tmp_138_type 1288
|
|
#define _tmp_139_type 1289
|
|
#define _tmp_140_type 1290
|
|
#define _tmp_141_type 1291
|
|
#define _tmp_142_type 1292
|
|
#define _tmp_143_type 1293
|
|
#define _tmp_144_type 1294
|
|
#define _loop1_145_type 1295
|
|
#define _tmp_146_type 1296
|
|
#define _tmp_147_type 1297
|
|
|
|
static mod_ty file_rule(Parser *p);
|
|
static mod_ty interactive_rule(Parser *p);
|
|
static mod_ty eval_rule(Parser *p);
|
|
static mod_ty func_type_rule(Parser *p);
|
|
static expr_ty fstring_rule(Parser *p);
|
|
static asdl_seq* type_expressions_rule(Parser *p);
|
|
static asdl_seq* statements_rule(Parser *p);
|
|
static asdl_seq* statement_rule(Parser *p);
|
|
static asdl_seq* statement_newline_rule(Parser *p);
|
|
static asdl_seq* simple_stmt_rule(Parser *p);
|
|
static stmt_ty small_stmt_rule(Parser *p);
|
|
static stmt_ty compound_stmt_rule(Parser *p);
|
|
static stmt_ty assignment_rule(Parser *p);
|
|
static AugOperator* augassign_rule(Parser *p);
|
|
static stmt_ty global_stmt_rule(Parser *p);
|
|
static stmt_ty nonlocal_stmt_rule(Parser *p);
|
|
static stmt_ty yield_stmt_rule(Parser *p);
|
|
static stmt_ty assert_stmt_rule(Parser *p);
|
|
static stmt_ty del_stmt_rule(Parser *p);
|
|
static stmt_ty import_stmt_rule(Parser *p);
|
|
static stmt_ty import_name_rule(Parser *p);
|
|
static stmt_ty import_from_rule(Parser *p);
|
|
static asdl_seq* import_from_targets_rule(Parser *p);
|
|
static asdl_seq* import_from_as_names_rule(Parser *p);
|
|
static alias_ty import_from_as_name_rule(Parser *p);
|
|
static asdl_seq* dotted_as_names_rule(Parser *p);
|
|
static alias_ty dotted_as_name_rule(Parser *p);
|
|
static expr_ty dotted_name_rule(Parser *p);
|
|
static stmt_ty if_stmt_rule(Parser *p);
|
|
static stmt_ty elif_stmt_rule(Parser *p);
|
|
static asdl_seq* else_block_rule(Parser *p);
|
|
static stmt_ty while_stmt_rule(Parser *p);
|
|
static stmt_ty for_stmt_rule(Parser *p);
|
|
static stmt_ty with_stmt_rule(Parser *p);
|
|
static withitem_ty with_item_rule(Parser *p);
|
|
static stmt_ty try_stmt_rule(Parser *p);
|
|
static excepthandler_ty except_block_rule(Parser *p);
|
|
static asdl_seq* finally_block_rule(Parser *p);
|
|
static stmt_ty return_stmt_rule(Parser *p);
|
|
static stmt_ty raise_stmt_rule(Parser *p);
|
|
static stmt_ty function_def_rule(Parser *p);
|
|
static stmt_ty function_def_raw_rule(Parser *p);
|
|
static Token* func_type_comment_rule(Parser *p);
|
|
static arguments_ty params_rule(Parser *p);
|
|
static arguments_ty parameters_rule(Parser *p);
|
|
static asdl_seq* slash_no_default_rule(Parser *p);
|
|
static SlashWithDefault* slash_with_default_rule(Parser *p);
|
|
static StarEtc* star_etc_rule(Parser *p);
|
|
static arg_ty kwds_rule(Parser *p);
|
|
static arg_ty param_no_default_rule(Parser *p);
|
|
static NameDefaultPair* param_with_default_rule(Parser *p);
|
|
static NameDefaultPair* param_maybe_default_rule(Parser *p);
|
|
static arg_ty param_rule(Parser *p);
|
|
static expr_ty annotation_rule(Parser *p);
|
|
static expr_ty default_rule(Parser *p);
|
|
static asdl_seq* decorators_rule(Parser *p);
|
|
static stmt_ty class_def_rule(Parser *p);
|
|
static stmt_ty class_def_raw_rule(Parser *p);
|
|
static asdl_seq* block_rule(Parser *p);
|
|
static asdl_seq* expressions_list_rule(Parser *p);
|
|
static expr_ty star_expressions_rule(Parser *p);
|
|
static expr_ty star_expression_rule(Parser *p);
|
|
static asdl_seq* star_named_expressions_rule(Parser *p);
|
|
static expr_ty star_named_expression_rule(Parser *p);
|
|
static expr_ty named_expression_rule(Parser *p);
|
|
static expr_ty annotated_rhs_rule(Parser *p);
|
|
static expr_ty expressions_rule(Parser *p);
|
|
static expr_ty expression_rule(Parser *p);
|
|
static expr_ty lambdef_rule(Parser *p);
|
|
static arguments_ty lambda_parameters_rule(Parser *p);
|
|
static asdl_seq* lambda_slash_no_default_rule(Parser *p);
|
|
static SlashWithDefault* lambda_slash_with_default_rule(Parser *p);
|
|
static StarEtc* lambda_star_etc_rule(Parser *p);
|
|
static arg_ty lambda_kwds_rule(Parser *p);
|
|
static arg_ty lambda_param_no_default_rule(Parser *p);
|
|
static NameDefaultPair* lambda_param_with_default_rule(Parser *p);
|
|
static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p);
|
|
static arg_ty lambda_param_rule(Parser *p);
|
|
static expr_ty disjunction_rule(Parser *p);
|
|
static expr_ty conjunction_rule(Parser *p);
|
|
static expr_ty inversion_rule(Parser *p);
|
|
static expr_ty comparison_rule(Parser *p);
|
|
static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p);
|
|
static CmpopExprPair* eq_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* noteq_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* lte_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* lt_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* gte_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* gt_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* notin_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* in_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* isnot_bitwise_or_rule(Parser *p);
|
|
static CmpopExprPair* is_bitwise_or_rule(Parser *p);
|
|
static expr_ty bitwise_or_rule(Parser *p);
|
|
static expr_ty bitwise_xor_rule(Parser *p);
|
|
static expr_ty bitwise_and_rule(Parser *p);
|
|
static expr_ty shift_expr_rule(Parser *p);
|
|
static expr_ty sum_rule(Parser *p);
|
|
static expr_ty term_rule(Parser *p);
|
|
static expr_ty factor_rule(Parser *p);
|
|
static expr_ty power_rule(Parser *p);
|
|
static expr_ty await_primary_rule(Parser *p);
|
|
static expr_ty primary_rule(Parser *p);
|
|
static expr_ty slices_rule(Parser *p);
|
|
static expr_ty slice_rule(Parser *p);
|
|
static expr_ty atom_rule(Parser *p);
|
|
static expr_ty strings_rule(Parser *p);
|
|
static expr_ty list_rule(Parser *p);
|
|
static expr_ty listcomp_rule(Parser *p);
|
|
static expr_ty tuple_rule(Parser *p);
|
|
static expr_ty group_rule(Parser *p);
|
|
static expr_ty genexp_rule(Parser *p);
|
|
static expr_ty set_rule(Parser *p);
|
|
static expr_ty setcomp_rule(Parser *p);
|
|
static expr_ty dict_rule(Parser *p);
|
|
static expr_ty dictcomp_rule(Parser *p);
|
|
static asdl_seq* kvpairs_rule(Parser *p);
|
|
static KeyValuePair* kvpair_rule(Parser *p);
|
|
static asdl_seq* for_if_clauses_rule(Parser *p);
|
|
static comprehension_ty for_if_clause_rule(Parser *p);
|
|
static expr_ty yield_expr_rule(Parser *p);
|
|
static expr_ty arguments_rule(Parser *p);
|
|
static expr_ty args_rule(Parser *p);
|
|
static asdl_seq* kwargs_rule(Parser *p);
|
|
static expr_ty starred_expression_rule(Parser *p);
|
|
static KeywordOrStarred* kwarg_or_starred_rule(Parser *p);
|
|
static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p);
|
|
static expr_ty star_targets_rule(Parser *p);
|
|
static asdl_seq* star_targets_seq_rule(Parser *p);
|
|
static expr_ty star_target_rule(Parser *p);
|
|
static expr_ty star_atom_rule(Parser *p);
|
|
static expr_ty inside_paren_ann_assign_target_rule(Parser *p);
|
|
static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p);
|
|
static asdl_seq* del_targets_rule(Parser *p);
|
|
static expr_ty del_target_rule(Parser *p);
|
|
static expr_ty del_t_atom_rule(Parser *p);
|
|
static asdl_seq* targets_rule(Parser *p);
|
|
static expr_ty target_rule(Parser *p);
|
|
static expr_ty t_primary_rule(Parser *p);
|
|
static void *t_lookahead_rule(Parser *p);
|
|
static expr_ty t_atom_rule(Parser *p);
|
|
static void *incorrect_arguments_rule(Parser *p);
|
|
static void *invalid_kwarg_rule(Parser *p);
|
|
static void *invalid_named_expression_rule(Parser *p);
|
|
static void *invalid_assignment_rule(Parser *p);
|
|
static void *invalid_block_rule(Parser *p);
|
|
static void *invalid_comprehension_rule(Parser *p);
|
|
static void *invalid_parameters_rule(Parser *p);
|
|
static void *invalid_star_etc_rule(Parser *p);
|
|
static void *invalid_lambda_star_etc_rule(Parser *p);
|
|
static void *invalid_double_type_comments_rule(Parser *p);
|
|
static asdl_seq *_loop0_1_rule(Parser *p);
|
|
static asdl_seq *_loop0_2_rule(Parser *p);
|
|
static asdl_seq *_loop0_4_rule(Parser *p);
|
|
static asdl_seq *_gather_3_rule(Parser *p);
|
|
static asdl_seq *_loop0_6_rule(Parser *p);
|
|
static asdl_seq *_gather_5_rule(Parser *p);
|
|
static asdl_seq *_loop0_8_rule(Parser *p);
|
|
static asdl_seq *_gather_7_rule(Parser *p);
|
|
static asdl_seq *_loop0_10_rule(Parser *p);
|
|
static asdl_seq *_gather_9_rule(Parser *p);
|
|
static asdl_seq *_loop1_11_rule(Parser *p);
|
|
static asdl_seq *_loop0_13_rule(Parser *p);
|
|
static asdl_seq *_gather_12_rule(Parser *p);
|
|
static void *_tmp_14_rule(Parser *p);
|
|
static void *_tmp_15_rule(Parser *p);
|
|
static void *_tmp_16_rule(Parser *p);
|
|
static void *_tmp_17_rule(Parser *p);
|
|
static void *_tmp_18_rule(Parser *p);
|
|
static void *_tmp_19_rule(Parser *p);
|
|
static void *_tmp_20_rule(Parser *p);
|
|
static void *_tmp_21_rule(Parser *p);
|
|
static asdl_seq *_loop1_22_rule(Parser *p);
|
|
static void *_tmp_23_rule(Parser *p);
|
|
static void *_tmp_24_rule(Parser *p);
|
|
static asdl_seq *_loop0_26_rule(Parser *p);
|
|
static asdl_seq *_gather_25_rule(Parser *p);
|
|
static asdl_seq *_loop0_28_rule(Parser *p);
|
|
static asdl_seq *_gather_27_rule(Parser *p);
|
|
static void *_tmp_29_rule(Parser *p);
|
|
static asdl_seq *_loop0_30_rule(Parser *p);
|
|
static asdl_seq *_loop1_31_rule(Parser *p);
|
|
static asdl_seq *_loop0_33_rule(Parser *p);
|
|
static asdl_seq *_gather_32_rule(Parser *p);
|
|
static void *_tmp_34_rule(Parser *p);
|
|
static asdl_seq *_loop0_36_rule(Parser *p);
|
|
static asdl_seq *_gather_35_rule(Parser *p);
|
|
static void *_tmp_37_rule(Parser *p);
|
|
static asdl_seq *_loop0_39_rule(Parser *p);
|
|
static asdl_seq *_gather_38_rule(Parser *p);
|
|
static asdl_seq *_loop0_41_rule(Parser *p);
|
|
static asdl_seq *_gather_40_rule(Parser *p);
|
|
static asdl_seq *_loop0_43_rule(Parser *p);
|
|
static asdl_seq *_gather_42_rule(Parser *p);
|
|
static asdl_seq *_loop0_45_rule(Parser *p);
|
|
static asdl_seq *_gather_44_rule(Parser *p);
|
|
static void *_tmp_46_rule(Parser *p);
|
|
static asdl_seq *_loop1_47_rule(Parser *p);
|
|
static void *_tmp_48_rule(Parser *p);
|
|
static void *_tmp_49_rule(Parser *p);
|
|
static void *_tmp_50_rule(Parser *p);
|
|
static void *_tmp_51_rule(Parser *p);
|
|
static void *_tmp_52_rule(Parser *p);
|
|
static asdl_seq *_loop0_53_rule(Parser *p);
|
|
static asdl_seq *_loop0_54_rule(Parser *p);
|
|
static asdl_seq *_loop0_55_rule(Parser *p);
|
|
static asdl_seq *_loop1_56_rule(Parser *p);
|
|
static asdl_seq *_loop0_57_rule(Parser *p);
|
|
static asdl_seq *_loop1_58_rule(Parser *p);
|
|
static asdl_seq *_loop1_59_rule(Parser *p);
|
|
static asdl_seq *_loop1_60_rule(Parser *p);
|
|
static asdl_seq *_loop0_61_rule(Parser *p);
|
|
static asdl_seq *_loop1_62_rule(Parser *p);
|
|
static asdl_seq *_loop0_63_rule(Parser *p);
|
|
static asdl_seq *_loop1_64_rule(Parser *p);
|
|
static asdl_seq *_loop0_65_rule(Parser *p);
|
|
static asdl_seq *_loop1_66_rule(Parser *p);
|
|
static asdl_seq *_loop1_67_rule(Parser *p);
|
|
static void *_tmp_68_rule(Parser *p);
|
|
static asdl_seq *_loop0_70_rule(Parser *p);
|
|
static asdl_seq *_gather_69_rule(Parser *p);
|
|
static asdl_seq *_loop1_71_rule(Parser *p);
|
|
static asdl_seq *_loop0_73_rule(Parser *p);
|
|
static asdl_seq *_gather_72_rule(Parser *p);
|
|
static asdl_seq *_loop1_74_rule(Parser *p);
|
|
static asdl_seq *_loop0_75_rule(Parser *p);
|
|
static asdl_seq *_loop0_76_rule(Parser *p);
|
|
static asdl_seq *_loop0_77_rule(Parser *p);
|
|
static asdl_seq *_loop1_78_rule(Parser *p);
|
|
static asdl_seq *_loop0_79_rule(Parser *p);
|
|
static asdl_seq *_loop1_80_rule(Parser *p);
|
|
static asdl_seq *_loop1_81_rule(Parser *p);
|
|
static asdl_seq *_loop1_82_rule(Parser *p);
|
|
static asdl_seq *_loop0_83_rule(Parser *p);
|
|
static asdl_seq *_loop1_84_rule(Parser *p);
|
|
static asdl_seq *_loop0_85_rule(Parser *p);
|
|
static asdl_seq *_loop1_86_rule(Parser *p);
|
|
static asdl_seq *_loop0_87_rule(Parser *p);
|
|
static asdl_seq *_loop1_88_rule(Parser *p);
|
|
static asdl_seq *_loop1_89_rule(Parser *p);
|
|
static asdl_seq *_loop1_90_rule(Parser *p);
|
|
static asdl_seq *_loop1_91_rule(Parser *p);
|
|
static void *_tmp_92_rule(Parser *p);
|
|
static asdl_seq *_loop0_94_rule(Parser *p);
|
|
static asdl_seq *_gather_93_rule(Parser *p);
|
|
static void *_tmp_95_rule(Parser *p);
|
|
static void *_tmp_96_rule(Parser *p);
|
|
static void *_tmp_97_rule(Parser *p);
|
|
static void *_tmp_98_rule(Parser *p);
|
|
static asdl_seq *_loop1_99_rule(Parser *p);
|
|
static void *_tmp_100_rule(Parser *p);
|
|
static void *_tmp_101_rule(Parser *p);
|
|
static asdl_seq *_loop0_103_rule(Parser *p);
|
|
static asdl_seq *_gather_102_rule(Parser *p);
|
|
static asdl_seq *_loop1_104_rule(Parser *p);
|
|
static asdl_seq *_loop0_105_rule(Parser *p);
|
|
static asdl_seq *_loop0_106_rule(Parser *p);
|
|
static void *_tmp_107_rule(Parser *p);
|
|
static void *_tmp_108_rule(Parser *p);
|
|
static asdl_seq *_loop0_110_rule(Parser *p);
|
|
static asdl_seq *_gather_109_rule(Parser *p);
|
|
static asdl_seq *_loop0_112_rule(Parser *p);
|
|
static asdl_seq *_gather_111_rule(Parser *p);
|
|
static asdl_seq *_loop0_114_rule(Parser *p);
|
|
static asdl_seq *_gather_113_rule(Parser *p);
|
|
static asdl_seq *_loop0_116_rule(Parser *p);
|
|
static asdl_seq *_gather_115_rule(Parser *p);
|
|
static asdl_seq *_loop0_117_rule(Parser *p);
|
|
static asdl_seq *_loop0_119_rule(Parser *p);
|
|
static asdl_seq *_gather_118_rule(Parser *p);
|
|
static void *_tmp_120_rule(Parser *p);
|
|
static asdl_seq *_loop0_122_rule(Parser *p);
|
|
static asdl_seq *_gather_121_rule(Parser *p);
|
|
static asdl_seq *_loop0_124_rule(Parser *p);
|
|
static asdl_seq *_gather_123_rule(Parser *p);
|
|
static void *_tmp_125_rule(Parser *p);
|
|
static void *_tmp_126_rule(Parser *p);
|
|
static void *_tmp_127_rule(Parser *p);
|
|
static void *_tmp_128_rule(Parser *p);
|
|
static void *_tmp_129_rule(Parser *p);
|
|
static asdl_seq *_loop0_130_rule(Parser *p);
|
|
static void *_tmp_131_rule(Parser *p);
|
|
static void *_tmp_132_rule(Parser *p);
|
|
static void *_tmp_133_rule(Parser *p);
|
|
static void *_tmp_134_rule(Parser *p);
|
|
static void *_tmp_135_rule(Parser *p);
|
|
static void *_tmp_136_rule(Parser *p);
|
|
static void *_tmp_137_rule(Parser *p);
|
|
static void *_tmp_138_rule(Parser *p);
|
|
static void *_tmp_139_rule(Parser *p);
|
|
static void *_tmp_140_rule(Parser *p);
|
|
static void *_tmp_141_rule(Parser *p);
|
|
static void *_tmp_142_rule(Parser *p);
|
|
static void *_tmp_143_rule(Parser *p);
|
|
static void *_tmp_144_rule(Parser *p);
|
|
static asdl_seq *_loop1_145_rule(Parser *p);
|
|
static void *_tmp_146_rule(Parser *p);
|
|
static void *_tmp_147_rule(Parser *p);
|
|
|
|
|
|
// file: statements? $
|
|
static mod_ty
|
|
file_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
mod_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // statements? $
|
|
void *a;
|
|
Token * endmarker_var;
|
|
if (
|
|
(a = statements_rule(p), 1) // statements?
|
|
&&
|
|
(endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
|
|
)
|
|
{
|
|
res = _PyPegen_make_module ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// interactive: statement_newline
|
|
static mod_ty
|
|
interactive_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
mod_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // statement_newline
|
|
asdl_seq* a;
|
|
if (
|
|
(a = statement_newline_rule(p)) // statement_newline
|
|
)
|
|
{
|
|
res = Interactive ( a , p -> arena );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// eval: expressions NEWLINE* $
|
|
static mod_ty
|
|
eval_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
mod_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // expressions NEWLINE* $
|
|
asdl_seq * _loop0_1_var;
|
|
expr_ty a;
|
|
Token * endmarker_var;
|
|
if (
|
|
(a = expressions_rule(p)) // expressions
|
|
&&
|
|
(_loop0_1_var = _loop0_1_rule(p)) // NEWLINE*
|
|
&&
|
|
(endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
|
|
)
|
|
{
|
|
res = Expression ( a , p -> arena );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// func_type: '(' type_expressions? ')' '->' expression NEWLINE* $
|
|
static mod_ty
|
|
func_type_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
mod_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // '(' type_expressions? ')' '->' expression NEWLINE* $
|
|
asdl_seq * _loop0_2_var;
|
|
void *a;
|
|
expr_ty b;
|
|
Token * endmarker_var;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
Token * literal_2;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = type_expressions_rule(p), 1) // type_expressions?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
&&
|
|
(literal_2 = _PyPegen_expect_token(p, 51)) // token='->'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
&&
|
|
(_loop0_2_var = _loop0_2_rule(p)) // NEWLINE*
|
|
&&
|
|
(endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
|
|
)
|
|
{
|
|
res = FunctionType ( a , b , p -> arena );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// fstring: star_expressions
|
|
static expr_ty
|
|
fstring_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // star_expressions
|
|
expr_ty star_expressions_var;
|
|
if (
|
|
(star_expressions_var = star_expressions_rule(p)) // star_expressions
|
|
)
|
|
{
|
|
res = star_expressions_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// type_expressions:
|
|
// | ','.expression+ ',' '*' expression ',' '**' expression
|
|
// | ','.expression+ ',' '*' expression
|
|
// | ','.expression+ ',' '**' expression
|
|
// | '*' expression ',' '**' expression
|
|
// | '*' expression
|
|
// | '**' expression
|
|
// | ','.expression+
|
|
static asdl_seq*
|
|
type_expressions_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.expression+ ',' '*' expression ',' '**' expression
|
|
asdl_seq * a;
|
|
expr_ty b;
|
|
expr_ty c;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
Token * literal_2;
|
|
Token * literal_3;
|
|
if (
|
|
(a = _gather_3_rule(p)) // ','.expression+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
&&
|
|
(literal_2 = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(literal_3 = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(c = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ','.expression+ ',' '*' expression
|
|
asdl_seq * a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = _gather_5_rule(p)) // ','.expression+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = _PyPegen_seq_append_to_end ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ','.expression+ ',' '**' expression
|
|
asdl_seq * a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = _gather_7_rule(p)) // ','.expression+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = _PyPegen_seq_append_to_end ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '*' expression ',' '**' expression
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
Token * literal_2;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(literal_2 = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '*' expression
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = _PyPegen_singleton_seq ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '**' expression
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = _PyPegen_singleton_seq ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ','.expression+
|
|
asdl_seq * _gather_9_var;
|
|
if (
|
|
(_gather_9_var = _gather_9_rule(p)) // ','.expression+
|
|
)
|
|
{
|
|
res = _gather_9_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// statements: statement+
|
|
static asdl_seq*
|
|
statements_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // statement+
|
|
asdl_seq * a;
|
|
if (
|
|
(a = _loop1_11_rule(p)) // statement+
|
|
)
|
|
{
|
|
res = _PyPegen_seq_flatten ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// statement: compound_stmt | simple_stmt
|
|
static asdl_seq*
|
|
statement_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // compound_stmt
|
|
stmt_ty a;
|
|
if (
|
|
(a = compound_stmt_rule(p)) // compound_stmt
|
|
)
|
|
{
|
|
res = _PyPegen_singleton_seq ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // simple_stmt
|
|
asdl_seq* simple_stmt_var;
|
|
if (
|
|
(simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
|
|
)
|
|
{
|
|
res = simple_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
|
|
static asdl_seq*
|
|
statement_newline_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // compound_stmt NEWLINE
|
|
stmt_ty a;
|
|
Token * newline_var;
|
|
if (
|
|
(a = compound_stmt_rule(p)) // compound_stmt
|
|
&&
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
)
|
|
{
|
|
res = _PyPegen_singleton_seq ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // simple_stmt
|
|
asdl_seq* simple_stmt_var;
|
|
if (
|
|
(simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
|
|
)
|
|
{
|
|
res = simple_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // NEWLINE
|
|
Token * newline_var;
|
|
if (
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // $
|
|
Token * endmarker_var;
|
|
if (
|
|
(endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
|
|
)
|
|
{
|
|
res = _PyPegen_interactive_exit ( p );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
|
|
static asdl_seq*
|
|
simple_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // small_stmt !';' NEWLINE
|
|
stmt_ty a;
|
|
Token * newline_var;
|
|
if (
|
|
(a = small_stmt_rule(p)) // small_stmt
|
|
&&
|
|
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';'
|
|
&&
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
)
|
|
{
|
|
res = _PyPegen_singleton_seq ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ';'.small_stmt+ ';'? NEWLINE
|
|
asdl_seq * a;
|
|
Token * newline_var;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = _gather_12_rule(p)) // ';'.small_stmt+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 13), 1) // ';'?
|
|
&&
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// small_stmt:
|
|
// | assignment
|
|
// | star_expressions
|
|
// | &'return' return_stmt
|
|
// | &('import' | 'from') import_stmt
|
|
// | &'raise' raise_stmt
|
|
// | 'pass'
|
|
// | &'del' del_stmt
|
|
// | &'yield' yield_stmt
|
|
// | &'assert' assert_stmt
|
|
// | 'break'
|
|
// | 'continue'
|
|
// | &'global' global_stmt
|
|
// | &'nonlocal' nonlocal_stmt
|
|
static stmt_ty
|
|
small_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, small_stmt_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // assignment
|
|
stmt_ty assignment_var;
|
|
if (
|
|
(assignment_var = assignment_rule(p)) // assignment
|
|
)
|
|
{
|
|
res = assignment_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_expressions
|
|
expr_ty e;
|
|
if (
|
|
(e = star_expressions_rule(p)) // star_expressions
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Expr ( e , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'return' return_stmt
|
|
stmt_ty return_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return'
|
|
&&
|
|
(return_stmt_var = return_stmt_rule(p)) // return_stmt
|
|
)
|
|
{
|
|
res = return_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &('import' | 'from') import_stmt
|
|
stmt_ty import_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead(1, _tmp_14_rule, p)
|
|
&&
|
|
(import_stmt_var = import_stmt_rule(p)) // import_stmt
|
|
)
|
|
{
|
|
res = import_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'raise' raise_stmt
|
|
stmt_ty raise_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise'
|
|
&&
|
|
(raise_stmt_var = raise_stmt_rule(p)) // raise_stmt
|
|
)
|
|
{
|
|
res = raise_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'pass'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 502)) // token='pass'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Pass ( EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'del' del_stmt
|
|
stmt_ty del_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del'
|
|
&&
|
|
(del_stmt_var = del_stmt_rule(p)) // del_stmt
|
|
)
|
|
{
|
|
res = del_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'yield' yield_stmt
|
|
stmt_ty yield_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield'
|
|
&&
|
|
(yield_stmt_var = yield_stmt_rule(p)) // yield_stmt
|
|
)
|
|
{
|
|
res = yield_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'assert' assert_stmt
|
|
stmt_ty assert_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert'
|
|
&&
|
|
(assert_stmt_var = assert_stmt_rule(p)) // assert_stmt
|
|
)
|
|
{
|
|
res = assert_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'break'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 506)) // token='break'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Break ( EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'continue'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 507)) // token='continue'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Continue ( EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'global' global_stmt
|
|
stmt_ty global_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global'
|
|
&&
|
|
(global_stmt_var = global_stmt_rule(p)) // global_stmt
|
|
)
|
|
{
|
|
res = global_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'nonlocal' nonlocal_stmt
|
|
stmt_ty nonlocal_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal'
|
|
&&
|
|
(nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt
|
|
)
|
|
{
|
|
res = nonlocal_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, small_stmt_type, res);
|
|
return res;
|
|
}
|
|
|
|
// compound_stmt:
|
|
// | &('def' | '@' | ASYNC) function_def
|
|
// | &'if' if_stmt
|
|
// | &('class' | '@') class_def
|
|
// | &('with' | ASYNC) with_stmt
|
|
// | &('for' | ASYNC) for_stmt
|
|
// | &'try' try_stmt
|
|
// | &'while' while_stmt
|
|
static stmt_ty
|
|
compound_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // &('def' | '@' | ASYNC) function_def
|
|
stmt_ty function_def_var;
|
|
if (
|
|
_PyPegen_lookahead(1, _tmp_15_rule, p)
|
|
&&
|
|
(function_def_var = function_def_rule(p)) // function_def
|
|
)
|
|
{
|
|
res = function_def_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'if' if_stmt
|
|
stmt_ty if_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if'
|
|
&&
|
|
(if_stmt_var = if_stmt_rule(p)) // if_stmt
|
|
)
|
|
{
|
|
res = if_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &('class' | '@') class_def
|
|
stmt_ty class_def_var;
|
|
if (
|
|
_PyPegen_lookahead(1, _tmp_16_rule, p)
|
|
&&
|
|
(class_def_var = class_def_rule(p)) // class_def
|
|
)
|
|
{
|
|
res = class_def_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &('with' | ASYNC) with_stmt
|
|
stmt_ty with_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead(1, _tmp_17_rule, p)
|
|
&&
|
|
(with_stmt_var = with_stmt_rule(p)) // with_stmt
|
|
)
|
|
{
|
|
res = with_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &('for' | ASYNC) for_stmt
|
|
stmt_ty for_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead(1, _tmp_18_rule, p)
|
|
&&
|
|
(for_stmt_var = for_stmt_rule(p)) // for_stmt
|
|
)
|
|
{
|
|
res = for_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'try' try_stmt
|
|
stmt_ty try_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try'
|
|
&&
|
|
(try_stmt_var = try_stmt_rule(p)) // try_stmt
|
|
)
|
|
{
|
|
res = try_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'while' while_stmt
|
|
stmt_ty while_stmt_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while'
|
|
&&
|
|
(while_stmt_var = while_stmt_rule(p)) // while_stmt
|
|
)
|
|
{
|
|
res = while_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// assignment:
|
|
// | NAME ':' expression ['=' annotated_rhs]
|
|
// | ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs]
|
|
// | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
|
|
// | target augassign (yield_expr | star_expressions)
|
|
// | invalid_assignment
|
|
static stmt_ty
|
|
assignment_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME ':' expression ['=' annotated_rhs]
|
|
expr_ty a;
|
|
expr_ty b;
|
|
void *c;
|
|
Token * literal;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
&&
|
|
(c = _tmp_19_rule(p), 1) // ['=' annotated_rhs]
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs]
|
|
void *a;
|
|
expr_ty b;
|
|
void *c;
|
|
Token * literal;
|
|
if (
|
|
(a = _tmp_20_rule(p)) // '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
&&
|
|
(c = _tmp_21_rule(p), 1) // ['=' annotated_rhs]
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
|
|
asdl_seq * a;
|
|
void *b;
|
|
void *tc;
|
|
if (
|
|
(a = _loop1_22_rule(p)) // ((star_targets '='))+
|
|
&&
|
|
(b = _tmp_23_rule(p)) // yield_expr | star_expressions
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // target augassign (yield_expr | star_expressions)
|
|
expr_ty a;
|
|
AugOperator* b;
|
|
void *c;
|
|
if (
|
|
(a = target_rule(p)) // target
|
|
&&
|
|
(b = augassign_rule(p)) // augassign
|
|
&&
|
|
(c = _tmp_24_rule(p)) // yield_expr | star_expressions
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_AugAssign ( a , b -> kind , c , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_assignment
|
|
void *invalid_assignment_var;
|
|
if (
|
|
(invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment
|
|
)
|
|
{
|
|
res = invalid_assignment_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// augassign:
|
|
// | '+='
|
|
// | '-='
|
|
// | '*='
|
|
// | '@='
|
|
// | '/='
|
|
// | '%='
|
|
// | '&='
|
|
// | '|='
|
|
// | '^='
|
|
// | '<<='
|
|
// | '>>='
|
|
// | '**='
|
|
// | '//='
|
|
static AugOperator*
|
|
augassign_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
AugOperator* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '+='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 36)) // token='+='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , Add );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '-='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 37)) // token='-='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , Sub );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '*='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 38)) // token='*='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , Mult );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '@='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 50)) // token='@='
|
|
)
|
|
{
|
|
res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '/='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 39)) // token='/='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , Div );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '%='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 40)) // token='%='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , Mod );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '&='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 41)) // token='&='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , BitAnd );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '|='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 42)) // token='|='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , BitOr );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '^='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 43)) // token='^='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , BitXor );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '<<='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 44)) // token='<<='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , LShift );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '>>='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 45)) // token='>>='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , RShift );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '**='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 46)) // token='**='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , Pow );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '//='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 48)) // token='//='
|
|
)
|
|
{
|
|
res = _PyPegen_augoperator ( p , FloorDiv );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// global_stmt: 'global' ','.NAME+
|
|
static stmt_ty
|
|
global_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'global' ','.NAME+
|
|
asdl_seq * a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 508)) // token='global'
|
|
&&
|
|
(a = _gather_25_rule(p)) // ','.NAME+
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// nonlocal_stmt: 'nonlocal' ','.NAME+
|
|
static stmt_ty
|
|
nonlocal_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'nonlocal' ','.NAME+
|
|
asdl_seq * a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal'
|
|
&&
|
|
(a = _gather_27_rule(p)) // ','.NAME+
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// yield_stmt: yield_expr
|
|
static stmt_ty
|
|
yield_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // yield_expr
|
|
expr_ty y;
|
|
if (
|
|
(y = yield_expr_rule(p)) // yield_expr
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Expr ( y , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// assert_stmt: 'assert' expression [',' expression]
|
|
static stmt_ty
|
|
assert_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'assert' expression [',' expression]
|
|
expr_ty a;
|
|
void *b;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 505)) // token='assert'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(b = _tmp_29_rule(p), 1) // [',' expression]
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Assert ( a , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// del_stmt: 'del' del_targets
|
|
static stmt_ty
|
|
del_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'del' del_targets
|
|
asdl_seq* a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 503)) // token='del'
|
|
&&
|
|
(a = del_targets_rule(p)) // del_targets
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Delete ( a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// import_stmt: import_name | import_from
|
|
static stmt_ty
|
|
import_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // import_name
|
|
stmt_ty import_name_var;
|
|
if (
|
|
(import_name_var = import_name_rule(p)) // import_name
|
|
)
|
|
{
|
|
res = import_name_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // import_from
|
|
stmt_ty import_from_var;
|
|
if (
|
|
(import_from_var = import_from_rule(p)) // import_from
|
|
)
|
|
{
|
|
res = import_from_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// import_name: 'import' dotted_as_names
|
|
static stmt_ty
|
|
import_name_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'import' dotted_as_names
|
|
asdl_seq* a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 513)) // token='import'
|
|
&&
|
|
(a = dotted_as_names_rule(p)) // dotted_as_names
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Import ( a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// import_from:
|
|
// | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
|
|
// | 'from' (('.' | '...'))+ 'import' import_from_targets
|
|
static stmt_ty
|
|
import_from_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
|
|
asdl_seq * a;
|
|
expr_ty b;
|
|
asdl_seq* c;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 514)) // token='from'
|
|
&&
|
|
(a = _loop0_30_rule(p)) // (('.' | '...'))*
|
|
&&
|
|
(b = dotted_name_rule(p)) // dotted_name
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 513)) // token='import'
|
|
&&
|
|
(c = import_from_targets_rule(p)) // import_from_targets
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'from' (('.' | '...'))+ 'import' import_from_targets
|
|
asdl_seq * a;
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 514)) // token='from'
|
|
&&
|
|
(a = _loop1_31_rule(p)) // (('.' | '...'))+
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 513)) // token='import'
|
|
&&
|
|
(b = import_from_targets_rule(p)) // import_from_targets
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*'
|
|
static asdl_seq*
|
|
import_from_targets_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '(' import_from_as_names ','? ')'
|
|
asdl_seq* a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = import_from_as_names_rule(p)) // import_from_as_names
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // import_from_as_names
|
|
asdl_seq* import_from_as_names_var;
|
|
if (
|
|
(import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names
|
|
)
|
|
{
|
|
res = import_from_as_names_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '*'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
)
|
|
{
|
|
res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// import_from_as_names: ','.import_from_as_name+
|
|
static asdl_seq*
|
|
import_from_as_names_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.import_from_as_name+
|
|
asdl_seq * a;
|
|
if (
|
|
(a = _gather_32_rule(p)) // ','.import_from_as_name+
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// import_from_as_name: NAME ['as' NAME]
|
|
static alias_ty
|
|
import_from_as_name_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
alias_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // NAME ['as' NAME]
|
|
expr_ty a;
|
|
void *b;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(b = _tmp_34_rule(p), 1) // ['as' NAME]
|
|
)
|
|
{
|
|
res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// dotted_as_names: ','.dotted_as_name+
|
|
static asdl_seq*
|
|
dotted_as_names_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.dotted_as_name+
|
|
asdl_seq * a;
|
|
if (
|
|
(a = _gather_35_rule(p)) // ','.dotted_as_name+
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// dotted_as_name: dotted_name ['as' NAME]
|
|
static alias_ty
|
|
dotted_as_name_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
alias_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // dotted_name ['as' NAME]
|
|
expr_ty a;
|
|
void *b;
|
|
if (
|
|
(a = dotted_name_rule(p)) // dotted_name
|
|
&&
|
|
(b = _tmp_37_rule(p), 1) // ['as' NAME]
|
|
)
|
|
{
|
|
res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// dotted_name: dotted_name '.' NAME | NAME
|
|
static expr_ty dotted_name_raw(Parser *);
|
|
static expr_ty
|
|
dotted_name_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, dotted_name_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_0 = _PyPegen_update_memo(p, mark, dotted_name_type, res);
|
|
if (tmpvar_0) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = dotted_name_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
dotted_name_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // dotted_name '.' NAME
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = dotted_name_rule(p)) // dotted_name
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
&&
|
|
(b = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = _PyPegen_join_names_with_dot ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // NAME
|
|
expr_ty name_var;
|
|
if (
|
|
(name_var = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = name_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// if_stmt:
|
|
// | 'if' named_expression ':' block elif_stmt
|
|
// | 'if' named_expression ':' block else_block?
|
|
static stmt_ty
|
|
if_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'if' named_expression ':' block elif_stmt
|
|
expr_ty a;
|
|
asdl_seq* b;
|
|
stmt_ty c;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 510)) // token='if'
|
|
&&
|
|
(a = named_expression_rule(p)) // named_expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(c = elif_stmt_rule(p)) // elif_stmt
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'if' named_expression ':' block else_block?
|
|
expr_ty a;
|
|
asdl_seq* b;
|
|
void *c;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 510)) // token='if'
|
|
&&
|
|
(a = named_expression_rule(p)) // named_expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(c = else_block_rule(p), 1) // else_block?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_If ( a , b , c , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// elif_stmt:
|
|
// | 'elif' named_expression ':' block elif_stmt
|
|
// | 'elif' named_expression ':' block else_block?
|
|
static stmt_ty
|
|
elif_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'elif' named_expression ':' block elif_stmt
|
|
expr_ty a;
|
|
asdl_seq* b;
|
|
stmt_ty c;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 515)) // token='elif'
|
|
&&
|
|
(a = named_expression_rule(p)) // named_expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(c = elif_stmt_rule(p)) // elif_stmt
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'elif' named_expression ':' block else_block?
|
|
expr_ty a;
|
|
asdl_seq* b;
|
|
void *c;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 515)) // token='elif'
|
|
&&
|
|
(a = named_expression_rule(p)) // named_expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(c = else_block_rule(p), 1) // else_block?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_If ( a , b , c , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// else_block: 'else' ':' block
|
|
static asdl_seq*
|
|
else_block_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'else' ':' block
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 516)) // token='else'
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
res = b;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// while_stmt: 'while' named_expression ':' block else_block?
|
|
static stmt_ty
|
|
while_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'while' named_expression ':' block else_block?
|
|
expr_ty a;
|
|
asdl_seq* b;
|
|
void *c;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 512)) // token='while'
|
|
&&
|
|
(a = named_expression_rule(p)) // named_expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(c = else_block_rule(p), 1) // else_block?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_While ( a , b , c , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// for_stmt:
|
|
// | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
|
|
// | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
|
|
static stmt_ty
|
|
for_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
|
|
asdl_seq* b;
|
|
void *el;
|
|
expr_ty ex;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
Token * literal;
|
|
expr_ty t;
|
|
void *tc;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 517)) // token='for'
|
|
&&
|
|
(t = star_targets_rule(p)) // star_targets
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
|
|
&&
|
|
(ex = star_expressions_rule(p)) // star_expressions
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(el = else_block_rule(p), 1) // else_block?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
|
|
Token * async_var;
|
|
asdl_seq* b;
|
|
void *el;
|
|
expr_ty ex;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
Token * literal;
|
|
expr_ty t;
|
|
void *tc;
|
|
if (
|
|
(async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
|
|
&&
|
|
(keyword = _PyPegen_expect_token(p, 517)) // token='for'
|
|
&&
|
|
(t = star_targets_rule(p)) // star_targets
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
|
|
&&
|
|
(ex = star_expressions_rule(p)) // star_expressions
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(el = else_block_rule(p), 1) // else_block?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// with_stmt:
|
|
// | 'with' '(' ','.with_item+ ','? ')' ':' block
|
|
// | 'with' ','.with_item+ ':' TYPE_COMMENT? block
|
|
// | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
|
|
// | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
|
|
static stmt_ty
|
|
with_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'with' '(' ','.with_item+ ','? ')' ':' block
|
|
asdl_seq * a;
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
Token * literal_2;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 519)) // token='with'
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = _gather_38_rule(p)) // ','.with_item+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
&&
|
|
(literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_With ( a , b , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'with' ','.with_item+ ':' TYPE_COMMENT? block
|
|
asdl_seq * a;
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
void *tc;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 519)) // token='with'
|
|
&&
|
|
(a = _gather_40_rule(p)) // ','.with_item+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
|
|
asdl_seq * a;
|
|
Token * async_var;
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
Token * literal_2;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
|
|
&&
|
|
(keyword = _PyPegen_expect_token(p, 519)) // token='with'
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = _gather_42_rule(p)) // ','.with_item+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
&&
|
|
(literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
|
|
asdl_seq * a;
|
|
Token * async_var;
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
void *tc;
|
|
if (
|
|
(async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
|
|
&&
|
|
(keyword = _PyPegen_expect_token(p, 519)) // token='with'
|
|
&&
|
|
(a = _gather_44_rule(p)) // ','.with_item+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// with_item: expression ['as' target]
|
|
static withitem_ty
|
|
with_item_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
withitem_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // expression ['as' target]
|
|
expr_ty e;
|
|
void *o;
|
|
if (
|
|
(e = expression_rule(p)) // expression
|
|
&&
|
|
(o = _tmp_46_rule(p), 1) // ['as' target]
|
|
)
|
|
{
|
|
res = _Py_withitem ( e , o , p -> arena );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// try_stmt:
|
|
// | 'try' ':' block finally_block
|
|
// | 'try' ':' block except_block+ else_block? finally_block?
|
|
static stmt_ty
|
|
try_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'try' ':' block finally_block
|
|
asdl_seq* b;
|
|
asdl_seq* f;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 511)) // token='try'
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(f = finally_block_rule(p)) // finally_block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Try ( b , NULL , NULL , f , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'try' ':' block except_block+ else_block? finally_block?
|
|
asdl_seq* b;
|
|
void *el;
|
|
asdl_seq * ex;
|
|
void *f;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 511)) // token='try'
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
&&
|
|
(ex = _loop1_47_rule(p)) // except_block+
|
|
&&
|
|
(el = else_block_rule(p), 1) // else_block?
|
|
&&
|
|
(f = finally_block_rule(p), 1) // finally_block?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Try ( b , ex , el , f , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// except_block: 'except' expression ['as' target] ':' block | 'except' ':' block
|
|
static excepthandler_ty
|
|
except_block_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
excepthandler_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'except' expression ['as' target] ':' block
|
|
asdl_seq* b;
|
|
expr_ty e;
|
|
Token * keyword;
|
|
Token * literal;
|
|
void *t;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 520)) // token='except'
|
|
&&
|
|
(e = expression_rule(p)) // expression
|
|
&&
|
|
(t = _tmp_48_rule(p), 1) // ['as' target]
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'except' ':' block
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 520)) // token='except'
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// finally_block: 'finally' ':' block
|
|
static asdl_seq*
|
|
finally_block_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'finally' ':' block
|
|
asdl_seq* a;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 521)) // token='finally'
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(a = block_rule(p)) // block
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// return_stmt: 'return' star_expressions?
|
|
static stmt_ty
|
|
return_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'return' star_expressions?
|
|
void *a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 500)) // token='return'
|
|
&&
|
|
(a = star_expressions_rule(p), 1) // star_expressions?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Return ( a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// raise_stmt: 'raise' expression ['from' expression] | 'raise'
|
|
static stmt_ty
|
|
raise_stmt_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'raise' expression ['from' expression]
|
|
expr_ty a;
|
|
void *b;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 501)) // token='raise'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(b = _tmp_49_rule(p), 1) // ['from' expression]
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Raise ( a , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'raise'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 501)) // token='raise'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Raise ( NULL , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// function_def: decorators function_def_raw | function_def_raw
|
|
static stmt_ty
|
|
function_def_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // decorators function_def_raw
|
|
asdl_seq* d;
|
|
stmt_ty f;
|
|
if (
|
|
(d = decorators_rule(p)) // decorators
|
|
&&
|
|
(f = function_def_raw_rule(p)) // function_def_raw
|
|
)
|
|
{
|
|
res = _PyPegen_function_def_decorators ( p , d , f );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // function_def_raw
|
|
stmt_ty function_def_raw_var;
|
|
if (
|
|
(function_def_raw_var = function_def_raw_rule(p)) // function_def_raw
|
|
)
|
|
{
|
|
res = function_def_raw_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// function_def_raw:
|
|
// | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
|
|
// | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
|
|
static stmt_ty
|
|
function_def_raw_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
|
|
void *a;
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
Token * literal_2;
|
|
expr_ty n;
|
|
void *params;
|
|
void *tc;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 522)) // token='def'
|
|
&&
|
|
(n = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(params = params_rule(p), 1) // params?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
&&
|
|
(a = _tmp_50_rule(p), 1) // ['->' expression]
|
|
&&
|
|
(literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(tc = func_type_comment_rule(p), 1) // func_type_comment?
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
|
|
void *a;
|
|
Token * async_var;
|
|
asdl_seq* b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
Token * literal_2;
|
|
expr_ty n;
|
|
void *params;
|
|
void *tc;
|
|
if (
|
|
(async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
|
|
&&
|
|
(keyword = _PyPegen_expect_token(p, 522)) // token='def'
|
|
&&
|
|
(n = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(params = params_rule(p), 1) // params?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
&&
|
|
(a = _tmp_51_rule(p), 1) // ['->' expression]
|
|
&&
|
|
(literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(tc = func_type_comment_rule(p), 1) // func_type_comment?
|
|
&&
|
|
(b = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
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 ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// func_type_comment:
|
|
// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
|
|
// | invalid_double_type_comments
|
|
// | TYPE_COMMENT
|
|
static Token*
|
|
func_type_comment_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
Token* res = NULL;
|
|
int mark = p->mark;
|
|
{ // NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
|
|
Token * newline_var;
|
|
Token * t;
|
|
if (
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
&&
|
|
(t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
|
|
&&
|
|
_PyPegen_lookahead(1, _tmp_52_rule, p)
|
|
)
|
|
{
|
|
res = t;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_double_type_comments
|
|
void *invalid_double_type_comments_var;
|
|
if (
|
|
(invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments
|
|
)
|
|
{
|
|
res = invalid_double_type_comments_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // TYPE_COMMENT
|
|
Token * type_comment_var;
|
|
if (
|
|
(type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
|
|
)
|
|
{
|
|
res = type_comment_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// params: invalid_parameters | parameters
|
|
static arguments_ty
|
|
params_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arguments_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // invalid_parameters
|
|
void *invalid_parameters_var;
|
|
if (
|
|
(invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters
|
|
)
|
|
{
|
|
res = invalid_parameters_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // parameters
|
|
arguments_ty parameters_var;
|
|
if (
|
|
(parameters_var = parameters_rule(p)) // parameters
|
|
)
|
|
{
|
|
res = parameters_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// parameters:
|
|
// | slash_no_default param_no_default* param_with_default* star_etc?
|
|
// | slash_with_default param_with_default* star_etc?
|
|
// | param_no_default+ param_with_default* star_etc?
|
|
// | param_with_default+ star_etc?
|
|
// | star_etc
|
|
static arguments_ty
|
|
parameters_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arguments_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // slash_no_default param_no_default* param_with_default* star_etc?
|
|
asdl_seq* a;
|
|
asdl_seq * b;
|
|
asdl_seq * c;
|
|
void *d;
|
|
if (
|
|
(a = slash_no_default_rule(p)) // slash_no_default
|
|
&&
|
|
(b = _loop0_53_rule(p)) // param_no_default*
|
|
&&
|
|
(c = _loop0_54_rule(p)) // param_with_default*
|
|
&&
|
|
(d = star_etc_rule(p), 1) // star_etc?
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // slash_with_default param_with_default* star_etc?
|
|
SlashWithDefault* a;
|
|
asdl_seq * b;
|
|
void *c;
|
|
if (
|
|
(a = slash_with_default_rule(p)) // slash_with_default
|
|
&&
|
|
(b = _loop0_55_rule(p)) // param_with_default*
|
|
&&
|
|
(c = star_etc_rule(p), 1) // star_etc?
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // param_no_default+ param_with_default* star_etc?
|
|
asdl_seq * a;
|
|
asdl_seq * b;
|
|
void *c;
|
|
if (
|
|
(a = _loop1_56_rule(p)) // param_no_default+
|
|
&&
|
|
(b = _loop0_57_rule(p)) // param_with_default*
|
|
&&
|
|
(c = star_etc_rule(p), 1) // star_etc?
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // param_with_default+ star_etc?
|
|
asdl_seq * a;
|
|
void *b;
|
|
if (
|
|
(a = _loop1_58_rule(p)) // param_with_default+
|
|
&&
|
|
(b = star_etc_rule(p), 1) // star_etc?
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_etc
|
|
StarEtc* a;
|
|
if (
|
|
(a = star_etc_rule(p)) // star_etc
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')'
|
|
static asdl_seq*
|
|
slash_no_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // param_no_default+ '/' ','
|
|
asdl_seq * a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = _loop1_59_rule(p)) // param_no_default+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // param_no_default+ '/' &')'
|
|
asdl_seq * a;
|
|
Token * literal;
|
|
if (
|
|
(a = _loop1_60_rule(p)) // param_no_default+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// slash_with_default:
|
|
// | param_no_default* param_with_default+ '/' ','
|
|
// | param_no_default* param_with_default+ '/' &')'
|
|
static SlashWithDefault*
|
|
slash_with_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
SlashWithDefault* res = NULL;
|
|
int mark = p->mark;
|
|
{ // param_no_default* param_with_default+ '/' ','
|
|
asdl_seq * a;
|
|
asdl_seq * b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = _loop0_61_rule(p)) // param_no_default*
|
|
&&
|
|
(b = _loop1_62_rule(p)) // param_with_default+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
res = _PyPegen_slash_with_default ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // param_no_default* param_with_default+ '/' &')'
|
|
asdl_seq * a;
|
|
asdl_seq * b;
|
|
Token * literal;
|
|
if (
|
|
(a = _loop0_63_rule(p)) // param_no_default*
|
|
&&
|
|
(b = _loop1_64_rule(p)) // param_with_default+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
|
|
)
|
|
{
|
|
res = _PyPegen_slash_with_default ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// star_etc:
|
|
// | '*' param_no_default param_maybe_default* kwds?
|
|
// | '*' ',' param_maybe_default+ kwds?
|
|
// | kwds
|
|
// | invalid_star_etc
|
|
static StarEtc*
|
|
star_etc_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
StarEtc* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '*' param_no_default param_maybe_default* kwds?
|
|
arg_ty a;
|
|
asdl_seq * b;
|
|
void *c;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(a = param_no_default_rule(p)) // param_no_default
|
|
&&
|
|
(b = _loop0_65_rule(p)) // param_maybe_default*
|
|
&&
|
|
(c = kwds_rule(p), 1) // kwds?
|
|
)
|
|
{
|
|
res = _PyPegen_star_etc ( p , a , b , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '*' ',' param_maybe_default+ kwds?
|
|
asdl_seq * b;
|
|
void *c;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(b = _loop1_66_rule(p)) // param_maybe_default+
|
|
&&
|
|
(c = kwds_rule(p), 1) // kwds?
|
|
)
|
|
{
|
|
res = _PyPegen_star_etc ( p , NULL , b , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // kwds
|
|
arg_ty a;
|
|
if (
|
|
(a = kwds_rule(p)) // kwds
|
|
)
|
|
{
|
|
res = _PyPegen_star_etc ( p , NULL , NULL , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_star_etc
|
|
void *invalid_star_etc_var;
|
|
if (
|
|
(invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc
|
|
)
|
|
{
|
|
res = invalid_star_etc_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// kwds: '**' param_no_default
|
|
static arg_ty
|
|
kwds_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arg_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // '**' param_no_default
|
|
arg_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(a = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')'
|
|
static arg_ty
|
|
param_no_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arg_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // param ',' TYPE_COMMENT?
|
|
arg_ty a;
|
|
Token * literal;
|
|
void *tc;
|
|
if (
|
|
(a = param_rule(p)) // param
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
)
|
|
{
|
|
res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // param TYPE_COMMENT? &')'
|
|
arg_ty a;
|
|
void *tc;
|
|
if (
|
|
(a = param_rule(p)) // param
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
|
|
)
|
|
{
|
|
res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')'
|
|
static NameDefaultPair*
|
|
param_with_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
NameDefaultPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // param default ',' TYPE_COMMENT?
|
|
arg_ty a;
|
|
expr_ty c;
|
|
Token * literal;
|
|
void *tc;
|
|
if (
|
|
(a = param_rule(p)) // param
|
|
&&
|
|
(c = default_rule(p)) // default
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
)
|
|
{
|
|
res = _PyPegen_name_default_pair ( p , a , c , tc );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // param default TYPE_COMMENT? &')'
|
|
arg_ty a;
|
|
expr_ty c;
|
|
void *tc;
|
|
if (
|
|
(a = param_rule(p)) // param
|
|
&&
|
|
(c = default_rule(p)) // default
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
|
|
)
|
|
{
|
|
res = _PyPegen_name_default_pair ( p , a , c , tc );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// param_maybe_default:
|
|
// | param default? ',' TYPE_COMMENT?
|
|
// | param default? TYPE_COMMENT? &')'
|
|
static NameDefaultPair*
|
|
param_maybe_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
NameDefaultPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // param default? ',' TYPE_COMMENT?
|
|
arg_ty a;
|
|
void *c;
|
|
Token * literal;
|
|
void *tc;
|
|
if (
|
|
(a = param_rule(p)) // param
|
|
&&
|
|
(c = default_rule(p), 1) // default?
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
)
|
|
{
|
|
res = _PyPegen_name_default_pair ( p , a , c , tc );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // param default? TYPE_COMMENT? &')'
|
|
arg_ty a;
|
|
void *c;
|
|
void *tc;
|
|
if (
|
|
(a = param_rule(p)) // param
|
|
&&
|
|
(c = default_rule(p), 1) // default?
|
|
&&
|
|
(tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
|
|
)
|
|
{
|
|
res = _PyPegen_name_default_pair ( p , a , c , tc );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// param: NAME annotation?
|
|
static arg_ty
|
|
param_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arg_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME annotation?
|
|
expr_ty a;
|
|
void *b;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(b = annotation_rule(p), 1) // annotation?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// annotation: ':' expression
|
|
static expr_ty
|
|
annotation_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // ':' expression
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// default: '=' expression
|
|
static expr_ty
|
|
default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // '=' expression
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// decorators: (('@' named_expression NEWLINE))+
|
|
static asdl_seq*
|
|
decorators_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // (('@' named_expression NEWLINE))+
|
|
asdl_seq * a;
|
|
if (
|
|
(a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// class_def: decorators class_def_raw | class_def_raw
|
|
static stmt_ty
|
|
class_def_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // decorators class_def_raw
|
|
asdl_seq* a;
|
|
stmt_ty b;
|
|
if (
|
|
(a = decorators_rule(p)) // decorators
|
|
&&
|
|
(b = class_def_raw_rule(p)) // class_def_raw
|
|
)
|
|
{
|
|
res = _PyPegen_class_def_decorators ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // class_def_raw
|
|
stmt_ty class_def_raw_var;
|
|
if (
|
|
(class_def_raw_var = class_def_raw_rule(p)) // class_def_raw
|
|
)
|
|
{
|
|
res = class_def_raw_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block
|
|
static stmt_ty
|
|
class_def_raw_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
stmt_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'class' NAME ['(' arguments? ')'] ':' block
|
|
expr_ty a;
|
|
void *b;
|
|
asdl_seq* c;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 523)) // token='class'
|
|
&&
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(b = _tmp_68_rule(p), 1) // ['(' arguments? ')']
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(c = block_rule(p)) // block
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
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 );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
|
|
static asdl_seq*
|
|
block_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
if (_PyPegen_is_memoized(p, block_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
{ // NEWLINE INDENT statements DEDENT
|
|
asdl_seq* a;
|
|
Token * dedent_var;
|
|
Token * indent_var;
|
|
Token * newline_var;
|
|
if (
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
&&
|
|
(indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
|
|
&&
|
|
(a = statements_rule(p)) // statements
|
|
&&
|
|
(dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // simple_stmt
|
|
asdl_seq* simple_stmt_var;
|
|
if (
|
|
(simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
|
|
)
|
|
{
|
|
res = simple_stmt_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_block
|
|
void *invalid_block_var;
|
|
if (
|
|
(invalid_block_var = invalid_block_rule(p)) // invalid_block
|
|
)
|
|
{
|
|
res = invalid_block_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, block_type, res);
|
|
return res;
|
|
}
|
|
|
|
// expressions_list: ','.star_expression+ ','?
|
|
static asdl_seq*
|
|
expressions_list_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.star_expression+ ','?
|
|
asdl_seq * a;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = _gather_69_rule(p)) // ','.star_expression+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// star_expressions:
|
|
// | star_expression ((',' star_expression))+ ','?
|
|
// | star_expression ','
|
|
// | star_expression
|
|
static expr_ty
|
|
star_expressions_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // star_expression ((',' star_expression))+ ','?
|
|
expr_ty a;
|
|
asdl_seq * b;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = star_expression_rule(p)) // star_expression
|
|
&&
|
|
(b = _loop1_71_rule(p)) // ((',' star_expression))+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_expression ','
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(a = star_expression_rule(p)) // star_expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_expression
|
|
expr_ty star_expression_var;
|
|
if (
|
|
(star_expression_var = star_expression_rule(p)) // star_expression
|
|
)
|
|
{
|
|
res = star_expression_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// star_expression: '*' bitwise_or | expression
|
|
static expr_ty
|
|
star_expression_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, star_expression_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '*' bitwise_or
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Starred ( a , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression
|
|
expr_ty expression_var;
|
|
if (
|
|
(expression_var = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = expression_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, star_expression_type, res);
|
|
return res;
|
|
}
|
|
|
|
// star_named_expressions: ','.star_named_expression+ ','?
|
|
static asdl_seq*
|
|
star_named_expressions_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.star_named_expression+ ','?
|
|
asdl_seq * a;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = _gather_72_rule(p)) // ','.star_named_expression+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// star_named_expression: '*' bitwise_or | named_expression
|
|
static expr_ty
|
|
star_named_expression_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '*' bitwise_or
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Starred ( a , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // named_expression
|
|
expr_ty named_expression_var;
|
|
if (
|
|
(named_expression_var = named_expression_rule(p)) // named_expression
|
|
)
|
|
{
|
|
res = named_expression_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression
|
|
static expr_ty
|
|
named_expression_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME ':=' expression
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 53)) // token=':='
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression !':='
|
|
expr_ty expression_var;
|
|
if (
|
|
(expression_var = expression_rule(p)) // expression
|
|
&&
|
|
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':='
|
|
)
|
|
{
|
|
res = expression_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_named_expression
|
|
void *invalid_named_expression_var;
|
|
if (
|
|
(invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression
|
|
)
|
|
{
|
|
res = invalid_named_expression_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// annotated_rhs: yield_expr | star_expressions
|
|
static expr_ty
|
|
annotated_rhs_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // yield_expr
|
|
expr_ty yield_expr_var;
|
|
if (
|
|
(yield_expr_var = yield_expr_rule(p)) // yield_expr
|
|
)
|
|
{
|
|
res = yield_expr_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_expressions
|
|
expr_ty star_expressions_var;
|
|
if (
|
|
(star_expressions_var = star_expressions_rule(p)) // star_expressions
|
|
)
|
|
{
|
|
res = star_expressions_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// expressions: expression ((',' expression))+ ','? | expression ',' | expression
|
|
static expr_ty
|
|
expressions_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // expression ((',' expression))+ ','?
|
|
expr_ty a;
|
|
asdl_seq * b;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(b = _loop1_74_rule(p)) // ((',' expression))+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression ','
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression
|
|
expr_ty expression_var;
|
|
if (
|
|
(expression_var = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = expression_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef
|
|
static expr_ty
|
|
expression_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, expression_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // disjunction 'if' disjunction 'else' expression
|
|
expr_ty a;
|
|
expr_ty b;
|
|
expr_ty c;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
if (
|
|
(a = disjunction_rule(p)) // disjunction
|
|
&&
|
|
(keyword = _PyPegen_expect_token(p, 510)) // token='if'
|
|
&&
|
|
(b = disjunction_rule(p)) // disjunction
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 516)) // token='else'
|
|
&&
|
|
(c = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_IfExp ( b , a , c , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // disjunction
|
|
expr_ty disjunction_var;
|
|
if (
|
|
(disjunction_var = disjunction_rule(p)) // disjunction
|
|
)
|
|
{
|
|
res = disjunction_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambdef
|
|
expr_ty lambdef_var;
|
|
if (
|
|
(lambdef_var = lambdef_rule(p)) // lambdef
|
|
)
|
|
{
|
|
res = lambdef_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, expression_type, res);
|
|
return res;
|
|
}
|
|
|
|
// lambdef: 'lambda' lambda_parameters? ':' expression
|
|
static expr_ty
|
|
lambdef_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'lambda' lambda_parameters? ':' expression
|
|
void *a;
|
|
expr_ty b;
|
|
Token * keyword;
|
|
Token * literal;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 524)) // token='lambda'
|
|
&&
|
|
(a = lambda_parameters_rule(p), 1) // lambda_parameters?
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_parameters:
|
|
// | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
|
|
// | lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
|
|
// | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
|
|
// | lambda_param_with_default+ lambda_star_etc?
|
|
// | lambda_star_etc
|
|
static arguments_ty
|
|
lambda_parameters_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arguments_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
|
|
asdl_seq* a;
|
|
asdl_seq * b;
|
|
asdl_seq * c;
|
|
void *d;
|
|
if (
|
|
(a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default
|
|
&&
|
|
(b = _loop0_75_rule(p)) // lambda_param_no_default*
|
|
&&
|
|
(c = _loop0_76_rule(p)) // lambda_param_with_default*
|
|
&&
|
|
(d = lambda_star_etc_rule(p), 1) // lambda_star_etc?
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
|
|
SlashWithDefault* a;
|
|
asdl_seq * b;
|
|
void *c;
|
|
if (
|
|
(a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
|
|
&&
|
|
(b = _loop0_77_rule(p)) // lambda_param_with_default*
|
|
&&
|
|
(c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
|
|
asdl_seq * a;
|
|
asdl_seq * b;
|
|
void *c;
|
|
if (
|
|
(a = _loop1_78_rule(p)) // lambda_param_no_default+
|
|
&&
|
|
(b = _loop0_79_rule(p)) // lambda_param_with_default*
|
|
&&
|
|
(c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_param_with_default+ lambda_star_etc?
|
|
asdl_seq * a;
|
|
void *b;
|
|
if (
|
|
(a = _loop1_80_rule(p)) // lambda_param_with_default+
|
|
&&
|
|
(b = lambda_star_etc_rule(p), 1) // lambda_star_etc?
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_star_etc
|
|
StarEtc* a;
|
|
if (
|
|
(a = lambda_star_etc_rule(p)) // lambda_star_etc
|
|
)
|
|
{
|
|
res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_slash_no_default:
|
|
// | lambda_param_no_default+ '/' ','
|
|
// | lambda_param_no_default+ '/' &':'
|
|
static asdl_seq*
|
|
lambda_slash_no_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // lambda_param_no_default+ '/' ','
|
|
asdl_seq * a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = _loop1_81_rule(p)) // lambda_param_no_default+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_param_no_default+ '/' &':'
|
|
asdl_seq * a;
|
|
Token * literal;
|
|
if (
|
|
(a = _loop1_82_rule(p)) // lambda_param_no_default+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_slash_with_default:
|
|
// | lambda_param_no_default* lambda_param_with_default+ '/' ','
|
|
// | lambda_param_no_default* lambda_param_with_default+ '/' &':'
|
|
static SlashWithDefault*
|
|
lambda_slash_with_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
SlashWithDefault* res = NULL;
|
|
int mark = p->mark;
|
|
{ // lambda_param_no_default* lambda_param_with_default+ '/' ','
|
|
asdl_seq * a;
|
|
asdl_seq * b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = _loop0_83_rule(p)) // lambda_param_no_default*
|
|
&&
|
|
(b = _loop1_84_rule(p)) // lambda_param_with_default+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
res = _PyPegen_slash_with_default ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_param_no_default* lambda_param_with_default+ '/' &':'
|
|
asdl_seq * a;
|
|
asdl_seq * b;
|
|
Token * literal;
|
|
if (
|
|
(a = _loop0_85_rule(p)) // lambda_param_no_default*
|
|
&&
|
|
(b = _loop1_86_rule(p)) // lambda_param_with_default+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
|
|
)
|
|
{
|
|
res = _PyPegen_slash_with_default ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_star_etc:
|
|
// | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
|
|
// | '*' ',' lambda_param_maybe_default+ lambda_kwds?
|
|
// | lambda_kwds
|
|
// | invalid_lambda_star_etc
|
|
static StarEtc*
|
|
lambda_star_etc_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
StarEtc* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
|
|
arg_ty a;
|
|
asdl_seq * b;
|
|
void *c;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(a = lambda_param_no_default_rule(p)) // lambda_param_no_default
|
|
&&
|
|
(b = _loop0_87_rule(p)) // lambda_param_maybe_default*
|
|
&&
|
|
(c = lambda_kwds_rule(p), 1) // lambda_kwds?
|
|
)
|
|
{
|
|
res = _PyPegen_star_etc ( p , a , b , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '*' ',' lambda_param_maybe_default+ lambda_kwds?
|
|
asdl_seq * b;
|
|
void *c;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(b = _loop1_88_rule(p)) // lambda_param_maybe_default+
|
|
&&
|
|
(c = lambda_kwds_rule(p), 1) // lambda_kwds?
|
|
)
|
|
{
|
|
res = _PyPegen_star_etc ( p , NULL , b , c );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_kwds
|
|
arg_ty a;
|
|
if (
|
|
(a = lambda_kwds_rule(p)) // lambda_kwds
|
|
)
|
|
{
|
|
res = _PyPegen_star_etc ( p , NULL , NULL , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_lambda_star_etc
|
|
void *invalid_lambda_star_etc_var;
|
|
if (
|
|
(invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc
|
|
)
|
|
{
|
|
res = invalid_lambda_star_etc_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_kwds: '**' lambda_param_no_default
|
|
static arg_ty
|
|
lambda_kwds_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arg_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // '**' lambda_param_no_default
|
|
arg_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(a = lambda_param_no_default_rule(p)) // lambda_param_no_default
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_param_no_default: lambda_param ',' | lambda_param &':'
|
|
static arg_ty
|
|
lambda_param_no_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arg_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // lambda_param ','
|
|
arg_ty a;
|
|
Token * literal;
|
|
if (
|
|
(a = lambda_param_rule(p)) // lambda_param
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_param &':'
|
|
arg_ty a;
|
|
if (
|
|
(a = lambda_param_rule(p)) // lambda_param
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_param_with_default: lambda_param default ',' | lambda_param default &':'
|
|
static NameDefaultPair*
|
|
lambda_param_with_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
NameDefaultPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // lambda_param default ','
|
|
arg_ty a;
|
|
expr_ty c;
|
|
Token * literal;
|
|
if (
|
|
(a = lambda_param_rule(p)) // lambda_param
|
|
&&
|
|
(c = default_rule(p)) // default
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
res = _PyPegen_name_default_pair ( p , a , c , NULL );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_param default &':'
|
|
arg_ty a;
|
|
expr_ty c;
|
|
if (
|
|
(a = lambda_param_rule(p)) // lambda_param
|
|
&&
|
|
(c = default_rule(p)) // default
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
|
|
)
|
|
{
|
|
res = _PyPegen_name_default_pair ( p , a , c , NULL );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':'
|
|
static NameDefaultPair*
|
|
lambda_param_maybe_default_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
NameDefaultPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // lambda_param default? ','
|
|
arg_ty a;
|
|
void *c;
|
|
Token * literal;
|
|
if (
|
|
(a = lambda_param_rule(p)) // lambda_param
|
|
&&
|
|
(c = default_rule(p), 1) // default?
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
)
|
|
{
|
|
res = _PyPegen_name_default_pair ( p , a , c , NULL );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lambda_param default? &':'
|
|
arg_ty a;
|
|
void *c;
|
|
if (
|
|
(a = lambda_param_rule(p)) // lambda_param
|
|
&&
|
|
(c = default_rule(p), 1) // default?
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
|
|
)
|
|
{
|
|
res = _PyPegen_name_default_pair ( p , a , c , NULL );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lambda_param: NAME
|
|
static arg_ty
|
|
lambda_param_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
arg_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME
|
|
expr_ty a;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// disjunction: conjunction (('or' conjunction))+ | conjunction
|
|
static expr_ty
|
|
disjunction_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, disjunction_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // conjunction (('or' conjunction))+
|
|
expr_ty a;
|
|
asdl_seq * b;
|
|
if (
|
|
(a = conjunction_rule(p)) // conjunction
|
|
&&
|
|
(b = _loop1_89_rule(p)) // (('or' conjunction))+
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // conjunction
|
|
expr_ty conjunction_var;
|
|
if (
|
|
(conjunction_var = conjunction_rule(p)) // conjunction
|
|
)
|
|
{
|
|
res = conjunction_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, disjunction_type, res);
|
|
return res;
|
|
}
|
|
|
|
// conjunction: inversion (('and' inversion))+ | inversion
|
|
static expr_ty
|
|
conjunction_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, conjunction_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // inversion (('and' inversion))+
|
|
expr_ty a;
|
|
asdl_seq * b;
|
|
if (
|
|
(a = inversion_rule(p)) // inversion
|
|
&&
|
|
(b = _loop1_90_rule(p)) // (('and' inversion))+
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // inversion
|
|
expr_ty inversion_var;
|
|
if (
|
|
(inversion_var = inversion_rule(p)) // inversion
|
|
)
|
|
{
|
|
res = inversion_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, conjunction_type, res);
|
|
return res;
|
|
}
|
|
|
|
// inversion: 'not' inversion | comparison
|
|
static expr_ty
|
|
inversion_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, inversion_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'not' inversion
|
|
expr_ty a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 525)) // token='not'
|
|
&&
|
|
(a = inversion_rule(p)) // inversion
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_UnaryOp ( Not , a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // comparison
|
|
expr_ty comparison_var;
|
|
if (
|
|
(comparison_var = comparison_rule(p)) // comparison
|
|
)
|
|
{
|
|
res = comparison_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, inversion_type, res);
|
|
return res;
|
|
}
|
|
|
|
// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or
|
|
static expr_ty
|
|
comparison_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // bitwise_or compare_op_bitwise_or_pair+
|
|
expr_ty a;
|
|
asdl_seq * b;
|
|
if (
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
&&
|
|
(b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // bitwise_or
|
|
expr_ty bitwise_or_var;
|
|
if (
|
|
(bitwise_or_var = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// compare_op_bitwise_or_pair:
|
|
// | eq_bitwise_or
|
|
// | noteq_bitwise_or
|
|
// | lte_bitwise_or
|
|
// | lt_bitwise_or
|
|
// | gte_bitwise_or
|
|
// | gt_bitwise_or
|
|
// | notin_bitwise_or
|
|
// | in_bitwise_or
|
|
// | isnot_bitwise_or
|
|
// | is_bitwise_or
|
|
static CmpopExprPair*
|
|
compare_op_bitwise_or_pair_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // eq_bitwise_or
|
|
CmpopExprPair* eq_bitwise_or_var;
|
|
if (
|
|
(eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or
|
|
)
|
|
{
|
|
res = eq_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // noteq_bitwise_or
|
|
CmpopExprPair* noteq_bitwise_or_var;
|
|
if (
|
|
(noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or
|
|
)
|
|
{
|
|
res = noteq_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lte_bitwise_or
|
|
CmpopExprPair* lte_bitwise_or_var;
|
|
if (
|
|
(lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or
|
|
)
|
|
{
|
|
res = lte_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // lt_bitwise_or
|
|
CmpopExprPair* lt_bitwise_or_var;
|
|
if (
|
|
(lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or
|
|
)
|
|
{
|
|
res = lt_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // gte_bitwise_or
|
|
CmpopExprPair* gte_bitwise_or_var;
|
|
if (
|
|
(gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or
|
|
)
|
|
{
|
|
res = gte_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // gt_bitwise_or
|
|
CmpopExprPair* gt_bitwise_or_var;
|
|
if (
|
|
(gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or
|
|
)
|
|
{
|
|
res = gt_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // notin_bitwise_or
|
|
CmpopExprPair* notin_bitwise_or_var;
|
|
if (
|
|
(notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or
|
|
)
|
|
{
|
|
res = notin_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // in_bitwise_or
|
|
CmpopExprPair* in_bitwise_or_var;
|
|
if (
|
|
(in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or
|
|
)
|
|
{
|
|
res = in_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // isnot_bitwise_or
|
|
CmpopExprPair* isnot_bitwise_or_var;
|
|
if (
|
|
(isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or
|
|
)
|
|
{
|
|
res = isnot_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // is_bitwise_or
|
|
CmpopExprPair* is_bitwise_or_var;
|
|
if (
|
|
(is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or
|
|
)
|
|
{
|
|
res = is_bitwise_or_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// eq_bitwise_or: '==' bitwise_or
|
|
static CmpopExprPair*
|
|
eq_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '==' bitwise_or
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 27)) // token='=='
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , Eq , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// noteq_bitwise_or: ('!=') bitwise_or
|
|
static CmpopExprPair*
|
|
noteq_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ('!=') bitwise_or
|
|
void *_tmp_92_var;
|
|
expr_ty a;
|
|
if (
|
|
(_tmp_92_var = _tmp_92_rule(p)) // '!='
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , NotEq , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lte_bitwise_or: '<=' bitwise_or
|
|
static CmpopExprPair*
|
|
lte_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '<=' bitwise_or
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 29)) // token='<='
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , LtE , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// lt_bitwise_or: '<' bitwise_or
|
|
static CmpopExprPair*
|
|
lt_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '<' bitwise_or
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 20)) // token='<'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , Lt , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// gte_bitwise_or: '>=' bitwise_or
|
|
static CmpopExprPair*
|
|
gte_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '>=' bitwise_or
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 30)) // token='>='
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , GtE , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// gt_bitwise_or: '>' bitwise_or
|
|
static CmpopExprPair*
|
|
gt_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '>' bitwise_or
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 21)) // token='>'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , Gt , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// notin_bitwise_or: 'not' 'in' bitwise_or
|
|
static CmpopExprPair*
|
|
notin_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'not' 'in' bitwise_or
|
|
expr_ty a;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 525)) // token='not'
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , NotIn , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// in_bitwise_or: 'in' bitwise_or
|
|
static CmpopExprPair*
|
|
in_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'in' bitwise_or
|
|
expr_ty a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 518)) // token='in'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , In , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// isnot_bitwise_or: 'is' 'not' bitwise_or
|
|
static CmpopExprPair*
|
|
isnot_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'is' 'not' bitwise_or
|
|
expr_ty a;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 526)) // token='is'
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 525)) // token='not'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , IsNot , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// is_bitwise_or: 'is' bitwise_or
|
|
static CmpopExprPair*
|
|
is_bitwise_or_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
CmpopExprPair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'is' bitwise_or
|
|
expr_ty a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 526)) // token='is'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_cmpop_expr_pair ( p , Is , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor
|
|
static expr_ty bitwise_or_raw(Parser *);
|
|
static expr_ty
|
|
bitwise_or_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, bitwise_or_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_1 = _PyPegen_update_memo(p, mark, bitwise_or_type, res);
|
|
if (tmpvar_1) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = bitwise_or_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
bitwise_or_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // bitwise_or '|' bitwise_xor
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 18)) // token='|'
|
|
&&
|
|
(b = bitwise_xor_rule(p)) // bitwise_xor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , BitOr , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // bitwise_xor
|
|
expr_ty bitwise_xor_var;
|
|
if (
|
|
(bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor
|
|
)
|
|
{
|
|
res = bitwise_xor_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and
|
|
static expr_ty bitwise_xor_raw(Parser *);
|
|
static expr_ty
|
|
bitwise_xor_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, bitwise_xor_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_2 = _PyPegen_update_memo(p, mark, bitwise_xor_type, res);
|
|
if (tmpvar_2) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = bitwise_xor_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
bitwise_xor_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // bitwise_xor '^' bitwise_and
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = bitwise_xor_rule(p)) // bitwise_xor
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 32)) // token='^'
|
|
&&
|
|
(b = bitwise_and_rule(p)) // bitwise_and
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , BitXor , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // bitwise_and
|
|
expr_ty bitwise_and_var;
|
|
if (
|
|
(bitwise_and_var = bitwise_and_rule(p)) // bitwise_and
|
|
)
|
|
{
|
|
res = bitwise_and_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// bitwise_and: bitwise_and '&' shift_expr | shift_expr
|
|
static expr_ty bitwise_and_raw(Parser *);
|
|
static expr_ty
|
|
bitwise_and_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, bitwise_and_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_3 = _PyPegen_update_memo(p, mark, bitwise_and_type, res);
|
|
if (tmpvar_3) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = bitwise_and_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
bitwise_and_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // bitwise_and '&' shift_expr
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = bitwise_and_rule(p)) // bitwise_and
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 19)) // token='&'
|
|
&&
|
|
(b = shift_expr_rule(p)) // shift_expr
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , BitAnd , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // shift_expr
|
|
expr_ty shift_expr_var;
|
|
if (
|
|
(shift_expr_var = shift_expr_rule(p)) // shift_expr
|
|
)
|
|
{
|
|
res = shift_expr_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum
|
|
static expr_ty shift_expr_raw(Parser *);
|
|
static expr_ty
|
|
shift_expr_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, shift_expr_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_4 = _PyPegen_update_memo(p, mark, shift_expr_type, res);
|
|
if (tmpvar_4) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = shift_expr_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
shift_expr_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // shift_expr '<<' sum
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = shift_expr_rule(p)) // shift_expr
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 33)) // token='<<'
|
|
&&
|
|
(b = sum_rule(p)) // sum
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , LShift , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // shift_expr '>>' sum
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = shift_expr_rule(p)) // shift_expr
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 34)) // token='>>'
|
|
&&
|
|
(b = sum_rule(p)) // sum
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , RShift , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // sum
|
|
expr_ty sum_var;
|
|
if (
|
|
(sum_var = sum_rule(p)) // sum
|
|
)
|
|
{
|
|
res = sum_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// sum: sum '+' term | sum '-' term | term
|
|
static expr_ty sum_raw(Parser *);
|
|
static expr_ty
|
|
sum_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, sum_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_5 = _PyPegen_update_memo(p, mark, sum_type, res);
|
|
if (tmpvar_5) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = sum_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
sum_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // sum '+' term
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = sum_rule(p)) // sum
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 14)) // token='+'
|
|
&&
|
|
(b = term_rule(p)) // term
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , Add , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // sum '-' term
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = sum_rule(p)) // sum
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 15)) // token='-'
|
|
&&
|
|
(b = term_rule(p)) // term
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , Sub , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // term
|
|
expr_ty term_var;
|
|
if (
|
|
(term_var = term_rule(p)) // term
|
|
)
|
|
{
|
|
res = term_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// term:
|
|
// | term '*' factor
|
|
// | term '/' factor
|
|
// | term '//' factor
|
|
// | term '%' factor
|
|
// | term '@' factor
|
|
// | factor
|
|
static expr_ty term_raw(Parser *);
|
|
static expr_ty
|
|
term_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, term_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_6 = _PyPegen_update_memo(p, mark, term_type, res);
|
|
if (tmpvar_6) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = term_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
term_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // term '*' factor
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = term_rule(p)) // term
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(b = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , Mult , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // term '/' factor
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = term_rule(p)) // term
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 17)) // token='/'
|
|
&&
|
|
(b = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , Div , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // term '//' factor
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = term_rule(p)) // term
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 47)) // token='//'
|
|
&&
|
|
(b = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , FloorDiv , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // term '%' factor
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = term_rule(p)) // term
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 24)) // token='%'
|
|
&&
|
|
(b = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , Mod , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // term '@' factor
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = term_rule(p)) // term
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 49)) // token='@'
|
|
&&
|
|
(b = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // factor
|
|
expr_ty factor_var;
|
|
if (
|
|
(factor_var = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
res = factor_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// factor: '+' factor | '-' factor | '~' factor | power
|
|
static expr_ty
|
|
factor_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, factor_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '+' factor
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 14)) // token='+'
|
|
&&
|
|
(a = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_UnaryOp ( UAdd , a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '-' factor
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 15)) // token='-'
|
|
&&
|
|
(a = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_UnaryOp ( USub , a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '~' factor
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 31)) // token='~'
|
|
&&
|
|
(a = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_UnaryOp ( Invert , a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // power
|
|
expr_ty power_var;
|
|
if (
|
|
(power_var = power_rule(p)) // power
|
|
)
|
|
{
|
|
res = power_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, factor_type, res);
|
|
return res;
|
|
}
|
|
|
|
// power: await_primary '**' factor | await_primary
|
|
static expr_ty
|
|
power_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // await_primary '**' factor
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = await_primary_rule(p)) // await_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(b = factor_rule(p)) // factor
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_BinOp ( a , Pow , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // await_primary
|
|
expr_ty await_primary_var;
|
|
if (
|
|
(await_primary_var = await_primary_rule(p)) // await_primary
|
|
)
|
|
{
|
|
res = await_primary_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// await_primary: AWAIT primary | primary
|
|
static expr_ty
|
|
await_primary_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, await_primary_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // AWAIT primary
|
|
expr_ty a;
|
|
Token * await_var;
|
|
if (
|
|
(await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT'
|
|
&&
|
|
(a = primary_rule(p)) // primary
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // primary
|
|
expr_ty primary_var;
|
|
if (
|
|
(primary_var = primary_rule(p)) // primary
|
|
)
|
|
{
|
|
res = primary_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, await_primary_type, res);
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// primary:
|
|
// | primary '.' NAME
|
|
// | primary genexp
|
|
// | primary '(' arguments? ')'
|
|
// | primary '[' slices ']'
|
|
// | atom
|
|
static expr_ty primary_raw(Parser *);
|
|
static expr_ty
|
|
primary_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, primary_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_7 = _PyPegen_update_memo(p, mark, primary_type, res);
|
|
if (tmpvar_7) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = primary_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
primary_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // primary '.' NAME
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = primary_rule(p)) // primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
&&
|
|
(b = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // primary genexp
|
|
expr_ty a;
|
|
expr_ty b;
|
|
if (
|
|
(a = primary_rule(p)) // primary
|
|
&&
|
|
(b = genexp_rule(p)) // genexp
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // primary '(' arguments? ')'
|
|
expr_ty a;
|
|
void *b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = primary_rule(p)) // primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(b = arguments_rule(p), 1) // arguments?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // primary '[' slices ']'
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = primary_rule(p)) // primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(b = slices_rule(p)) // slices
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Subscript ( a , b , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // atom
|
|
expr_ty atom_var;
|
|
if (
|
|
(atom_var = atom_rule(p)) // atom
|
|
)
|
|
{
|
|
res = atom_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// slices: slice !',' | ','.slice+ ','?
|
|
static expr_ty
|
|
slices_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // slice !','
|
|
expr_ty a;
|
|
if (
|
|
(a = slice_rule(p)) // slice
|
|
&&
|
|
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ','.slice+ ','?
|
|
asdl_seq * a;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = _gather_93_rule(p)) // ','.slice+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( a , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// slice: expression? ':' expression? [':' expression?] | expression
|
|
static expr_ty
|
|
slice_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // expression? ':' expression? [':' expression?]
|
|
void *a;
|
|
void *b;
|
|
void *c;
|
|
Token * literal;
|
|
if (
|
|
(a = expression_rule(p), 1) // expression?
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = expression_rule(p), 1) // expression?
|
|
&&
|
|
(c = _tmp_95_rule(p), 1) // [':' expression?]
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Slice ( a , b , c , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression
|
|
expr_ty a;
|
|
if (
|
|
(a = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// atom:
|
|
// | NAME
|
|
// | 'True'
|
|
// | 'False'
|
|
// | 'None'
|
|
// | '__new_parser__'
|
|
// | &STRING strings
|
|
// | NUMBER
|
|
// | &'(' (tuple | group | genexp)
|
|
// | &'[' (list | listcomp)
|
|
// | &'{' (dict | set | dictcomp | setcomp)
|
|
// | '...'
|
|
static expr_ty
|
|
atom_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME
|
|
expr_ty name_var;
|
|
if (
|
|
(name_var = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = name_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'True'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 527)) // token='True'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Constant ( Py_True , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'False'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 528)) // token='False'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Constant ( Py_False , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'None'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 529)) // token='None'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Constant ( Py_None , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '__new_parser__'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__'
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "You found it!" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &STRING strings
|
|
expr_ty strings_var;
|
|
if (
|
|
_PyPegen_lookahead(1, _PyPegen_string_token, p)
|
|
&&
|
|
(strings_var = strings_rule(p)) // strings
|
|
)
|
|
{
|
|
res = strings_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // NUMBER
|
|
expr_ty number_var;
|
|
if (
|
|
(number_var = _PyPegen_number_token(p)) // NUMBER
|
|
)
|
|
{
|
|
res = number_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'(' (tuple | group | genexp)
|
|
void *_tmp_96_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='('
|
|
&&
|
|
(_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp
|
|
)
|
|
{
|
|
res = _tmp_96_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'[' (list | listcomp)
|
|
void *_tmp_97_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='['
|
|
&&
|
|
(_tmp_97_var = _tmp_97_rule(p)) // list | listcomp
|
|
)
|
|
{
|
|
res = _tmp_97_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // &'{' (dict | set | dictcomp | setcomp)
|
|
void *_tmp_98_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{'
|
|
&&
|
|
(_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp
|
|
)
|
|
{
|
|
res = _tmp_98_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '...'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 52)) // token='...'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// strings: STRING+
|
|
static expr_ty
|
|
strings_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, strings_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
{ // STRING+
|
|
asdl_seq * a;
|
|
if (
|
|
(a = _loop1_99_rule(p)) // STRING+
|
|
)
|
|
{
|
|
res = _PyPegen_concatenate_strings ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, strings_type, res);
|
|
return res;
|
|
}
|
|
|
|
// list: '[' star_named_expressions? ']'
|
|
static expr_ty
|
|
list_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '[' star_named_expressions? ']'
|
|
void *a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(a = star_named_expressions_rule(p), 1) // star_named_expressions?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_List ( a , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension
|
|
static expr_ty
|
|
listcomp_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '[' named_expression for_if_clauses ']'
|
|
expr_ty a;
|
|
asdl_seq* b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(a = named_expression_rule(p)) // named_expression
|
|
&&
|
|
(b = for_if_clauses_rule(p)) // for_if_clauses
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_ListComp ( a , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_comprehension
|
|
void *invalid_comprehension_var;
|
|
if (
|
|
(invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
|
|
)
|
|
{
|
|
res = invalid_comprehension_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// tuple: '(' [star_named_expression ',' star_named_expressions?] ')'
|
|
static expr_ty
|
|
tuple_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '(' [star_named_expression ',' star_named_expressions?] ')'
|
|
void *a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?]
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( a , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// group: '(' (yield_expr | named_expression) ')'
|
|
static expr_ty
|
|
group_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // '(' (yield_expr | named_expression) ')'
|
|
void *a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = _tmp_101_rule(p)) // yield_expr | named_expression
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// genexp: '(' expression for_if_clauses ')' | invalid_comprehension
|
|
static expr_ty
|
|
genexp_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '(' expression for_if_clauses ')'
|
|
expr_ty a;
|
|
asdl_seq* b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(b = for_if_clauses_rule(p)) // for_if_clauses
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_GeneratorExp ( a , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_comprehension
|
|
void *invalid_comprehension_var;
|
|
if (
|
|
(invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
|
|
)
|
|
{
|
|
res = invalid_comprehension_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// set: '{' expressions_list '}'
|
|
static expr_ty
|
|
set_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '{' expressions_list '}'
|
|
asdl_seq* a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 25)) // token='{'
|
|
&&
|
|
(a = expressions_list_rule(p)) // expressions_list
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Set ( a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// setcomp: '{' expression for_if_clauses '}' | invalid_comprehension
|
|
static expr_ty
|
|
setcomp_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '{' expression for_if_clauses '}'
|
|
expr_ty a;
|
|
asdl_seq* b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 25)) // token='{'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(b = for_if_clauses_rule(p)) // for_if_clauses
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_SetComp ( a , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_comprehension
|
|
void *invalid_comprehension_var;
|
|
if (
|
|
(invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
|
|
)
|
|
{
|
|
res = invalid_comprehension_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// dict: '{' kvpairs? '}'
|
|
static expr_ty
|
|
dict_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '{' kvpairs? '}'
|
|
void *a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 25)) // token='{'
|
|
&&
|
|
(a = kvpairs_rule(p), 1) // kvpairs?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// dictcomp: '{' kvpair for_if_clauses '}'
|
|
static expr_ty
|
|
dictcomp_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '{' kvpair for_if_clauses '}'
|
|
KeyValuePair* a;
|
|
asdl_seq* b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 25)) // token='{'
|
|
&&
|
|
(a = kvpair_rule(p)) // kvpair
|
|
&&
|
|
(b = for_if_clauses_rule(p)) // for_if_clauses
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_DictComp ( a -> key , a -> value , b , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// kvpairs: ','.kvpair+ ','?
|
|
static asdl_seq*
|
|
kvpairs_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.kvpair+ ','?
|
|
asdl_seq * a;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = _gather_102_rule(p)) // ','.kvpair+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// kvpair: '**' bitwise_or | expression ':' expression
|
|
static KeyValuePair*
|
|
kvpair_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
KeyValuePair* res = NULL;
|
|
int mark = p->mark;
|
|
{ // '**' bitwise_or
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(a = bitwise_or_rule(p)) // bitwise_or
|
|
)
|
|
{
|
|
res = _PyPegen_key_value_pair ( p , NULL , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression ':' expression
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = _PyPegen_key_value_pair ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// for_if_clauses: for_if_clause+
|
|
static asdl_seq*
|
|
for_if_clauses_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // for_if_clause+
|
|
asdl_seq * _loop1_104_var;
|
|
if (
|
|
(_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+
|
|
)
|
|
{
|
|
res = _loop1_104_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// for_if_clause:
|
|
// | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
|
|
// | 'for' star_targets 'in' disjunction (('if' disjunction))*
|
|
static comprehension_ty
|
|
for_if_clause_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
comprehension_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
|
|
expr_ty a;
|
|
Token * async_var;
|
|
expr_ty b;
|
|
asdl_seq * c;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
if (
|
|
(async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
|
|
&&
|
|
(keyword = _PyPegen_expect_token(p, 517)) // token='for'
|
|
&&
|
|
(a = star_targets_rule(p)) // star_targets
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
|
|
&&
|
|
(b = disjunction_rule(p)) // disjunction
|
|
&&
|
|
(c = _loop0_105_rule(p)) // (('if' disjunction))*
|
|
)
|
|
{
|
|
res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'for' star_targets 'in' disjunction (('if' disjunction))*
|
|
expr_ty a;
|
|
expr_ty b;
|
|
asdl_seq * c;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 517)) // token='for'
|
|
&&
|
|
(a = star_targets_rule(p)) // star_targets
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
|
|
&&
|
|
(b = disjunction_rule(p)) // disjunction
|
|
&&
|
|
(c = _loop0_106_rule(p)) // (('if' disjunction))*
|
|
)
|
|
{
|
|
res = _Py_comprehension ( a , b , c , 0 , p -> arena );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// yield_expr: 'yield' 'from' expression | 'yield' star_expressions?
|
|
static expr_ty
|
|
yield_expr_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // 'yield' 'from' expression
|
|
expr_ty a;
|
|
Token * keyword;
|
|
Token * keyword_1;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 504)) // token='yield'
|
|
&&
|
|
(keyword_1 = _PyPegen_expect_token(p, 514)) // token='from'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_YieldFrom ( a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'yield' star_expressions?
|
|
void *a;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 504)) // token='yield'
|
|
&&
|
|
(a = star_expressions_rule(p), 1) // star_expressions?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Yield ( a , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// arguments: args ','? &')' | incorrect_arguments
|
|
static expr_ty
|
|
arguments_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, arguments_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
{ // args ','? &')'
|
|
expr_ty a;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = args_rule(p)) // args
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
&&
|
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // incorrect_arguments
|
|
void *incorrect_arguments_var;
|
|
if (
|
|
(incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments
|
|
)
|
|
{
|
|
res = incorrect_arguments_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, arguments_type, res);
|
|
return res;
|
|
}
|
|
|
|
// args: starred_expression [',' args] | kwargs | named_expression [',' args]
|
|
static expr_ty
|
|
args_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // starred_expression [',' args]
|
|
expr_ty a;
|
|
void *b;
|
|
if (
|
|
(a = starred_expression_rule(p)) // starred_expression
|
|
&&
|
|
(b = _tmp_107_rule(p), 1) // [',' args]
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
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 );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // kwargs
|
|
asdl_seq* a;
|
|
if (
|
|
(a = kwargs_rule(p)) // kwargs
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
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 );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // named_expression [',' args]
|
|
expr_ty a;
|
|
void *b;
|
|
if (
|
|
(a = named_expression_rule(p)) // named_expression
|
|
&&
|
|
(b = _tmp_108_rule(p), 1) // [',' args]
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
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 );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// kwargs:
|
|
// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
|
|
// | ','.kwarg_or_starred+
|
|
// | ','.kwarg_or_double_starred+
|
|
static asdl_seq*
|
|
kwargs_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
|
|
asdl_seq * a;
|
|
asdl_seq * b;
|
|
Token * literal;
|
|
if (
|
|
(a = _gather_109_rule(p)) // ','.kwarg_or_starred+
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+
|
|
)
|
|
{
|
|
res = _PyPegen_join_sequences ( p , a , b );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ','.kwarg_or_starred+
|
|
asdl_seq * _gather_113_var;
|
|
if (
|
|
(_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+
|
|
)
|
|
{
|
|
res = _gather_113_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ','.kwarg_or_double_starred+
|
|
asdl_seq * _gather_115_var;
|
|
if (
|
|
(_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+
|
|
)
|
|
{
|
|
res = _gather_115_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// starred_expression: '*' expression
|
|
static expr_ty
|
|
starred_expression_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '*' expression
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Starred ( a , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg
|
|
static KeywordOrStarred*
|
|
kwarg_or_starred_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
KeywordOrStarred* res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME '=' expression
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // starred_expression
|
|
expr_ty a;
|
|
if (
|
|
(a = starred_expression_rule(p)) // starred_expression
|
|
)
|
|
{
|
|
res = _PyPegen_keyword_or_starred ( p , a , 0 );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_kwarg
|
|
void *invalid_kwarg_var;
|
|
if (
|
|
(invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg
|
|
)
|
|
{
|
|
res = invalid_kwarg_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg
|
|
static KeywordOrStarred*
|
|
kwarg_or_double_starred_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
KeywordOrStarred* res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME '=' expression
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
&&
|
|
(b = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '**' expression
|
|
expr_ty a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 35)) // token='**'
|
|
&&
|
|
(a = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // invalid_kwarg
|
|
void *invalid_kwarg_var;
|
|
if (
|
|
(invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg
|
|
)
|
|
{
|
|
res = invalid_kwarg_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// star_targets: star_target !',' | star_target ((',' star_target))* ','?
|
|
static expr_ty
|
|
star_targets_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // star_target !','
|
|
expr_ty a;
|
|
if (
|
|
(a = star_target_rule(p)) // star_target
|
|
&&
|
|
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_target ((',' star_target))* ','?
|
|
expr_ty a;
|
|
asdl_seq * b;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = star_target_rule(p)) // star_target
|
|
&&
|
|
(b = _loop0_117_rule(p)) // ((',' star_target))*
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// star_targets_seq: ','.star_target+ ','?
|
|
static asdl_seq*
|
|
star_targets_seq_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.star_target+ ','?
|
|
asdl_seq * a;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = _gather_118_rule(p)) // ','.star_target+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// star_target:
|
|
// | '*' (!'*' star_target)
|
|
// | t_primary '.' NAME !t_lookahead
|
|
// | t_primary '[' slices ']' !t_lookahead
|
|
// | star_atom
|
|
static expr_ty
|
|
star_target_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, star_target_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // '*' (!'*' star_target)
|
|
void *a;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(a = _tmp_120_rule(p)) // !'*' star_target
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_primary '.' NAME !t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
&&
|
|
(b = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
_PyPegen_lookahead(0, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_primary '[' slices ']' !t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(b = slices_rule(p)) // slices
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
&&
|
|
_PyPegen_lookahead(0, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Subscript ( a , b , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_atom
|
|
expr_ty star_atom_var;
|
|
if (
|
|
(star_atom_var = star_atom_rule(p)) // star_atom
|
|
)
|
|
{
|
|
res = star_atom_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, star_target_type, res);
|
|
return res;
|
|
}
|
|
|
|
// star_atom:
|
|
// | NAME
|
|
// | '(' star_target ')'
|
|
// | '(' star_targets_seq? ')'
|
|
// | '[' star_targets_seq? ']'
|
|
static expr_ty
|
|
star_atom_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME
|
|
expr_ty a;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = _PyPegen_set_expr_context ( p , a , Store );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '(' star_target ')'
|
|
expr_ty a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = star_target_rule(p)) // star_target
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = _PyPegen_set_expr_context ( p , a , Store );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '(' star_targets_seq? ')'
|
|
void *a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = star_targets_seq_rule(p), 1) // star_targets_seq?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( a , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '[' star_targets_seq? ']'
|
|
void *a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(a = star_targets_seq_rule(p), 1) // star_targets_seq?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_List ( a , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// inside_paren_ann_assign_target:
|
|
// | ann_assign_subscript_attribute_target
|
|
// | NAME
|
|
// | '(' inside_paren_ann_assign_target ')'
|
|
static expr_ty
|
|
inside_paren_ann_assign_target_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
{ // ann_assign_subscript_attribute_target
|
|
expr_ty ann_assign_subscript_attribute_target_var;
|
|
if (
|
|
(ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p)) // ann_assign_subscript_attribute_target
|
|
)
|
|
{
|
|
res = ann_assign_subscript_attribute_target_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // NAME
|
|
expr_ty a;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = _PyPegen_set_expr_context ( p , a , Store );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '(' inside_paren_ann_assign_target ')'
|
|
expr_ty a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = inside_paren_ann_assign_target_rule(p)) // inside_paren_ann_assign_target
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// ann_assign_subscript_attribute_target:
|
|
// | t_primary '.' NAME !t_lookahead
|
|
// | t_primary '[' slices ']' !t_lookahead
|
|
static expr_ty
|
|
ann_assign_subscript_attribute_target_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // t_primary '.' NAME !t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
&&
|
|
(b = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
_PyPegen_lookahead(0, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_primary '[' slices ']' !t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(b = slices_rule(p)) // slices
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
&&
|
|
_PyPegen_lookahead(0, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Subscript ( a , b , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// del_targets: ','.del_target+ ','?
|
|
static asdl_seq*
|
|
del_targets_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.del_target+ ','?
|
|
asdl_seq * a;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = _gather_121_rule(p)) // ','.del_target+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// del_target:
|
|
// | t_primary '.' NAME !t_lookahead
|
|
// | t_primary '[' slices ']' !t_lookahead
|
|
// | del_t_atom
|
|
static expr_ty
|
|
del_target_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, del_target_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // t_primary '.' NAME !t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
&&
|
|
(b = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
_PyPegen_lookahead(0, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_primary '[' slices ']' !t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(b = slices_rule(p)) // slices
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
&&
|
|
_PyPegen_lookahead(0, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Subscript ( a , b , Del , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // del_t_atom
|
|
expr_ty del_t_atom_var;
|
|
if (
|
|
(del_t_atom_var = del_t_atom_rule(p)) // del_t_atom
|
|
)
|
|
{
|
|
res = del_t_atom_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, del_target_type, res);
|
|
return res;
|
|
}
|
|
|
|
// del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']'
|
|
static expr_ty
|
|
del_t_atom_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME
|
|
expr_ty a;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = _PyPegen_set_expr_context ( p , a , Del );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '(' del_target ')'
|
|
expr_ty a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = del_target_rule(p)) // del_target
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = _PyPegen_set_expr_context ( p , a , Del );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '(' del_targets? ')'
|
|
void *a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = del_targets_rule(p), 1) // del_targets?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( a , Del , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '[' del_targets? ']'
|
|
void *a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(a = del_targets_rule(p), 1) // del_targets?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_List ( a , Del , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// targets: ','.target+ ','?
|
|
static asdl_seq*
|
|
targets_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq* res = NULL;
|
|
int mark = p->mark;
|
|
{ // ','.target+ ','?
|
|
asdl_seq * a;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(a = _gather_123_rule(p)) // ','.target+
|
|
&&
|
|
(opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// target:
|
|
// | t_primary '.' NAME !t_lookahead
|
|
// | t_primary '[' slices ']' !t_lookahead
|
|
// | t_atom
|
|
static expr_ty
|
|
target_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, target_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // t_primary '.' NAME !t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
&&
|
|
(b = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
_PyPegen_lookahead(0, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_primary '[' slices ']' !t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(b = slices_rule(p)) // slices
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
&&
|
|
_PyPegen_lookahead(0, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Subscript ( a , b , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_atom
|
|
expr_ty t_atom_var;
|
|
if (
|
|
(t_atom_var = t_atom_rule(p)) // t_atom
|
|
)
|
|
{
|
|
res = t_atom_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
_PyPegen_insert_memo(p, mark, target_type, res);
|
|
return res;
|
|
}
|
|
|
|
// Left-recursive
|
|
// t_primary:
|
|
// | t_primary '.' NAME &t_lookahead
|
|
// | t_primary '[' slices ']' &t_lookahead
|
|
// | t_primary genexp &t_lookahead
|
|
// | t_primary '(' arguments? ')' &t_lookahead
|
|
// | atom &t_lookahead
|
|
static expr_ty t_primary_raw(Parser *);
|
|
static expr_ty
|
|
t_primary_rule(Parser *p)
|
|
{
|
|
expr_ty res = NULL;
|
|
if (_PyPegen_is_memoized(p, t_primary_type, &res))
|
|
return res;
|
|
int mark = p->mark;
|
|
int resmark = p->mark;
|
|
while (1) {
|
|
int tmpvar_8 = _PyPegen_update_memo(p, mark, t_primary_type, res);
|
|
if (tmpvar_8) {
|
|
return res;
|
|
}
|
|
p->mark = mark;
|
|
void *raw = t_primary_raw(p);
|
|
if (raw == NULL || p->mark <= resmark)
|
|
break;
|
|
resmark = p->mark;
|
|
res = raw;
|
|
}
|
|
p->mark = resmark;
|
|
return res;
|
|
}
|
|
static expr_ty
|
|
t_primary_raw(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // t_primary '.' NAME &t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
&&
|
|
(b = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
_PyPegen_lookahead(1, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_primary '[' slices ']' &t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(b = slices_rule(p)) // slices
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
&&
|
|
_PyPegen_lookahead(1, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Subscript ( a , b , Load , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_primary genexp &t_lookahead
|
|
expr_ty a;
|
|
expr_ty b;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(b = genexp_rule(p)) // genexp
|
|
&&
|
|
_PyPegen_lookahead(1, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // t_primary '(' arguments? ')' &t_lookahead
|
|
expr_ty a;
|
|
void *b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(a = t_primary_rule(p)) // t_primary
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(b = arguments_rule(p), 1) // arguments?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
&&
|
|
_PyPegen_lookahead(1, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // atom &t_lookahead
|
|
expr_ty a;
|
|
if (
|
|
(a = atom_rule(p)) // atom
|
|
&&
|
|
_PyPegen_lookahead(1, t_lookahead_rule, p)
|
|
)
|
|
{
|
|
res = a;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// t_lookahead: '(' | '[' | '.'
|
|
static void *
|
|
t_lookahead_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '('
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '['
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '.'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']'
|
|
static expr_ty
|
|
t_atom_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
expr_ty res = NULL;
|
|
int mark = p->mark;
|
|
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
int start_lineno = p->tokens[mark]->lineno;
|
|
UNUSED(start_lineno); // Only used by EXTRA macro
|
|
int start_col_offset = p->tokens[mark]->col_offset;
|
|
UNUSED(start_col_offset); // Only used by EXTRA macro
|
|
{ // NAME
|
|
expr_ty a;
|
|
if (
|
|
(a = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = _PyPegen_set_expr_context ( p , a , Store );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '(' target ')'
|
|
expr_ty a;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(a = target_rule(p)) // target
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = _PyPegen_set_expr_context ( p , a , Store );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '(' targets? ')'
|
|
void *b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(b = targets_rule(p), 1) // targets?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_Tuple ( b , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '[' targets? ']'
|
|
void *b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
&&
|
|
(b = targets_rule(p), 1) // targets?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
|
|
)
|
|
{
|
|
Token *token = _PyPegen_get_last_nonnwhitespace_token(p);
|
|
if (token == NULL) {
|
|
return NULL;
|
|
}
|
|
int end_lineno = token->end_lineno;
|
|
UNUSED(end_lineno); // Only used by EXTRA macro
|
|
int end_col_offset = token->end_col_offset;
|
|
UNUSED(end_col_offset); // Only used by EXTRA macro
|
|
res = _Py_List ( b , Store , EXTRA );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// incorrect_arguments:
|
|
// | args ',' '*'
|
|
// | expression for_if_clauses ',' [args | expression for_if_clauses]
|
|
// | args ',' args
|
|
static void *
|
|
incorrect_arguments_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // args ',' '*'
|
|
expr_ty args_var;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(args_var = args_rule(p)) // args
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression for_if_clauses ',' [args | expression for_if_clauses]
|
|
expr_ty expression_var;
|
|
asdl_seq* for_if_clauses_var;
|
|
Token * literal;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(expression_var = expression_rule(p)) // expression
|
|
&&
|
|
(for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses]
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "Generator expression must be parenthesized" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // args ',' args
|
|
expr_ty a;
|
|
expr_ty args_var;
|
|
Token * literal;
|
|
if (
|
|
(a = args_rule(p)) // args
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(args_var = args_rule(p)) // args
|
|
)
|
|
{
|
|
res = _PyPegen_arguments_parsing_error ( p , a );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_kwarg: expression '='
|
|
static void *
|
|
invalid_kwarg_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // expression '='
|
|
expr_ty expression_var;
|
|
Token * literal;
|
|
if (
|
|
(expression_var = expression_rule(p)) // expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "expression cannot contain assignment, perhaps you meant \"==\"?" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_named_expression: expression ':=' expression
|
|
static void *
|
|
invalid_named_expression_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // expression ':=' expression
|
|
expr_ty a;
|
|
expr_ty expression_var;
|
|
Token * literal;
|
|
if (
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 53)) // token=':='
|
|
&&
|
|
(expression_var = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_assignment:
|
|
// | list ':'
|
|
// | tuple ':'
|
|
// | expression ':' expression ['=' annotated_rhs]
|
|
// | expression ('=' | augassign) (yield_expr | star_expressions)
|
|
static void *
|
|
invalid_assignment_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // list ':'
|
|
expr_ty list_var;
|
|
Token * literal;
|
|
if (
|
|
(list_var = list_rule(p)) // list
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "only single target (not list) can be annotated" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // tuple ':'
|
|
Token * literal;
|
|
expr_ty tuple_var;
|
|
if (
|
|
(tuple_var = tuple_rule(p)) // tuple
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "only single target (not tuple) can be annotated" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression ':' expression ['=' annotated_rhs]
|
|
expr_ty expression_var;
|
|
expr_ty expression_var_1;
|
|
Token * literal;
|
|
void *opt_var;
|
|
UNUSED(opt_var); // Silence compiler warnings
|
|
if (
|
|
(expression_var = expression_rule(p)) // expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(expression_var_1 = expression_rule(p)) // expression
|
|
&&
|
|
(opt_var = _tmp_126_rule(p), 1) // ['=' annotated_rhs]
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "illegal target for annotation" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression ('=' | augassign) (yield_expr | star_expressions)
|
|
void *_tmp_127_var;
|
|
void *_tmp_128_var;
|
|
expr_ty a;
|
|
if (
|
|
(a = expression_rule(p)) // expression
|
|
&&
|
|
(_tmp_127_var = _tmp_127_rule(p)) // '=' | augassign
|
|
&&
|
|
(_tmp_128_var = _tmp_128_rule(p)) // yield_expr | star_expressions
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR_NO_COL_OFFSET ( "cannot assign to %s" , _PyPegen_get_expr_name ( a ) );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_block: NEWLINE !INDENT
|
|
static void *
|
|
invalid_block_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // NEWLINE !INDENT
|
|
Token * newline_var;
|
|
if (
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
&&
|
|
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT
|
|
)
|
|
{
|
|
res = RAISE_INDENTATION_ERROR ( "expected an indented block" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_comprehension: ('[' | '(' | '{') '*' expression for_if_clauses
|
|
static void *
|
|
invalid_comprehension_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ('[' | '(' | '{') '*' expression for_if_clauses
|
|
void *_tmp_129_var;
|
|
expr_ty expression_var;
|
|
asdl_seq* for_if_clauses_var;
|
|
Token * literal;
|
|
if (
|
|
(_tmp_129_var = _tmp_129_rule(p)) // '[' | '(' | '{'
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(expression_var = expression_rule(p)) // expression
|
|
&&
|
|
(for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "iterable unpacking cannot be used in comprehension" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_parameters:
|
|
// | param_no_default* (slash_with_default | param_with_default+) param_no_default
|
|
static void *
|
|
invalid_parameters_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // param_no_default* (slash_with_default | param_with_default+) param_no_default
|
|
asdl_seq * _loop0_130_var;
|
|
void *_tmp_131_var;
|
|
arg_ty param_no_default_var;
|
|
if (
|
|
(_loop0_130_var = _loop0_130_rule(p)) // param_no_default*
|
|
&&
|
|
(_tmp_131_var = _tmp_131_rule(p)) // slash_with_default | param_with_default+
|
|
&&
|
|
(param_no_default_var = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_star_etc: '*' (')' | ',' (')' | '**'))
|
|
static void *
|
|
invalid_star_etc_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '*' (')' | ',' (')' | '**'))
|
|
void *_tmp_132_var;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(_tmp_132_var = _tmp_132_rule(p)) // ')' | ',' (')' | '**')
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_lambda_star_etc: '*' (':' | ',' (':' | '**'))
|
|
static void *
|
|
invalid_lambda_star_etc_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '*' (':' | ',' (':' | '**'))
|
|
void *_tmp_133_var;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 16)) // token='*'
|
|
&&
|
|
(_tmp_133_var = _tmp_133_rule(p)) // ':' | ',' (':' | '**')
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
|
|
static void *
|
|
invalid_double_type_comments_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
|
|
Token * indent_var;
|
|
Token * newline_var;
|
|
Token * newline_var_1;
|
|
Token * type_comment_var;
|
|
Token * type_comment_var_1;
|
|
if (
|
|
(type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
|
|
&&
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
&&
|
|
(type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
|
|
&&
|
|
(newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
&&
|
|
(indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
|
|
)
|
|
{
|
|
res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_1: NEWLINE
|
|
static asdl_seq *
|
|
_loop0_1_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // NEWLINE
|
|
Token * newline_var;
|
|
while (
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
)
|
|
{
|
|
res = newline_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_1_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_2: NEWLINE
|
|
static asdl_seq *
|
|
_loop0_2_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // NEWLINE
|
|
Token * newline_var;
|
|
while (
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
)
|
|
{
|
|
res = newline_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_2_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_4: ',' expression
|
|
static asdl_seq *
|
|
_loop0_4_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' expression
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_4_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_3: expression _loop0_4
|
|
static asdl_seq *
|
|
_gather_3_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // expression _loop0_4
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = expression_rule(p)) // expression
|
|
&&
|
|
(seq = _loop0_4_rule(p)) // _loop0_4
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_6: ',' expression
|
|
static asdl_seq *
|
|
_loop0_6_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' expression
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_6_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_5: expression _loop0_6
|
|
static asdl_seq *
|
|
_gather_5_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // expression _loop0_6
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = expression_rule(p)) // expression
|
|
&&
|
|
(seq = _loop0_6_rule(p)) // _loop0_6
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_8: ',' expression
|
|
static asdl_seq *
|
|
_loop0_8_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' expression
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_8_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_7: expression _loop0_8
|
|
static asdl_seq *
|
|
_gather_7_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // expression _loop0_8
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = expression_rule(p)) // expression
|
|
&&
|
|
(seq = _loop0_8_rule(p)) // _loop0_8
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_10: ',' expression
|
|
static asdl_seq *
|
|
_loop0_10_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' expression
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_10_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_9: expression _loop0_10
|
|
static asdl_seq *
|
|
_gather_9_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // expression _loop0_10
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = expression_rule(p)) // expression
|
|
&&
|
|
(seq = _loop0_10_rule(p)) // _loop0_10
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop1_11: statement
|
|
static asdl_seq *
|
|
_loop1_11_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // statement
|
|
asdl_seq* statement_var;
|
|
while (
|
|
(statement_var = statement_rule(p)) // statement
|
|
)
|
|
{
|
|
res = statement_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_11_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_13: ';' small_stmt
|
|
static asdl_seq *
|
|
_loop0_13_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ';' small_stmt
|
|
stmt_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 13)) // token=';'
|
|
&&
|
|
(elem = small_stmt_rule(p)) // small_stmt
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_13_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_12: small_stmt _loop0_13
|
|
static asdl_seq *
|
|
_gather_12_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // small_stmt _loop0_13
|
|
stmt_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = small_stmt_rule(p)) // small_stmt
|
|
&&
|
|
(seq = _loop0_13_rule(p)) // _loop0_13
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_14: 'import' | 'from'
|
|
static void *
|
|
_tmp_14_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'import'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 513)) // token='import'
|
|
)
|
|
{
|
|
res = keyword;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // 'from'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 514)) // token='from'
|
|
)
|
|
{
|
|
res = keyword;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_15: 'def' | '@' | ASYNC
|
|
static void *
|
|
_tmp_15_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'def'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 522)) // token='def'
|
|
)
|
|
{
|
|
res = keyword;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '@'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 49)) // token='@'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ASYNC
|
|
Token * async_var;
|
|
if (
|
|
(async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
|
|
)
|
|
{
|
|
res = async_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_16: 'class' | '@'
|
|
static void *
|
|
_tmp_16_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'class'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 523)) // token='class'
|
|
)
|
|
{
|
|
res = keyword;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '@'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 49)) // token='@'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_17: 'with' | ASYNC
|
|
static void *
|
|
_tmp_17_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'with'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 519)) // token='with'
|
|
)
|
|
{
|
|
res = keyword;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ASYNC
|
|
Token * async_var;
|
|
if (
|
|
(async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
|
|
)
|
|
{
|
|
res = async_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_18: 'for' | ASYNC
|
|
static void *
|
|
_tmp_18_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'for'
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 517)) // token='for'
|
|
)
|
|
{
|
|
res = keyword;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ASYNC
|
|
Token * async_var;
|
|
if (
|
|
(async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
|
|
)
|
|
{
|
|
res = async_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_19: '=' annotated_rhs
|
|
static void *
|
|
_tmp_19_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '=' annotated_rhs
|
|
expr_ty d;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
&&
|
|
(d = annotated_rhs_rule(p)) // annotated_rhs
|
|
)
|
|
{
|
|
res = d;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target
|
|
static void *
|
|
_tmp_20_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '(' inside_paren_ann_assign_target ')'
|
|
expr_ty b;
|
|
Token * literal;
|
|
Token * literal_1;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(b = inside_paren_ann_assign_target_rule(p)) // inside_paren_ann_assign_target
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = b;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ann_assign_subscript_attribute_target
|
|
expr_ty ann_assign_subscript_attribute_target_var;
|
|
if (
|
|
(ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p)) // ann_assign_subscript_attribute_target
|
|
)
|
|
{
|
|
res = ann_assign_subscript_attribute_target_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_21: '=' annotated_rhs
|
|
static void *
|
|
_tmp_21_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '=' annotated_rhs
|
|
expr_ty d;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
&&
|
|
(d = annotated_rhs_rule(p)) // annotated_rhs
|
|
)
|
|
{
|
|
res = d;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop1_22: (star_targets '=')
|
|
static asdl_seq *
|
|
_loop1_22_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // (star_targets '=')
|
|
void *_tmp_134_var;
|
|
while (
|
|
(_tmp_134_var = _tmp_134_rule(p)) // star_targets '='
|
|
)
|
|
{
|
|
res = _tmp_134_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_22_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _tmp_23: yield_expr | star_expressions
|
|
static void *
|
|
_tmp_23_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // yield_expr
|
|
expr_ty yield_expr_var;
|
|
if (
|
|
(yield_expr_var = yield_expr_rule(p)) // yield_expr
|
|
)
|
|
{
|
|
res = yield_expr_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_expressions
|
|
expr_ty star_expressions_var;
|
|
if (
|
|
(star_expressions_var = star_expressions_rule(p)) // star_expressions
|
|
)
|
|
{
|
|
res = star_expressions_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_24: yield_expr | star_expressions
|
|
static void *
|
|
_tmp_24_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // yield_expr
|
|
expr_ty yield_expr_var;
|
|
if (
|
|
(yield_expr_var = yield_expr_rule(p)) // yield_expr
|
|
)
|
|
{
|
|
res = yield_expr_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_expressions
|
|
expr_ty star_expressions_var;
|
|
if (
|
|
(star_expressions_var = star_expressions_rule(p)) // star_expressions
|
|
)
|
|
{
|
|
res = star_expressions_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_26: ',' NAME
|
|
static asdl_seq *
|
|
_loop0_26_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' NAME
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_26_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_25: NAME _loop0_26
|
|
static asdl_seq *
|
|
_gather_25_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // NAME _loop0_26
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(seq = _loop0_26_rule(p)) // _loop0_26
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_28: ',' NAME
|
|
static asdl_seq *
|
|
_loop0_28_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' NAME
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_28_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_27: NAME _loop0_28
|
|
static asdl_seq *
|
|
_gather_27_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // NAME _loop0_28
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = _PyPegen_name_token(p)) // NAME
|
|
&&
|
|
(seq = _loop0_28_rule(p)) // _loop0_28
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_29: ',' expression
|
|
static void *
|
|
_tmp_29_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ',' expression
|
|
Token * literal;
|
|
expr_ty z;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(z = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_30: ('.' | '...')
|
|
static asdl_seq *
|
|
_loop0_30_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ('.' | '...')
|
|
void *_tmp_135_var;
|
|
while (
|
|
(_tmp_135_var = _tmp_135_rule(p)) // '.' | '...'
|
|
)
|
|
{
|
|
res = _tmp_135_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_30_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_31: ('.' | '...')
|
|
static asdl_seq *
|
|
_loop1_31_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ('.' | '...')
|
|
void *_tmp_136_var;
|
|
while (
|
|
(_tmp_136_var = _tmp_136_rule(p)) // '.' | '...'
|
|
)
|
|
{
|
|
res = _tmp_136_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_31_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_33: ',' import_from_as_name
|
|
static asdl_seq *
|
|
_loop0_33_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' import_from_as_name
|
|
alias_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = import_from_as_name_rule(p)) // import_from_as_name
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_33_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_32: import_from_as_name _loop0_33
|
|
static asdl_seq *
|
|
_gather_32_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // import_from_as_name _loop0_33
|
|
alias_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = import_from_as_name_rule(p)) // import_from_as_name
|
|
&&
|
|
(seq = _loop0_33_rule(p)) // _loop0_33
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_34: 'as' NAME
|
|
static void *
|
|
_tmp_34_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'as' NAME
|
|
Token * keyword;
|
|
expr_ty z;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 531)) // token='as'
|
|
&&
|
|
(z = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_36: ',' dotted_as_name
|
|
static asdl_seq *
|
|
_loop0_36_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' dotted_as_name
|
|
alias_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = dotted_as_name_rule(p)) // dotted_as_name
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_36_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_35: dotted_as_name _loop0_36
|
|
static asdl_seq *
|
|
_gather_35_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // dotted_as_name _loop0_36
|
|
alias_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = dotted_as_name_rule(p)) // dotted_as_name
|
|
&&
|
|
(seq = _loop0_36_rule(p)) // _loop0_36
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_37: 'as' NAME
|
|
static void *
|
|
_tmp_37_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'as' NAME
|
|
Token * keyword;
|
|
expr_ty z;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 531)) // token='as'
|
|
&&
|
|
(z = _PyPegen_name_token(p)) // NAME
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_39: ',' with_item
|
|
static asdl_seq *
|
|
_loop0_39_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' with_item
|
|
withitem_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = with_item_rule(p)) // with_item
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_39_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_38: with_item _loop0_39
|
|
static asdl_seq *
|
|
_gather_38_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // with_item _loop0_39
|
|
withitem_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = with_item_rule(p)) // with_item
|
|
&&
|
|
(seq = _loop0_39_rule(p)) // _loop0_39
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_41: ',' with_item
|
|
static asdl_seq *
|
|
_loop0_41_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' with_item
|
|
withitem_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = with_item_rule(p)) // with_item
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_41_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_40: with_item _loop0_41
|
|
static asdl_seq *
|
|
_gather_40_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // with_item _loop0_41
|
|
withitem_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = with_item_rule(p)) // with_item
|
|
&&
|
|
(seq = _loop0_41_rule(p)) // _loop0_41
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_43: ',' with_item
|
|
static asdl_seq *
|
|
_loop0_43_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' with_item
|
|
withitem_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = with_item_rule(p)) // with_item
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_43_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_42: with_item _loop0_43
|
|
static asdl_seq *
|
|
_gather_42_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // with_item _loop0_43
|
|
withitem_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = with_item_rule(p)) // with_item
|
|
&&
|
|
(seq = _loop0_43_rule(p)) // _loop0_43
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_45: ',' with_item
|
|
static asdl_seq *
|
|
_loop0_45_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' with_item
|
|
withitem_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = with_item_rule(p)) // with_item
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_45_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_44: with_item _loop0_45
|
|
static asdl_seq *
|
|
_gather_44_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // with_item _loop0_45
|
|
withitem_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = with_item_rule(p)) // with_item
|
|
&&
|
|
(seq = _loop0_45_rule(p)) // _loop0_45
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_46: 'as' target
|
|
static void *
|
|
_tmp_46_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'as' target
|
|
Token * keyword;
|
|
expr_ty t;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 531)) // token='as'
|
|
&&
|
|
(t = target_rule(p)) // target
|
|
)
|
|
{
|
|
res = t;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop1_47: except_block
|
|
static asdl_seq *
|
|
_loop1_47_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // except_block
|
|
excepthandler_ty except_block_var;
|
|
while (
|
|
(except_block_var = except_block_rule(p)) // except_block
|
|
)
|
|
{
|
|
res = except_block_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_47_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _tmp_48: 'as' target
|
|
static void *
|
|
_tmp_48_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'as' target
|
|
Token * keyword;
|
|
expr_ty z;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 531)) // token='as'
|
|
&&
|
|
(z = target_rule(p)) // target
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_49: 'from' expression
|
|
static void *
|
|
_tmp_49_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'from' expression
|
|
Token * keyword;
|
|
expr_ty z;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 514)) // token='from'
|
|
&&
|
|
(z = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_50: '->' expression
|
|
static void *
|
|
_tmp_50_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '->' expression
|
|
Token * literal;
|
|
expr_ty z;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 51)) // token='->'
|
|
&&
|
|
(z = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_51: '->' expression
|
|
static void *
|
|
_tmp_51_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '->' expression
|
|
Token * literal;
|
|
expr_ty z;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 51)) // token='->'
|
|
&&
|
|
(z = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_52: NEWLINE INDENT
|
|
static void *
|
|
_tmp_52_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // NEWLINE INDENT
|
|
Token * indent_var;
|
|
Token * newline_var;
|
|
if (
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
&&
|
|
(indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
|
|
)
|
|
{
|
|
res = _PyPegen_dummy_name(p, newline_var, indent_var);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_53: param_no_default
|
|
static asdl_seq *
|
|
_loop0_53_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_no_default
|
|
arg_ty param_no_default_var;
|
|
while (
|
|
(param_no_default_var = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_53_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_54: param_with_default
|
|
static asdl_seq *
|
|
_loop0_54_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_with_default
|
|
NameDefaultPair* param_with_default_var;
|
|
while (
|
|
(param_with_default_var = param_with_default_rule(p)) // param_with_default
|
|
)
|
|
{
|
|
res = param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_54_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_55: param_with_default
|
|
static asdl_seq *
|
|
_loop0_55_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_with_default
|
|
NameDefaultPair* param_with_default_var;
|
|
while (
|
|
(param_with_default_var = param_with_default_rule(p)) // param_with_default
|
|
)
|
|
{
|
|
res = param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_55_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_56: param_no_default
|
|
static asdl_seq *
|
|
_loop1_56_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_no_default
|
|
arg_ty param_no_default_var;
|
|
while (
|
|
(param_no_default_var = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_56_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_57: param_with_default
|
|
static asdl_seq *
|
|
_loop0_57_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_with_default
|
|
NameDefaultPair* param_with_default_var;
|
|
while (
|
|
(param_with_default_var = param_with_default_rule(p)) // param_with_default
|
|
)
|
|
{
|
|
res = param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_57_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_58: param_with_default
|
|
static asdl_seq *
|
|
_loop1_58_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_with_default
|
|
NameDefaultPair* param_with_default_var;
|
|
while (
|
|
(param_with_default_var = param_with_default_rule(p)) // param_with_default
|
|
)
|
|
{
|
|
res = param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_58_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_59: param_no_default
|
|
static asdl_seq *
|
|
_loop1_59_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_no_default
|
|
arg_ty param_no_default_var;
|
|
while (
|
|
(param_no_default_var = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_59_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_60: param_no_default
|
|
static asdl_seq *
|
|
_loop1_60_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_no_default
|
|
arg_ty param_no_default_var;
|
|
while (
|
|
(param_no_default_var = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_60_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_61: param_no_default
|
|
static asdl_seq *
|
|
_loop0_61_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_no_default
|
|
arg_ty param_no_default_var;
|
|
while (
|
|
(param_no_default_var = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_61_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_62: param_with_default
|
|
static asdl_seq *
|
|
_loop1_62_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_with_default
|
|
NameDefaultPair* param_with_default_var;
|
|
while (
|
|
(param_with_default_var = param_with_default_rule(p)) // param_with_default
|
|
)
|
|
{
|
|
res = param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_62_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_63: param_no_default
|
|
static asdl_seq *
|
|
_loop0_63_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_no_default
|
|
arg_ty param_no_default_var;
|
|
while (
|
|
(param_no_default_var = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_63_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_64: param_with_default
|
|
static asdl_seq *
|
|
_loop1_64_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_with_default
|
|
NameDefaultPair* param_with_default_var;
|
|
while (
|
|
(param_with_default_var = param_with_default_rule(p)) // param_with_default
|
|
)
|
|
{
|
|
res = param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_64_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_65: param_maybe_default
|
|
static asdl_seq *
|
|
_loop0_65_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_maybe_default
|
|
NameDefaultPair* param_maybe_default_var;
|
|
while (
|
|
(param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
|
|
)
|
|
{
|
|
res = param_maybe_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_65_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_66: param_maybe_default
|
|
static asdl_seq *
|
|
_loop1_66_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_maybe_default
|
|
NameDefaultPair* param_maybe_default_var;
|
|
while (
|
|
(param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
|
|
)
|
|
{
|
|
res = param_maybe_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_66_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_67: ('@' named_expression NEWLINE)
|
|
static asdl_seq *
|
|
_loop1_67_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ('@' named_expression NEWLINE)
|
|
void *_tmp_137_var;
|
|
while (
|
|
(_tmp_137_var = _tmp_137_rule(p)) // '@' named_expression NEWLINE
|
|
)
|
|
{
|
|
res = _tmp_137_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_67_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _tmp_68: '(' arguments? ')'
|
|
static void *
|
|
_tmp_68_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '(' arguments? ')'
|
|
Token * literal;
|
|
Token * literal_1;
|
|
void *z;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
&&
|
|
(z = arguments_rule(p), 1) // arguments?
|
|
&&
|
|
(literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_70: ',' star_expression
|
|
static asdl_seq *
|
|
_loop0_70_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' star_expression
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = star_expression_rule(p)) // star_expression
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_70_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_69: star_expression _loop0_70
|
|
static asdl_seq *
|
|
_gather_69_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // star_expression _loop0_70
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = star_expression_rule(p)) // star_expression
|
|
&&
|
|
(seq = _loop0_70_rule(p)) // _loop0_70
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop1_71: (',' star_expression)
|
|
static asdl_seq *
|
|
_loop1_71_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // (',' star_expression)
|
|
void *_tmp_138_var;
|
|
while (
|
|
(_tmp_138_var = _tmp_138_rule(p)) // ',' star_expression
|
|
)
|
|
{
|
|
res = _tmp_138_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_71_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_73: ',' star_named_expression
|
|
static asdl_seq *
|
|
_loop0_73_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' star_named_expression
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = star_named_expression_rule(p)) // star_named_expression
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_73_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_72: star_named_expression _loop0_73
|
|
static asdl_seq *
|
|
_gather_72_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // star_named_expression _loop0_73
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = star_named_expression_rule(p)) // star_named_expression
|
|
&&
|
|
(seq = _loop0_73_rule(p)) // _loop0_73
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop1_74: (',' expression)
|
|
static asdl_seq *
|
|
_loop1_74_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // (',' expression)
|
|
void *_tmp_139_var;
|
|
while (
|
|
(_tmp_139_var = _tmp_139_rule(p)) // ',' expression
|
|
)
|
|
{
|
|
res = _tmp_139_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_74_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_75: lambda_param_no_default
|
|
static asdl_seq *
|
|
_loop0_75_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_no_default
|
|
arg_ty lambda_param_no_default_var;
|
|
while (
|
|
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
|
|
)
|
|
{
|
|
res = lambda_param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_75_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_76: lambda_param_with_default
|
|
static asdl_seq *
|
|
_loop0_76_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_with_default
|
|
NameDefaultPair* lambda_param_with_default_var;
|
|
while (
|
|
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
|
|
)
|
|
{
|
|
res = lambda_param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_76_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_77: lambda_param_with_default
|
|
static asdl_seq *
|
|
_loop0_77_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_with_default
|
|
NameDefaultPair* lambda_param_with_default_var;
|
|
while (
|
|
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
|
|
)
|
|
{
|
|
res = lambda_param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_77_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_78: lambda_param_no_default
|
|
static asdl_seq *
|
|
_loop1_78_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_no_default
|
|
arg_ty lambda_param_no_default_var;
|
|
while (
|
|
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
|
|
)
|
|
{
|
|
res = lambda_param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_78_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_79: lambda_param_with_default
|
|
static asdl_seq *
|
|
_loop0_79_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_with_default
|
|
NameDefaultPair* lambda_param_with_default_var;
|
|
while (
|
|
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
|
|
)
|
|
{
|
|
res = lambda_param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_79_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_80: lambda_param_with_default
|
|
static asdl_seq *
|
|
_loop1_80_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_with_default
|
|
NameDefaultPair* lambda_param_with_default_var;
|
|
while (
|
|
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
|
|
)
|
|
{
|
|
res = lambda_param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_80_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_81: lambda_param_no_default
|
|
static asdl_seq *
|
|
_loop1_81_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_no_default
|
|
arg_ty lambda_param_no_default_var;
|
|
while (
|
|
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
|
|
)
|
|
{
|
|
res = lambda_param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_81_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_82: lambda_param_no_default
|
|
static asdl_seq *
|
|
_loop1_82_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_no_default
|
|
arg_ty lambda_param_no_default_var;
|
|
while (
|
|
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
|
|
)
|
|
{
|
|
res = lambda_param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_82_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_83: lambda_param_no_default
|
|
static asdl_seq *
|
|
_loop0_83_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_no_default
|
|
arg_ty lambda_param_no_default_var;
|
|
while (
|
|
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
|
|
)
|
|
{
|
|
res = lambda_param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_83_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_84: lambda_param_with_default
|
|
static asdl_seq *
|
|
_loop1_84_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_with_default
|
|
NameDefaultPair* lambda_param_with_default_var;
|
|
while (
|
|
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
|
|
)
|
|
{
|
|
res = lambda_param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_84_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_85: lambda_param_no_default
|
|
static asdl_seq *
|
|
_loop0_85_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_no_default
|
|
arg_ty lambda_param_no_default_var;
|
|
while (
|
|
(lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
|
|
)
|
|
{
|
|
res = lambda_param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_85_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_86: lambda_param_with_default
|
|
static asdl_seq *
|
|
_loop1_86_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_with_default
|
|
NameDefaultPair* lambda_param_with_default_var;
|
|
while (
|
|
(lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
|
|
)
|
|
{
|
|
res = lambda_param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_86_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_87: lambda_param_maybe_default
|
|
static asdl_seq *
|
|
_loop0_87_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_maybe_default
|
|
NameDefaultPair* lambda_param_maybe_default_var;
|
|
while (
|
|
(lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
|
|
)
|
|
{
|
|
res = lambda_param_maybe_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_87_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_88: lambda_param_maybe_default
|
|
static asdl_seq *
|
|
_loop1_88_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // lambda_param_maybe_default
|
|
NameDefaultPair* lambda_param_maybe_default_var;
|
|
while (
|
|
(lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
|
|
)
|
|
{
|
|
res = lambda_param_maybe_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_88_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_89: ('or' conjunction)
|
|
static asdl_seq *
|
|
_loop1_89_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ('or' conjunction)
|
|
void *_tmp_140_var;
|
|
while (
|
|
(_tmp_140_var = _tmp_140_rule(p)) // 'or' conjunction
|
|
)
|
|
{
|
|
res = _tmp_140_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_89_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_90: ('and' inversion)
|
|
static asdl_seq *
|
|
_loop1_90_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ('and' inversion)
|
|
void *_tmp_141_var;
|
|
while (
|
|
(_tmp_141_var = _tmp_141_rule(p)) // 'and' inversion
|
|
)
|
|
{
|
|
res = _tmp_141_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_90_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop1_91: compare_op_bitwise_or_pair
|
|
static asdl_seq *
|
|
_loop1_91_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // compare_op_bitwise_or_pair
|
|
CmpopExprPair* compare_op_bitwise_or_pair_var;
|
|
while (
|
|
(compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair
|
|
)
|
|
{
|
|
res = compare_op_bitwise_or_pair_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_91_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _tmp_92: '!='
|
|
static void *
|
|
_tmp_92_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '!='
|
|
Token * tok;
|
|
if (
|
|
(tok = _PyPegen_expect_token(p, 28)) // token='!='
|
|
)
|
|
{
|
|
res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_94: ',' slice
|
|
static asdl_seq *
|
|
_loop0_94_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' slice
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = slice_rule(p)) // slice
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_94_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_93: slice _loop0_94
|
|
static asdl_seq *
|
|
_gather_93_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // slice _loop0_94
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = slice_rule(p)) // slice
|
|
&&
|
|
(seq = _loop0_94_rule(p)) // _loop0_94
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_95: ':' expression?
|
|
static void *
|
|
_tmp_95_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ':' expression?
|
|
void *d;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
&&
|
|
(d = expression_rule(p), 1) // expression?
|
|
)
|
|
{
|
|
res = d;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_96: tuple | group | genexp
|
|
static void *
|
|
_tmp_96_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // tuple
|
|
expr_ty tuple_var;
|
|
if (
|
|
(tuple_var = tuple_rule(p)) // tuple
|
|
)
|
|
{
|
|
res = tuple_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // group
|
|
expr_ty group_var;
|
|
if (
|
|
(group_var = group_rule(p)) // group
|
|
)
|
|
{
|
|
res = group_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // genexp
|
|
expr_ty genexp_var;
|
|
if (
|
|
(genexp_var = genexp_rule(p)) // genexp
|
|
)
|
|
{
|
|
res = genexp_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_97: list | listcomp
|
|
static void *
|
|
_tmp_97_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // list
|
|
expr_ty list_var;
|
|
if (
|
|
(list_var = list_rule(p)) // list
|
|
)
|
|
{
|
|
res = list_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // listcomp
|
|
expr_ty listcomp_var;
|
|
if (
|
|
(listcomp_var = listcomp_rule(p)) // listcomp
|
|
)
|
|
{
|
|
res = listcomp_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_98: dict | set | dictcomp | setcomp
|
|
static void *
|
|
_tmp_98_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // dict
|
|
expr_ty dict_var;
|
|
if (
|
|
(dict_var = dict_rule(p)) // dict
|
|
)
|
|
{
|
|
res = dict_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // set
|
|
expr_ty set_var;
|
|
if (
|
|
(set_var = set_rule(p)) // set
|
|
)
|
|
{
|
|
res = set_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // dictcomp
|
|
expr_ty dictcomp_var;
|
|
if (
|
|
(dictcomp_var = dictcomp_rule(p)) // dictcomp
|
|
)
|
|
{
|
|
res = dictcomp_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // setcomp
|
|
expr_ty setcomp_var;
|
|
if (
|
|
(setcomp_var = setcomp_rule(p)) // setcomp
|
|
)
|
|
{
|
|
res = setcomp_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop1_99: STRING
|
|
static asdl_seq *
|
|
_loop1_99_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // STRING
|
|
expr_ty string_var;
|
|
while (
|
|
(string_var = _PyPegen_string_token(p)) // STRING
|
|
)
|
|
{
|
|
res = string_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_99_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _tmp_100: star_named_expression ',' star_named_expressions?
|
|
static void *
|
|
_tmp_100_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // star_named_expression ',' star_named_expressions?
|
|
Token * literal;
|
|
expr_ty y;
|
|
void *z;
|
|
if (
|
|
(y = star_named_expression_rule(p)) // star_named_expression
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(z = star_named_expressions_rule(p), 1) // star_named_expressions?
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front ( p , y , z );
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_101: yield_expr | named_expression
|
|
static void *
|
|
_tmp_101_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // yield_expr
|
|
expr_ty yield_expr_var;
|
|
if (
|
|
(yield_expr_var = yield_expr_rule(p)) // yield_expr
|
|
)
|
|
{
|
|
res = yield_expr_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // named_expression
|
|
expr_ty named_expression_var;
|
|
if (
|
|
(named_expression_var = named_expression_rule(p)) // named_expression
|
|
)
|
|
{
|
|
res = named_expression_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_103: ',' kvpair
|
|
static asdl_seq *
|
|
_loop0_103_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' kvpair
|
|
KeyValuePair* elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = kvpair_rule(p)) // kvpair
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_103_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_102: kvpair _loop0_103
|
|
static asdl_seq *
|
|
_gather_102_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // kvpair _loop0_103
|
|
KeyValuePair* elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = kvpair_rule(p)) // kvpair
|
|
&&
|
|
(seq = _loop0_103_rule(p)) // _loop0_103
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop1_104: for_if_clause
|
|
static asdl_seq *
|
|
_loop1_104_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // for_if_clause
|
|
comprehension_ty for_if_clause_var;
|
|
while (
|
|
(for_if_clause_var = for_if_clause_rule(p)) // for_if_clause
|
|
)
|
|
{
|
|
res = for_if_clause_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_104_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_105: ('if' disjunction)
|
|
static asdl_seq *
|
|
_loop0_105_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ('if' disjunction)
|
|
void *_tmp_142_var;
|
|
while (
|
|
(_tmp_142_var = _tmp_142_rule(p)) // 'if' disjunction
|
|
)
|
|
{
|
|
res = _tmp_142_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_105_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_106: ('if' disjunction)
|
|
static asdl_seq *
|
|
_loop0_106_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ('if' disjunction)
|
|
void *_tmp_143_var;
|
|
while (
|
|
(_tmp_143_var = _tmp_143_rule(p)) // 'if' disjunction
|
|
)
|
|
{
|
|
res = _tmp_143_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_106_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _tmp_107: ',' args
|
|
static void *
|
|
_tmp_107_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ',' args
|
|
expr_ty c;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(c = args_rule(p)) // args
|
|
)
|
|
{
|
|
res = c;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_108: ',' args
|
|
static void *
|
|
_tmp_108_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ',' args
|
|
expr_ty c;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(c = args_rule(p)) // args
|
|
)
|
|
{
|
|
res = c;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_110: ',' kwarg_or_starred
|
|
static asdl_seq *
|
|
_loop0_110_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' kwarg_or_starred
|
|
KeywordOrStarred* elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_110_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_109: kwarg_or_starred _loop0_110
|
|
static asdl_seq *
|
|
_gather_109_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // kwarg_or_starred _loop0_110
|
|
KeywordOrStarred* elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
|
|
&&
|
|
(seq = _loop0_110_rule(p)) // _loop0_110
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_112: ',' kwarg_or_double_starred
|
|
static asdl_seq *
|
|
_loop0_112_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' kwarg_or_double_starred
|
|
KeywordOrStarred* elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_112_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_111: kwarg_or_double_starred _loop0_112
|
|
static asdl_seq *
|
|
_gather_111_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // kwarg_or_double_starred _loop0_112
|
|
KeywordOrStarred* elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
|
|
&&
|
|
(seq = _loop0_112_rule(p)) // _loop0_112
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_114: ',' kwarg_or_starred
|
|
static asdl_seq *
|
|
_loop0_114_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' kwarg_or_starred
|
|
KeywordOrStarred* elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_114_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_113: kwarg_or_starred _loop0_114
|
|
static asdl_seq *
|
|
_gather_113_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // kwarg_or_starred _loop0_114
|
|
KeywordOrStarred* elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
|
|
&&
|
|
(seq = _loop0_114_rule(p)) // _loop0_114
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_116: ',' kwarg_or_double_starred
|
|
static asdl_seq *
|
|
_loop0_116_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' kwarg_or_double_starred
|
|
KeywordOrStarred* elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_116_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_115: kwarg_or_double_starred _loop0_116
|
|
static asdl_seq *
|
|
_gather_115_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // kwarg_or_double_starred _loop0_116
|
|
KeywordOrStarred* elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
|
|
&&
|
|
(seq = _loop0_116_rule(p)) // _loop0_116
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_117: (',' star_target)
|
|
static asdl_seq *
|
|
_loop0_117_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // (',' star_target)
|
|
void *_tmp_144_var;
|
|
while (
|
|
(_tmp_144_var = _tmp_144_rule(p)) // ',' star_target
|
|
)
|
|
{
|
|
res = _tmp_144_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_117_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _loop0_119: ',' star_target
|
|
static asdl_seq *
|
|
_loop0_119_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' star_target
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = star_target_rule(p)) // star_target
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_119_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_118: star_target _loop0_119
|
|
static asdl_seq *
|
|
_gather_118_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // star_target _loop0_119
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = star_target_rule(p)) // star_target
|
|
&&
|
|
(seq = _loop0_119_rule(p)) // _loop0_119
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_120: !'*' star_target
|
|
static void *
|
|
_tmp_120_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // !'*' star_target
|
|
expr_ty star_target_var;
|
|
if (
|
|
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*'
|
|
&&
|
|
(star_target_var = star_target_rule(p)) // star_target
|
|
)
|
|
{
|
|
res = star_target_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_122: ',' del_target
|
|
static asdl_seq *
|
|
_loop0_122_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' del_target
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = del_target_rule(p)) // del_target
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_122_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_121: del_target _loop0_122
|
|
static asdl_seq *
|
|
_gather_121_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // del_target _loop0_122
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = del_target_rule(p)) // del_target
|
|
&&
|
|
(seq = _loop0_122_rule(p)) // _loop0_122
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_124: ',' target
|
|
static asdl_seq *
|
|
_loop0_124_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // ',' target
|
|
expr_ty elem;
|
|
Token * literal;
|
|
while (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(elem = target_rule(p)) // target
|
|
)
|
|
{
|
|
res = elem;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_124_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _gather_123: target _loop0_124
|
|
static asdl_seq *
|
|
_gather_123_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
asdl_seq * res = NULL;
|
|
int mark = p->mark;
|
|
{ // target _loop0_124
|
|
expr_ty elem;
|
|
asdl_seq * seq;
|
|
if (
|
|
(elem = target_rule(p)) // target
|
|
&&
|
|
(seq = _loop0_124_rule(p)) // _loop0_124
|
|
)
|
|
{
|
|
res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_125: args | expression for_if_clauses
|
|
static void *
|
|
_tmp_125_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // args
|
|
expr_ty args_var;
|
|
if (
|
|
(args_var = args_rule(p)) // args
|
|
)
|
|
{
|
|
res = args_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // expression for_if_clauses
|
|
expr_ty expression_var;
|
|
asdl_seq* for_if_clauses_var;
|
|
if (
|
|
(expression_var = expression_rule(p)) // expression
|
|
&&
|
|
(for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
|
|
)
|
|
{
|
|
res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_126: '=' annotated_rhs
|
|
static void *
|
|
_tmp_126_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '=' annotated_rhs
|
|
expr_ty annotated_rhs_var;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
&&
|
|
(annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs
|
|
)
|
|
{
|
|
res = _PyPegen_dummy_name(p, literal, annotated_rhs_var);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_127: '=' | augassign
|
|
static void *
|
|
_tmp_127_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '='
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // augassign
|
|
AugOperator* augassign_var;
|
|
if (
|
|
(augassign_var = augassign_rule(p)) // augassign
|
|
)
|
|
{
|
|
res = augassign_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_128: yield_expr | star_expressions
|
|
static void *
|
|
_tmp_128_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // yield_expr
|
|
expr_ty yield_expr_var;
|
|
if (
|
|
(yield_expr_var = yield_expr_rule(p)) // yield_expr
|
|
)
|
|
{
|
|
res = yield_expr_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // star_expressions
|
|
expr_ty star_expressions_var;
|
|
if (
|
|
(star_expressions_var = star_expressions_rule(p)) // star_expressions
|
|
)
|
|
{
|
|
res = star_expressions_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_129: '[' | '(' | '{'
|
|
static void *
|
|
_tmp_129_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '['
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 9)) // token='['
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '('
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 7)) // token='('
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '{'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 25)) // token='{'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop0_130: param_no_default
|
|
static asdl_seq *
|
|
_loop0_130_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_no_default
|
|
arg_ty param_no_default_var;
|
|
while (
|
|
(param_no_default_var = param_no_default_rule(p)) // param_no_default
|
|
)
|
|
{
|
|
res = param_no_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_130");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop0_130_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _tmp_131: slash_with_default | param_with_default+
|
|
static void *
|
|
_tmp_131_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // slash_with_default
|
|
SlashWithDefault* slash_with_default_var;
|
|
if (
|
|
(slash_with_default_var = slash_with_default_rule(p)) // slash_with_default
|
|
)
|
|
{
|
|
res = slash_with_default_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // param_with_default+
|
|
asdl_seq * _loop1_145_var;
|
|
if (
|
|
(_loop1_145_var = _loop1_145_rule(p)) // param_with_default+
|
|
)
|
|
{
|
|
res = _loop1_145_var;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_132: ')' | ',' (')' | '**')
|
|
static void *
|
|
_tmp_132_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ')'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ',' (')' | '**')
|
|
void *_tmp_146_var;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(_tmp_146_var = _tmp_146_rule(p)) // ')' | '**'
|
|
)
|
|
{
|
|
res = _PyPegen_dummy_name(p, literal, _tmp_146_var);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_133: ':' | ',' (':' | '**')
|
|
static void *
|
|
_tmp_133_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ':'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // ',' (':' | '**')
|
|
void *_tmp_147_var;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(_tmp_147_var = _tmp_147_rule(p)) // ':' | '**'
|
|
)
|
|
{
|
|
res = _PyPegen_dummy_name(p, literal, _tmp_147_var);
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_134: star_targets '='
|
|
static void *
|
|
_tmp_134_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // star_targets '='
|
|
Token * literal;
|
|
expr_ty z;
|
|
if (
|
|
(z = star_targets_rule(p)) // star_targets
|
|
&&
|
|
(literal = _PyPegen_expect_token(p, 22)) // token='='
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_135: '.' | '...'
|
|
static void *
|
|
_tmp_135_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '.'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '...'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 52)) // token='...'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_136: '.' | '...'
|
|
static void *
|
|
_tmp_136_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '.'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 23)) // token='.'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '...'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 52)) // token='...'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_137: '@' named_expression NEWLINE
|
|
static void *
|
|
_tmp_137_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // '@' named_expression NEWLINE
|
|
expr_ty f;
|
|
Token * literal;
|
|
Token * newline_var;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 49)) // token='@'
|
|
&&
|
|
(f = named_expression_rule(p)) // named_expression
|
|
&&
|
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
|
)
|
|
{
|
|
res = f;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_138: ',' star_expression
|
|
static void *
|
|
_tmp_138_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ',' star_expression
|
|
expr_ty c;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(c = star_expression_rule(p)) // star_expression
|
|
)
|
|
{
|
|
res = c;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_139: ',' expression
|
|
static void *
|
|
_tmp_139_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ',' expression
|
|
expr_ty c;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(c = expression_rule(p)) // expression
|
|
)
|
|
{
|
|
res = c;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_140: 'or' conjunction
|
|
static void *
|
|
_tmp_140_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'or' conjunction
|
|
expr_ty c;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 532)) // token='or'
|
|
&&
|
|
(c = conjunction_rule(p)) // conjunction
|
|
)
|
|
{
|
|
res = c;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_141: 'and' inversion
|
|
static void *
|
|
_tmp_141_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'and' inversion
|
|
expr_ty c;
|
|
Token * keyword;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 533)) // token='and'
|
|
&&
|
|
(c = inversion_rule(p)) // inversion
|
|
)
|
|
{
|
|
res = c;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_142: 'if' disjunction
|
|
static void *
|
|
_tmp_142_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'if' disjunction
|
|
Token * keyword;
|
|
expr_ty z;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 510)) // token='if'
|
|
&&
|
|
(z = disjunction_rule(p)) // disjunction
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_143: 'if' disjunction
|
|
static void *
|
|
_tmp_143_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // 'if' disjunction
|
|
Token * keyword;
|
|
expr_ty z;
|
|
if (
|
|
(keyword = _PyPegen_expect_token(p, 510)) // token='if'
|
|
&&
|
|
(z = disjunction_rule(p)) // disjunction
|
|
)
|
|
{
|
|
res = z;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_144: ',' star_target
|
|
static void *
|
|
_tmp_144_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ',' star_target
|
|
expr_ty c;
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 12)) // token=','
|
|
&&
|
|
(c = star_target_rule(p)) // star_target
|
|
)
|
|
{
|
|
res = c;
|
|
if (res == NULL && PyErr_Occurred()) {
|
|
p->error_indicator = 1;
|
|
return NULL;
|
|
}
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _loop1_145: param_with_default
|
|
static asdl_seq *
|
|
_loop1_145_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void *res = NULL;
|
|
int mark = p->mark;
|
|
int start_mark = p->mark;
|
|
void **children = PyMem_Malloc(sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "Parser out of memory");
|
|
return NULL;
|
|
}
|
|
ssize_t children_capacity = 1;
|
|
ssize_t n = 0;
|
|
{ // param_with_default
|
|
NameDefaultPair* param_with_default_var;
|
|
while (
|
|
(param_with_default_var = param_with_default_rule(p)) // param_with_default
|
|
)
|
|
{
|
|
res = param_with_default_var;
|
|
if (n == children_capacity) {
|
|
children_capacity *= 2;
|
|
children = PyMem_Realloc(children, children_capacity*sizeof(void *));
|
|
if (!children) {
|
|
PyErr_Format(PyExc_MemoryError, "realloc None");
|
|
return NULL;
|
|
}
|
|
}
|
|
children[n++] = res;
|
|
mark = p->mark;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
if (n == 0 || p->error_indicator) {
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);
|
|
if (!seq) {
|
|
PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_145");
|
|
PyMem_Free(children);
|
|
return NULL;
|
|
}
|
|
for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);
|
|
PyMem_Free(children);
|
|
_PyPegen_insert_memo(p, start_mark, _loop1_145_type, seq);
|
|
return seq;
|
|
}
|
|
|
|
// _tmp_146: ')' | '**'
|
|
static void *
|
|
_tmp_146_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ')'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 8)) // token=')'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '**'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 35)) // token='**'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
// _tmp_147: ':' | '**'
|
|
static void *
|
|
_tmp_147_rule(Parser *p)
|
|
{
|
|
if (p->error_indicator) {
|
|
return NULL;
|
|
}
|
|
void * res = NULL;
|
|
int mark = p->mark;
|
|
{ // ':'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 11)) // token=':'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
{ // '**'
|
|
Token * literal;
|
|
if (
|
|
(literal = _PyPegen_expect_token(p, 35)) // token='**'
|
|
)
|
|
{
|
|
res = literal;
|
|
goto done;
|
|
}
|
|
p->mark = mark;
|
|
}
|
|
res = NULL;
|
|
done:
|
|
return res;
|
|
}
|
|
|
|
void *
|
|
_PyPegen_parse(Parser *p)
|
|
{
|
|
// Initialize keywords
|
|
p->keywords = reserved_keywords;
|
|
p->n_keyword_lists = n_keyword_lists;
|
|
|
|
// Run parser
|
|
void *result = NULL;
|
|
if (p->start_rule == Py_file_input) {
|
|
result = file_rule(p);
|
|
} else if (p->start_rule == Py_single_input) {
|
|
result = interactive_rule(p);
|
|
} else if (p->start_rule == Py_eval_input) {
|
|
result = eval_rule(p);
|
|
} else if (p->start_rule == Py_func_type_input) {
|
|
result = func_type_rule(p);
|
|
} else if (p->start_rule == Py_fstring_input) {
|
|
result = fstring_rule(p);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// The end
|