From da7435017430671f86075449ff7bde96fd7700a5 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Thu, 15 Apr 2021 14:06:39 +0100 Subject: [PATCH] bpo-43823: Improve syntax errors for invalid dictionary literals (GH-25378) --- Grammar/python.gram | 11 + Lib/test/test_syntax.py | 32 + .../2021-04-13-03-06-09.bpo-43823.xpuHBi.rst | 2 + Parser/parser.c | 1364 +++++++++++------ 4 files changed, 934 insertions(+), 475 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2021-04-13-03-06-09.bpo-43823.xpuHBi.rst diff --git a/Grammar/python.gram b/Grammar/python.gram index 180d952b57a..8e399f1b8ea 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -650,6 +650,8 @@ dict[expr_ty]: CHECK(asdl_expr_seq*, _PyPegen_get_keys(p, a)), CHECK(asdl_expr_seq*, _PyPegen_get_values(p, a)), EXTRA) } + | '{' invalid_double_starred_kvpairs '}' + dictcomp[expr_ty]: | '{' a=kvpair b=for_if_clauses '}' { _PyAST_DictComp(a->key, a->value, b, EXTRA) } | invalid_dict_comprehension @@ -882,3 +884,12 @@ invalid_elif_stmt: | 'elif' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") } invalid_while_stmt: | 'while' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") } + +invalid_double_starred_kvpairs: + | ','.double_starred_kvpair+ ',' invalid_kvpair + | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use a starred expression in a dictionary value") } + | expression a=':' &('}'|',') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") } +invalid_kvpair: + | a=expression !(':') { RAISE_SYNTAX_ERROR("':' expected after dictionary key") } + | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use a starred expression in a dictionary value") } + | expression a=':' {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") } diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index bd6a4d339e7..75b778d20e9 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -880,6 +880,38 @@ Ensure that early = are not matched by the parser as invalid comparisons Traceback (most recent call last): SyntaxError: invalid syntax +Incomplete dictionary literals + + >>> {1:2, 3:4, 5} + Traceback (most recent call last): + SyntaxError: ':' expected after dictionary key + + >>> {1:2, 3:4, 5:} + Traceback (most recent call last): + SyntaxError: expression expected after dictionary key and ':' + + >>> {1: *12+1, 23: 1} + Traceback (most recent call last): + SyntaxError: cannot use a starred expression in a dictionary value + + >>> {1: *12+1} + Traceback (most recent call last): + SyntaxError: cannot use a starred expression in a dictionary value + + >>> {1: 23, 1: *12+1} + Traceback (most recent call last): + SyntaxError: cannot use a starred expression in a dictionary value + + >>> {1:} + Traceback (most recent call last): + SyntaxError: expression expected after dictionary key and ':' + + # Ensure that the error is not raise for syntax errors that happen after sets + + >>> {1} $ + Traceback (most recent call last): + SyntaxError: invalid syntax + Make sure that the old "raise X, Y[, Z]" form is gone: >>> raise X, Y Traceback (most recent call last): diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-04-13-03-06-09.bpo-43823.xpuHBi.rst b/Misc/NEWS.d/next/Core and Builtins/2021-04-13-03-06-09.bpo-43823.xpuHBi.rst new file mode 100644 index 00000000000..96cf8eee16b --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2021-04-13-03-06-09.bpo-43823.xpuHBi.rst @@ -0,0 +1,2 @@ +Improve syntax errors for invalid dictionary literals. Patch by Pablo +Galindo. diff --git a/Parser/parser.c b/Parser/parser.c index d158b2952ba..2ead05225be 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -268,191 +268,196 @@ static KeywordToken *reserved_keywords[] = { #define invalid_if_stmt_type 1200 #define invalid_elif_stmt_type 1201 #define invalid_while_stmt_type 1202 -#define _loop0_1_type 1203 -#define _loop0_2_type 1204 -#define _loop0_4_type 1205 -#define _gather_3_type 1206 -#define _loop0_6_type 1207 -#define _gather_5_type 1208 -#define _loop0_8_type 1209 -#define _gather_7_type 1210 -#define _loop0_10_type 1211 -#define _gather_9_type 1212 -#define _loop1_11_type 1213 -#define _loop0_13_type 1214 -#define _gather_12_type 1215 -#define _tmp_14_type 1216 -#define _tmp_15_type 1217 -#define _tmp_16_type 1218 -#define _tmp_17_type 1219 -#define _tmp_18_type 1220 -#define _tmp_19_type 1221 -#define _tmp_20_type 1222 -#define _tmp_21_type 1223 -#define _loop1_22_type 1224 -#define _tmp_23_type 1225 -#define _tmp_24_type 1226 -#define _loop0_26_type 1227 -#define _gather_25_type 1228 -#define _loop0_28_type 1229 -#define _gather_27_type 1230 -#define _tmp_29_type 1231 -#define _tmp_30_type 1232 -#define _loop0_31_type 1233 -#define _loop1_32_type 1234 -#define _loop0_34_type 1235 -#define _gather_33_type 1236 -#define _tmp_35_type 1237 -#define _loop0_37_type 1238 -#define _gather_36_type 1239 -#define _tmp_38_type 1240 -#define _loop0_40_type 1241 -#define _gather_39_type 1242 -#define _loop0_42_type 1243 -#define _gather_41_type 1244 -#define _loop0_44_type 1245 -#define _gather_43_type 1246 -#define _loop0_46_type 1247 -#define _gather_45_type 1248 -#define _tmp_47_type 1249 -#define _loop1_48_type 1250 -#define _tmp_49_type 1251 -#define _loop1_50_type 1252 -#define _loop0_52_type 1253 -#define _gather_51_type 1254 -#define _tmp_53_type 1255 -#define _tmp_54_type 1256 -#define _tmp_55_type 1257 -#define _loop0_57_type 1258 -#define _gather_56_type 1259 -#define _tmp_58_type 1260 -#define _loop0_60_type 1261 -#define _gather_59_type 1262 -#define _tmp_61_type 1263 -#define _loop0_63_type 1264 -#define _gather_62_type 1265 -#define _loop0_65_type 1266 -#define _gather_64_type 1267 -#define _tmp_66_type 1268 -#define _tmp_67_type 1269 -#define _tmp_68_type 1270 -#define _tmp_69_type 1271 -#define _loop0_70_type 1272 -#define _loop0_71_type 1273 -#define _loop0_72_type 1274 -#define _loop1_73_type 1275 -#define _loop0_74_type 1276 -#define _loop1_75_type 1277 -#define _loop1_76_type 1278 -#define _loop1_77_type 1279 -#define _loop0_78_type 1280 -#define _loop1_79_type 1281 -#define _loop0_80_type 1282 -#define _loop1_81_type 1283 -#define _loop0_82_type 1284 -#define _loop1_83_type 1285 -#define _loop1_84_type 1286 -#define _tmp_85_type 1287 -#define _loop1_86_type 1288 -#define _loop0_88_type 1289 -#define _gather_87_type 1290 -#define _loop1_89_type 1291 -#define _loop0_90_type 1292 -#define _loop0_91_type 1293 -#define _loop0_92_type 1294 -#define _loop1_93_type 1295 -#define _loop0_94_type 1296 -#define _loop1_95_type 1297 -#define _loop1_96_type 1298 -#define _loop1_97_type 1299 -#define _loop0_98_type 1300 -#define _loop1_99_type 1301 -#define _loop0_100_type 1302 -#define _loop1_101_type 1303 -#define _loop0_102_type 1304 -#define _loop1_103_type 1305 -#define _loop1_104_type 1306 -#define _loop1_105_type 1307 -#define _loop1_106_type 1308 -#define _tmp_107_type 1309 -#define _loop0_109_type 1310 -#define _gather_108_type 1311 -#define _tmp_110_type 1312 -#define _tmp_111_type 1313 -#define _tmp_112_type 1314 -#define _tmp_113_type 1315 -#define _loop1_114_type 1316 -#define _tmp_115_type 1317 -#define _tmp_116_type 1318 -#define _loop0_118_type 1319 -#define _gather_117_type 1320 -#define _loop1_119_type 1321 -#define _loop0_120_type 1322 -#define _loop0_121_type 1323 -#define _loop0_123_type 1324 -#define _gather_122_type 1325 -#define _tmp_124_type 1326 -#define _loop0_126_type 1327 -#define _gather_125_type 1328 -#define _loop0_128_type 1329 -#define _gather_127_type 1330 -#define _loop0_130_type 1331 -#define _gather_129_type 1332 -#define _loop0_132_type 1333 -#define _gather_131_type 1334 -#define _loop0_133_type 1335 -#define _loop0_135_type 1336 -#define _gather_134_type 1337 -#define _loop1_136_type 1338 -#define _tmp_137_type 1339 -#define _loop0_139_type 1340 -#define _gather_138_type 1341 -#define _loop0_141_type 1342 -#define _gather_140_type 1343 -#define _tmp_142_type 1344 -#define _tmp_143_type 1345 -#define _tmp_144_type 1346 -#define _tmp_145_type 1347 -#define _loop0_146_type 1348 -#define _loop0_147_type 1349 -#define _loop0_148_type 1350 -#define _tmp_149_type 1351 -#define _tmp_150_type 1352 -#define _tmp_151_type 1353 -#define _loop0_152_type 1354 -#define _loop1_153_type 1355 -#define _loop0_154_type 1356 -#define _loop1_155_type 1357 -#define _tmp_156_type 1358 -#define _tmp_157_type 1359 -#define _tmp_158_type 1360 -#define _loop0_160_type 1361 -#define _gather_159_type 1362 -#define _loop0_162_type 1363 -#define _gather_161_type 1364 -#define _tmp_163_type 1365 -#define _tmp_164_type 1366 -#define _tmp_165_type 1367 -#define _tmp_166_type 1368 -#define _tmp_167_type 1369 -#define _tmp_168_type 1370 -#define _tmp_169_type 1371 -#define _tmp_170_type 1372 -#define _tmp_171_type 1373 -#define _tmp_172_type 1374 -#define _tmp_173_type 1375 -#define _tmp_174_type 1376 -#define _tmp_175_type 1377 -#define _tmp_176_type 1378 -#define _tmp_177_type 1379 -#define _tmp_178_type 1380 -#define _tmp_179_type 1381 -#define _tmp_180_type 1382 -#define _tmp_181_type 1383 -#define _tmp_182_type 1384 -#define _tmp_183_type 1385 -#define _tmp_184_type 1386 -#define _tmp_185_type 1387 +#define invalid_double_starred_kvpairs_type 1203 +#define invalid_kvpair_type 1204 +#define _loop0_1_type 1205 +#define _loop0_2_type 1206 +#define _loop0_4_type 1207 +#define _gather_3_type 1208 +#define _loop0_6_type 1209 +#define _gather_5_type 1210 +#define _loop0_8_type 1211 +#define _gather_7_type 1212 +#define _loop0_10_type 1213 +#define _gather_9_type 1214 +#define _loop1_11_type 1215 +#define _loop0_13_type 1216 +#define _gather_12_type 1217 +#define _tmp_14_type 1218 +#define _tmp_15_type 1219 +#define _tmp_16_type 1220 +#define _tmp_17_type 1221 +#define _tmp_18_type 1222 +#define _tmp_19_type 1223 +#define _tmp_20_type 1224 +#define _tmp_21_type 1225 +#define _loop1_22_type 1226 +#define _tmp_23_type 1227 +#define _tmp_24_type 1228 +#define _loop0_26_type 1229 +#define _gather_25_type 1230 +#define _loop0_28_type 1231 +#define _gather_27_type 1232 +#define _tmp_29_type 1233 +#define _tmp_30_type 1234 +#define _loop0_31_type 1235 +#define _loop1_32_type 1236 +#define _loop0_34_type 1237 +#define _gather_33_type 1238 +#define _tmp_35_type 1239 +#define _loop0_37_type 1240 +#define _gather_36_type 1241 +#define _tmp_38_type 1242 +#define _loop0_40_type 1243 +#define _gather_39_type 1244 +#define _loop0_42_type 1245 +#define _gather_41_type 1246 +#define _loop0_44_type 1247 +#define _gather_43_type 1248 +#define _loop0_46_type 1249 +#define _gather_45_type 1250 +#define _tmp_47_type 1251 +#define _loop1_48_type 1252 +#define _tmp_49_type 1253 +#define _loop1_50_type 1254 +#define _loop0_52_type 1255 +#define _gather_51_type 1256 +#define _tmp_53_type 1257 +#define _tmp_54_type 1258 +#define _tmp_55_type 1259 +#define _loop0_57_type 1260 +#define _gather_56_type 1261 +#define _tmp_58_type 1262 +#define _loop0_60_type 1263 +#define _gather_59_type 1264 +#define _tmp_61_type 1265 +#define _loop0_63_type 1266 +#define _gather_62_type 1267 +#define _loop0_65_type 1268 +#define _gather_64_type 1269 +#define _tmp_66_type 1270 +#define _tmp_67_type 1271 +#define _tmp_68_type 1272 +#define _tmp_69_type 1273 +#define _loop0_70_type 1274 +#define _loop0_71_type 1275 +#define _loop0_72_type 1276 +#define _loop1_73_type 1277 +#define _loop0_74_type 1278 +#define _loop1_75_type 1279 +#define _loop1_76_type 1280 +#define _loop1_77_type 1281 +#define _loop0_78_type 1282 +#define _loop1_79_type 1283 +#define _loop0_80_type 1284 +#define _loop1_81_type 1285 +#define _loop0_82_type 1286 +#define _loop1_83_type 1287 +#define _loop1_84_type 1288 +#define _tmp_85_type 1289 +#define _loop1_86_type 1290 +#define _loop0_88_type 1291 +#define _gather_87_type 1292 +#define _loop1_89_type 1293 +#define _loop0_90_type 1294 +#define _loop0_91_type 1295 +#define _loop0_92_type 1296 +#define _loop1_93_type 1297 +#define _loop0_94_type 1298 +#define _loop1_95_type 1299 +#define _loop1_96_type 1300 +#define _loop1_97_type 1301 +#define _loop0_98_type 1302 +#define _loop1_99_type 1303 +#define _loop0_100_type 1304 +#define _loop1_101_type 1305 +#define _loop0_102_type 1306 +#define _loop1_103_type 1307 +#define _loop1_104_type 1308 +#define _loop1_105_type 1309 +#define _loop1_106_type 1310 +#define _tmp_107_type 1311 +#define _loop0_109_type 1312 +#define _gather_108_type 1313 +#define _tmp_110_type 1314 +#define _tmp_111_type 1315 +#define _tmp_112_type 1316 +#define _tmp_113_type 1317 +#define _loop1_114_type 1318 +#define _tmp_115_type 1319 +#define _tmp_116_type 1320 +#define _loop0_118_type 1321 +#define _gather_117_type 1322 +#define _loop1_119_type 1323 +#define _loop0_120_type 1324 +#define _loop0_121_type 1325 +#define _loop0_123_type 1326 +#define _gather_122_type 1327 +#define _tmp_124_type 1328 +#define _loop0_126_type 1329 +#define _gather_125_type 1330 +#define _loop0_128_type 1331 +#define _gather_127_type 1332 +#define _loop0_130_type 1333 +#define _gather_129_type 1334 +#define _loop0_132_type 1335 +#define _gather_131_type 1336 +#define _loop0_133_type 1337 +#define _loop0_135_type 1338 +#define _gather_134_type 1339 +#define _loop1_136_type 1340 +#define _tmp_137_type 1341 +#define _loop0_139_type 1342 +#define _gather_138_type 1343 +#define _loop0_141_type 1344 +#define _gather_140_type 1345 +#define _tmp_142_type 1346 +#define _tmp_143_type 1347 +#define _tmp_144_type 1348 +#define _tmp_145_type 1349 +#define _loop0_146_type 1350 +#define _loop0_147_type 1351 +#define _loop0_148_type 1352 +#define _tmp_149_type 1353 +#define _tmp_150_type 1354 +#define _tmp_151_type 1355 +#define _loop0_152_type 1356 +#define _loop1_153_type 1357 +#define _loop0_154_type 1358 +#define _loop1_155_type 1359 +#define _tmp_156_type 1360 +#define _tmp_157_type 1361 +#define _tmp_158_type 1362 +#define _loop0_160_type 1363 +#define _gather_159_type 1364 +#define _loop0_162_type 1365 +#define _gather_161_type 1366 +#define _tmp_163_type 1367 +#define _tmp_164_type 1368 +#define _loop0_166_type 1369 +#define _gather_165_type 1370 +#define _tmp_167_type 1371 +#define _tmp_168_type 1372 +#define _tmp_169_type 1373 +#define _tmp_170_type 1374 +#define _tmp_171_type 1375 +#define _tmp_172_type 1376 +#define _tmp_173_type 1377 +#define _tmp_174_type 1378 +#define _tmp_175_type 1379 +#define _tmp_176_type 1380 +#define _tmp_177_type 1381 +#define _tmp_178_type 1382 +#define _tmp_179_type 1383 +#define _tmp_180_type 1384 +#define _tmp_181_type 1385 +#define _tmp_182_type 1386 +#define _tmp_183_type 1387 +#define _tmp_184_type 1388 +#define _tmp_185_type 1389 +#define _tmp_186_type 1390 +#define _tmp_187_type 1391 +#define _tmp_188_type 1392 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -657,6 +662,8 @@ static void *invalid_case_block_rule(Parser *p); static void *invalid_if_stmt_rule(Parser *p); static void *invalid_elif_stmt_rule(Parser *p); static void *invalid_while_stmt_rule(Parser *p); +static void *invalid_double_starred_kvpairs_rule(Parser *p); +static void *invalid_kvpair_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); @@ -821,8 +828,8 @@ static asdl_seq *_loop0_162_rule(Parser *p); static asdl_seq *_gather_161_rule(Parser *p); static void *_tmp_163_rule(Parser *p); static void *_tmp_164_rule(Parser *p); -static void *_tmp_165_rule(Parser *p); -static void *_tmp_166_rule(Parser *p); +static asdl_seq *_loop0_166_rule(Parser *p); +static asdl_seq *_gather_165_rule(Parser *p); static void *_tmp_167_rule(Parser *p); static void *_tmp_168_rule(Parser *p); static void *_tmp_169_rule(Parser *p); @@ -842,6 +849,9 @@ static void *_tmp_182_rule(Parser *p); static void *_tmp_183_rule(Parser *p); static void *_tmp_184_rule(Parser *p); static void *_tmp_185_rule(Parser *p); +static void *_tmp_186_rule(Parser *p); +static void *_tmp_187_rule(Parser *p); +static void *_tmp_188_rule(Parser *p); // file: statements? $ @@ -14254,7 +14264,7 @@ setcomp_rule(Parser *p) return _res; } -// dict: '{' double_starred_kvpairs? '}' +// dict: '{' double_starred_kvpairs? '}' | '{' invalid_double_starred_kvpairs '}' static expr_ty dict_rule(Parser *p) { @@ -14313,6 +14323,31 @@ dict_rule(Parser *p) D(fprintf(stderr, "%*c%s dict[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' double_starred_kvpairs? '}'")); } + { // '{' invalid_double_starred_kvpairs '}' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> dict[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' invalid_double_starred_kvpairs '}'")); + Token * _literal; + Token * _literal_1; + void *invalid_double_starred_kvpairs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (invalid_double_starred_kvpairs_var = invalid_double_starred_kvpairs_rule(p)) // invalid_double_starred_kvpairs + && + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ dict[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' invalid_double_starred_kvpairs '}'")); + _res = _PyPegen_dummy_name(p, _literal, invalid_double_starred_kvpairs_var, _literal_1); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s dict[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' invalid_double_starred_kvpairs '}'")); + } _res = NULL; done: D(p->level--); @@ -19133,6 +19168,216 @@ invalid_while_stmt_rule(Parser *p) return _res; } +// invalid_double_starred_kvpairs: +// | ','.double_starred_kvpair+ ',' invalid_kvpair +// | expression ':' '*' bitwise_or +// | expression ':' &('}' | ',') +static void * +invalid_double_starred_kvpairs_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ','.double_starred_kvpair+ ',' invalid_kvpair + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' invalid_kvpair")); + asdl_seq * _gather_165_var; + Token * _literal; + void *invalid_kvpair_var; + if ( + (_gather_165_var = _gather_165_rule(p)) // ','.double_starred_kvpair+ + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (invalid_kvpair_var = invalid_kvpair_rule(p)) // invalid_kvpair + ) + { + D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' invalid_kvpair")); + _res = _PyPegen_dummy_name(p, _gather_165_var, _literal, invalid_kvpair_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ',' invalid_kvpair")); + } + { // expression ':' '*' bitwise_or + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); + Token * _literal; + Token * a; + expr_ty bitwise_or_var; + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use a starred expression in a dictionary value" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '*' bitwise_or")); + } + { // expression ':' &('}' | ',') + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); + Token * a; + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (a = _PyPegen_expect_token(p, 11)) // token=':' + && + _PyPegen_lookahead(1, _tmp_167_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression expected after dictionary key and ':'" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' &('}' | ',')")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_kvpair: expression !(':') | expression ':' '*' bitwise_or | expression ':' +static void * +invalid_kvpair_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // expression !(':') + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !(':')")); + expr_ty a; + if ( + (a = expression_rule(p)) // expression + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 11) // token=(':') + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !(':')")); + _res = RAISE_SYNTAX_ERROR ( "':' expected after dictionary key" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !(':')")); + } + { // expression ':' '*' bitwise_or + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); + Token * _literal; + Token * a; + expr_ty bitwise_or_var; + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use a starred expression in a dictionary value" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '*' bitwise_or")); + } + { // expression ':' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':'")); + Token * a; + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (a = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression expected after dictionary key and ':'" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + // _loop0_1: NEWLINE static asdl_seq * _loop0_1_rule(Parser *p) @@ -20381,12 +20626,12 @@ _loop1_22_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_165_var; + void *_tmp_168_var; while ( - (_tmp_165_var = _tmp_165_rule(p)) // star_targets '=' + (_tmp_168_var = _tmp_168_rule(p)) // star_targets '=' ) { - _res = _tmp_165_var; + _res = _tmp_168_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20889,12 +21134,12 @@ _loop0_31_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_166_var; + void *_tmp_169_var; while ( - (_tmp_166_var = _tmp_166_rule(p)) // '.' | '...' + (_tmp_169_var = _tmp_169_rule(p)) // '.' | '...' ) { - _res = _tmp_166_var; + _res = _tmp_169_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20955,12 +21200,12 @@ _loop1_32_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_167_var; + void *_tmp_170_var; while ( - (_tmp_167_var = _tmp_167_rule(p)) // '.' | '...' + (_tmp_170_var = _tmp_170_rule(p)) // '.' | '...' ) { - _res = _tmp_167_var; + _res = _tmp_170_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24071,12 +24316,12 @@ _loop1_84_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_168_var; + void *_tmp_171_var; while ( - (_tmp_168_var = _tmp_168_rule(p)) // '@' named_expression NEWLINE + (_tmp_171_var = _tmp_171_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_168_var; + _res = _tmp_171_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24189,12 +24434,12 @@ _loop1_86_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_169_var; + void *_tmp_172_var; while ( - (_tmp_169_var = _tmp_169_rule(p)) // ',' star_expression + (_tmp_172_var = _tmp_172_rule(p)) // ',' star_expression ) { - _res = _tmp_169_var; + _res = _tmp_172_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24374,12 +24619,12 @@ _loop1_89_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_170_var; + void *_tmp_173_var; while ( - (_tmp_170_var = _tmp_170_rule(p)) // ',' expression + (_tmp_173_var = _tmp_173_rule(p)) // ',' expression ) { - _res = _tmp_170_var; + _res = _tmp_173_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25404,12 +25649,12 @@ _loop1_104_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_171_var; + void *_tmp_174_var; while ( - (_tmp_171_var = _tmp_171_rule(p)) // 'or' conjunction + (_tmp_174_var = _tmp_174_rule(p)) // 'or' conjunction ) { - _res = _tmp_171_var; + _res = _tmp_174_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25475,12 +25720,12 @@ _loop1_105_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_172_var; + void *_tmp_175_var; while ( - (_tmp_172_var = _tmp_172_rule(p)) // 'and' inversion + (_tmp_175_var = _tmp_175_rule(p)) // 'and' inversion ) { - _res = _tmp_172_var; + _res = _tmp_175_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -26396,12 +26641,12 @@ _loop0_120_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_173_var; + void *_tmp_176_var; while ( - (_tmp_173_var = _tmp_173_rule(p)) // 'if' disjunction + (_tmp_176_var = _tmp_176_rule(p)) // 'if' disjunction ) { - _res = _tmp_173_var; + _res = _tmp_176_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -26462,12 +26707,12 @@ _loop0_121_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_174_var; + void *_tmp_177_var; while ( - (_tmp_174_var = _tmp_174_rule(p)) // 'if' disjunction + (_tmp_177_var = _tmp_177_rule(p)) // 'if' disjunction ) { - _res = _tmp_174_var; + _res = _tmp_177_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -26533,7 +26778,7 @@ _loop0_123_rule(Parser *p) while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_175_rule(p)) // starred_expression | direct_named_expression !'=' + (elem = _tmp_178_rule(p)) // starred_expression | direct_named_expression !'=' ) { _res = elem; @@ -26596,7 +26841,7 @@ _gather_122_rule(Parser *p) void *elem; asdl_seq * seq; if ( - (elem = _tmp_175_rule(p)) // starred_expression | direct_named_expression !'=' + (elem = _tmp_178_rule(p)) // starred_expression | direct_named_expression !'=' && (seq = _loop0_123_rule(p)) // _loop0_123 ) @@ -27142,12 +27387,12 @@ _loop0_133_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_176_var; + void *_tmp_179_var; while ( - (_tmp_176_var = _tmp_176_rule(p)) // ',' star_target + (_tmp_179_var = _tmp_179_rule(p)) // ',' star_target ) { - _res = _tmp_176_var; + _res = _tmp_179_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -27322,12 +27567,12 @@ _loop1_136_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_177_var; + void *_tmp_180_var; while ( - (_tmp_177_var = _tmp_177_rule(p)) // ',' star_target + (_tmp_180_var = _tmp_180_rule(p)) // ',' star_target ) { - _res = _tmp_177_var; + _res = _tmp_180_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -28062,12 +28307,12 @@ _loop0_147_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_178_var; + void *_tmp_181_var; while ( - (_tmp_178_var = _tmp_178_rule(p)) // star_targets '=' + (_tmp_181_var = _tmp_181_rule(p)) // star_targets '=' ) { - _res = _tmp_178_var; + _res = _tmp_181_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -28128,12 +28373,12 @@ _loop0_148_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_179_var; + void *_tmp_182_var; while ( - (_tmp_179_var = _tmp_179_rule(p)) // star_targets '=' + (_tmp_182_var = _tmp_182_rule(p)) // star_targets '=' ) { - _res = _tmp_179_var; + _res = _tmp_182_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -28662,15 +28907,15 @@ _tmp_156_rule(Parser *p) } D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_180_var; + void *_tmp_183_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_180_var = _tmp_180_rule(p)) // ')' | '**' + (_tmp_183_var = _tmp_183_rule(p)) // ')' | '**' ) { D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_180_var); + _res = _PyPegen_dummy_name(p, _literal, _tmp_183_var); goto done; } p->mark = _mark; @@ -28720,15 +28965,15 @@ _tmp_157_rule(Parser *p) } D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_181_var; + void *_tmp_184_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_181_var = _tmp_181_rule(p)) // ':' | '**' + (_tmp_184_var = _tmp_184_rule(p)) // ':' | '**' ) { D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_181_var); + _res = _PyPegen_dummy_name(p, _literal, _tmp_184_var); goto done; } p->mark = _mark; @@ -28847,7 +29092,7 @@ _loop0_160_rule(Parser *p) while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_182_rule(p)) // expression ['as' star_target] + (elem = _tmp_185_rule(p)) // expression ['as' star_target] ) { _res = elem; @@ -28910,7 +29155,7 @@ _gather_159_rule(Parser *p) void *elem; asdl_seq * seq; if ( - (elem = _tmp_182_rule(p)) // expression ['as' star_target] + (elem = _tmp_185_rule(p)) // expression ['as' star_target] && (seq = _loop0_160_rule(p)) // _loop0_160 ) @@ -28961,7 +29206,7 @@ _loop0_162_rule(Parser *p) while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_183_rule(p)) // expressions ['as' star_target] + (elem = _tmp_186_rule(p)) // expressions ['as' star_target] ) { _res = elem; @@ -29024,7 +29269,7 @@ _gather_161_rule(Parser *p) void *elem; asdl_seq * seq; if ( - (elem = _tmp_183_rule(p)) // expressions ['as' star_target] + (elem = _tmp_186_rule(p)) // expressions ['as' star_target] && (seq = _loop0_162_rule(p)) // _loop0_162 ) @@ -29121,9 +29366,178 @@ _tmp_164_rule(Parser *p) return _res; } -// _tmp_165: star_targets '=' +// _loop0_166: ',' double_starred_kvpair +static asdl_seq * +_loop0_166_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + Py_ssize_t _children_capacity = 1; + Py_ssize_t _n = 0; + { // ',' double_starred_kvpair + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + Token * _literal; + KeyValuePair* elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + D(p->level--); + return NULL; + } + if (_n == _children_capacity) { + _children_capacity *= 2; + void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); + if (!_new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + _children = _new_children; + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_166[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_166_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_165: double_starred_kvpair _loop0_166 +static asdl_seq * +_gather_165_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // double_starred_kvpair _loop0_166 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_166")); + KeyValuePair* elem; + asdl_seq * seq; + if ( + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + && + (seq = _loop0_166_rule(p)) // _loop0_166 + ) + { + D(fprintf(stderr, "%*c+ _gather_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_166")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_165[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_166")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_167: '}' | ',' static void * -_tmp_165_rule(Parser *p) +_tmp_167_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '}' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + } + { // ',' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_168: star_targets '=' +static void * +_tmp_168_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29137,7 +29551,7 @@ _tmp_165_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -29146,7 +29560,7 @@ _tmp_165_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29156,7 +29570,7 @@ _tmp_165_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -29165,9 +29579,9 @@ _tmp_165_rule(Parser *p) return _res; } -// _tmp_166: '.' | '...' +// _tmp_169: '.' | '...' static void * -_tmp_166_rule(Parser *p) +_tmp_169_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29181,18 +29595,18 @@ _tmp_166_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_169[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -29200,18 +29614,18 @@ _tmp_166_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_169[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -29220,9 +29634,9 @@ _tmp_166_rule(Parser *p) return _res; } -// _tmp_167: '.' | '...' +// _tmp_170: '.' | '...' static void * -_tmp_167_rule(Parser *p) +_tmp_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29236,18 +29650,18 @@ _tmp_167_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -29255,18 +29669,18 @@ _tmp_167_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -29275,9 +29689,9 @@ _tmp_167_rule(Parser *p) return _res; } -// _tmp_168: '@' named_expression NEWLINE +// _tmp_171: '@' named_expression NEWLINE static void * -_tmp_168_rule(Parser *p) +_tmp_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29291,7 +29705,7 @@ _tmp_168_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -29303,7 +29717,7 @@ _tmp_168_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29313,7 +29727,7 @@ _tmp_168_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -29322,9 +29736,9 @@ _tmp_168_rule(Parser *p) return _res; } -// _tmp_169: ',' star_expression +// _tmp_172: ',' star_expression static void * -_tmp_169_rule(Parser *p) +_tmp_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29338,7 +29752,7 @@ _tmp_169_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -29347,7 +29761,7 @@ _tmp_169_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29357,7 +29771,7 @@ _tmp_169_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_169[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_172[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -29366,9 +29780,9 @@ _tmp_169_rule(Parser *p) return _res; } -// _tmp_170: ',' expression +// _tmp_173: ',' expression static void * -_tmp_170_rule(Parser *p) +_tmp_173_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29382,7 +29796,7 @@ _tmp_170_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -29391,7 +29805,7 @@ _tmp_170_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29401,7 +29815,7 @@ _tmp_170_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -29410,9 +29824,9 @@ _tmp_170_rule(Parser *p) return _res; } -// _tmp_171: 'or' conjunction +// _tmp_174: 'or' conjunction static void * -_tmp_171_rule(Parser *p) +_tmp_174_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29426,7 +29840,7 @@ _tmp_171_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -29435,7 +29849,7 @@ _tmp_171_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29445,7 +29859,7 @@ _tmp_171_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -29454,9 +29868,9 @@ _tmp_171_rule(Parser *p) return _res; } -// _tmp_172: 'and' inversion +// _tmp_175: 'and' inversion static void * -_tmp_172_rule(Parser *p) +_tmp_175_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29470,7 +29884,7 @@ _tmp_172_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -29479,7 +29893,7 @@ _tmp_172_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29489,7 +29903,7 @@ _tmp_172_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_172[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -29498,9 +29912,9 @@ _tmp_172_rule(Parser *p) return _res; } -// _tmp_173: 'if' disjunction +// _tmp_176: 'if' disjunction static void * -_tmp_173_rule(Parser *p) +_tmp_176_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29514,7 +29928,7 @@ _tmp_173_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -29523,7 +29937,7 @@ _tmp_173_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29533,7 +29947,7 @@ _tmp_173_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -29542,9 +29956,9 @@ _tmp_173_rule(Parser *p) return _res; } -// _tmp_174: 'if' disjunction +// _tmp_177: 'if' disjunction static void * -_tmp_174_rule(Parser *p) +_tmp_177_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29558,7 +29972,7 @@ _tmp_174_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -29567,7 +29981,7 @@ _tmp_174_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29577,7 +29991,7 @@ _tmp_174_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -29586,9 +30000,9 @@ _tmp_174_rule(Parser *p) return _res; } -// _tmp_175: starred_expression | direct_named_expression !'=' +// _tmp_178: starred_expression | direct_named_expression !'=' static void * -_tmp_175_rule(Parser *p) +_tmp_178_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29602,18 +30016,18 @@ _tmp_175_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); expr_ty starred_expression_var; if ( (starred_expression_var = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); _res = starred_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } { // direct_named_expression !'=' @@ -29621,7 +30035,7 @@ _tmp_175_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "direct_named_expression !'='")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "direct_named_expression !'='")); expr_ty direct_named_expression_var; if ( (direct_named_expression_var = direct_named_expression_rule(p)) // direct_named_expression @@ -29629,12 +30043,12 @@ _tmp_175_rule(Parser *p) _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "direct_named_expression !'='")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "direct_named_expression !'='")); _res = direct_named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "direct_named_expression !'='")); } _res = NULL; @@ -29643,136 +30057,97 @@ _tmp_175_rule(Parser *p) return _res; } -// _tmp_176: ',' star_target -static void * -_tmp_176_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ',' star_target - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); - Token * _literal; - expr_ty c; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (c = star_target_rule(p)) // star_target - ) - { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); - _res = c; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_177: ',' star_target -static void * -_tmp_177_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ',' star_target - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); - Token * _literal; - expr_ty c; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (c = star_target_rule(p)) // star_target - ) - { - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); - _res = c; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_178: star_targets '=' -static void * -_tmp_178_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // star_targets '=' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - Token * _literal; - expr_ty star_targets_var; - if ( - (star_targets_var = star_targets_rule(p)) // star_targets - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - _res = _PyPegen_dummy_name(p, star_targets_var, _literal); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_179: star_targets '=' +// _tmp_179: ',' star_target static void * _tmp_179_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' star_target + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + Token * _literal; + expr_ty c; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (c = star_target_rule(p)) // star_target + ) + { + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + _res = c; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_180: ',' star_target +static void * +_tmp_180_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' star_target + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + Token * _literal; + expr_ty c; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (c = star_target_rule(p)) // star_target + ) + { + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + _res = c; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_181: star_targets '=' +static void * +_tmp_181_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29786,7 +30161,7 @@ _tmp_179_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -29795,12 +30170,12 @@ _tmp_179_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = _PyPegen_dummy_name(p, star_targets_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -29809,9 +30184,48 @@ _tmp_179_rule(Parser *p) return _res; } -// _tmp_180: ')' | '**' +// _tmp_182: star_targets '=' static void * -_tmp_180_rule(Parser *p) +_tmp_182_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // star_targets '=' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + Token * _literal; + expr_ty star_targets_var; + if ( + (star_targets_var = star_targets_rule(p)) // star_targets + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + _res = _PyPegen_dummy_name(p, star_targets_var, _literal); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_182[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_183: ')' | '**' +static void * +_tmp_183_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29825,18 +30239,18 @@ _tmp_180_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // '**' @@ -29844,18 +30258,18 @@ _tmp_180_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -29864,9 +30278,9 @@ _tmp_180_rule(Parser *p) return _res; } -// _tmp_181: ':' | '**' +// _tmp_184: ':' | '**' static void * -_tmp_181_rule(Parser *p) +_tmp_184_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29880,18 +30294,18 @@ _tmp_181_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_184[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '**' @@ -29899,18 +30313,18 @@ _tmp_181_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_184[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -29919,9 +30333,9 @@ _tmp_181_rule(Parser *p) return _res; } -// _tmp_182: expression ['as' star_target] +// _tmp_185: expression ['as' star_target] static void * -_tmp_182_rule(Parser *p) +_tmp_185_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29935,22 +30349,22 @@ _tmp_182_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_184_rule(p), 1) // ['as' star_target] + (_opt_var = _tmp_187_rule(p), 1) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); _res = _PyPegen_dummy_name(p, expression_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_182[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_185[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' star_target]")); } _res = NULL; @@ -29959,9 +30373,9 @@ _tmp_182_rule(Parser *p) return _res; } -// _tmp_183: expressions ['as' star_target] +// _tmp_186: expressions ['as' star_target] static void * -_tmp_183_rule(Parser *p) +_tmp_186_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29975,22 +30389,22 @@ _tmp_183_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expressions_var; if ( (expressions_var = expressions_rule(p)) // expressions && - (_opt_var = _tmp_185_rule(p), 1) // ['as' star_target] + (_opt_var = _tmp_188_rule(p), 1) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_186[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_186[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions ['as' star_target]")); } _res = NULL; @@ -29999,9 +30413,9 @@ _tmp_183_rule(Parser *p) return _res; } -// _tmp_184: 'as' star_target +// _tmp_187: 'as' star_target static void * -_tmp_184_rule(Parser *p) +_tmp_187_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -30015,7 +30429,7 @@ _tmp_184_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( @@ -30024,12 +30438,12 @@ _tmp_184_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_187[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_184[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_187[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); } _res = NULL; @@ -30038,9 +30452,9 @@ _tmp_184_rule(Parser *p) return _res; } -// _tmp_185: 'as' star_target +// _tmp_188: 'as' star_target static void * -_tmp_185_rule(Parser *p) +_tmp_188_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -30054,7 +30468,7 @@ _tmp_185_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( @@ -30063,12 +30477,12 @@ _tmp_185_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_185[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_188[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); } _res = NULL;