summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2022-09-17 17:09:28 (GMT)
committerGitHub <noreply@github.com>2022-09-17 17:09:28 (GMT)
commit7e36abbb7815b14777c207dba0fe6fcd41d6d37a (patch)
tree4329d4d070261c451d9e9ccbd4d3a8833522c6c8 /Parser
parent78359b1d45608439f8e03b8e86174fe7b04d3e08 (diff)
downloadcpython-7e36abbb7815b14777c207dba0fe6fcd41d6d37a.zip
cpython-7e36abbb7815b14777c207dba0fe6fcd41d6d37a.tar.gz
cpython-7e36abbb7815b14777c207dba0fe6fcd41d6d37a.tar.bz2
gh-91210: Improve error message when non-default param follows default (GH-95933)
- Improve error message when parameter without a default follows one with a default - Show same error message when positional-only params precede the default/non-default sequence
Diffstat (limited to 'Parser')
-rw-r--r--Parser/parser.c698
1 files changed, 353 insertions, 345 deletions
diff --git a/Parser/parser.c b/Parser/parser.c
index bec51fe..bd3204a 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -464,11 +464,11 @@ static char *soft_keywords[] = {
#define _tmp_156_type 1384
#define _tmp_157_type 1385
#define _tmp_158_type 1386
-#define _loop0_159_type 1387
+#define _tmp_159_type 1387
#define _loop0_160_type 1388
-#define _loop1_161_type 1389
-#define _tmp_162_type 1390
-#define _loop0_163_type 1391
+#define _loop0_161_type 1389
+#define _loop0_162_type 1390
+#define _loop1_163_type 1391
#define _tmp_164_type 1392
#define _loop0_165_type 1393
#define _tmp_166_type 1394
@@ -481,12 +481,12 @@ static char *soft_keywords[] = {
#define _tmp_173_type 1401
#define _tmp_174_type 1402
#define _loop1_175_type 1403
-#define _loop0_176_type 1404
+#define _tmp_176_type 1404
#define _loop0_177_type 1405
-#define _loop0_179_type 1406
-#define _gather_178_type 1407
-#define _tmp_180_type 1408
-#define _loop0_181_type 1409
+#define _loop0_178_type 1406
+#define _loop0_179_type 1407
+#define _loop0_181_type 1408
+#define _gather_180_type 1409
#define _tmp_182_type 1410
#define _loop0_183_type 1411
#define _tmp_184_type 1412
@@ -943,11 +943,11 @@ static void *_tmp_155_rule(Parser *p);
static void *_tmp_156_rule(Parser *p);
static void *_tmp_157_rule(Parser *p);
static void *_tmp_158_rule(Parser *p);
-static asdl_seq *_loop0_159_rule(Parser *p);
+static void *_tmp_159_rule(Parser *p);
static asdl_seq *_loop0_160_rule(Parser *p);
-static asdl_seq *_loop1_161_rule(Parser *p);
-static void *_tmp_162_rule(Parser *p);
-static asdl_seq *_loop0_163_rule(Parser *p);
+static asdl_seq *_loop0_161_rule(Parser *p);
+static asdl_seq *_loop0_162_rule(Parser *p);
+static asdl_seq *_loop1_163_rule(Parser *p);
static void *_tmp_164_rule(Parser *p);
static asdl_seq *_loop0_165_rule(Parser *p);
static void *_tmp_166_rule(Parser *p);
@@ -960,12 +960,12 @@ static asdl_seq *_loop0_172_rule(Parser *p);
static void *_tmp_173_rule(Parser *p);
static void *_tmp_174_rule(Parser *p);
static asdl_seq *_loop1_175_rule(Parser *p);
-static asdl_seq *_loop0_176_rule(Parser *p);
+static void *_tmp_176_rule(Parser *p);
static asdl_seq *_loop0_177_rule(Parser *p);
+static asdl_seq *_loop0_178_rule(Parser *p);
static asdl_seq *_loop0_179_rule(Parser *p);
-static asdl_seq *_gather_178_rule(Parser *p);
-static void *_tmp_180_rule(Parser *p);
static asdl_seq *_loop0_181_rule(Parser *p);
+static asdl_seq *_gather_180_rule(Parser *p);
static void *_tmp_182_rule(Parser *p);
static asdl_seq *_loop0_183_rule(Parser *p);
static void *_tmp_184_rule(Parser *p);
@@ -20192,10 +20192,10 @@ invalid_dict_comprehension_rule(Parser *p)
}
// invalid_parameters:
-// | param_no_default* invalid_parameters_helper param_no_default
-// | param_no_default* '(' param_no_default+ ','? ')'
// | "/" ','
// | (slash_no_default | slash_with_default) param_maybe_default* '/'
+// | slash_no_default? param_no_default* invalid_parameters_helper param_no_default
+// | param_no_default* '(' param_no_default+ ','? ')'
// | [(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'
// | param_maybe_default+ '/' '*'
static void *
@@ -20211,25 +20211,22 @@ invalid_parameters_rule(Parser *p)
}
void * _res = NULL;
int _mark = p->mark;
- { // param_no_default* invalid_parameters_helper param_no_default
+ { // "/" ','
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* invalid_parameters_helper param_no_default"));
- asdl_seq * _loop0_159_var;
- arg_ty a;
- void *invalid_parameters_helper_var;
+ D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"/\" ','"));
+ Token * _literal;
+ Token * a;
if (
- (_loop0_159_var = _loop0_159_rule(p)) // param_no_default*
- &&
- (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper
+ (a = _PyPegen_expect_token(p, 17)) // token='/'
&&
- (a = param_no_default_rule(p)) // param_no_default
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
)
{
- D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* invalid_parameters_helper param_no_default"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "non-default argument follows default argument" );
+ D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"/\" ','"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "at least one argument must precede /" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20239,34 +20236,27 @@ invalid_parameters_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* invalid_parameters_helper param_no_default"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"/\" ','"));
}
- { // param_no_default* '(' param_no_default+ ','? ')'
+ { // (slash_no_default | slash_with_default) param_maybe_default* '/'
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'"));
+ D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'"));
asdl_seq * _loop0_160_var;
- asdl_seq * _loop1_161_var;
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
+ void *_tmp_159_var;
Token * a;
- Token * b;
if (
- (_loop0_160_var = _loop0_160_rule(p)) // param_no_default*
- &&
- (a = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (_loop1_161_var = _loop1_161_rule(p)) // param_no_default+
+ (_tmp_159_var = _tmp_159_rule(p)) // slash_no_default | slash_with_default
&&
- (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','?
+ (_loop0_160_var = _loop0_160_rule(p)) // param_maybe_default*
&&
- (b = _PyPegen_expect_token(p, 8)) // token=')'
+ (a = _PyPegen_expect_token(p, 17)) // token='/'
)
{
- D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Function parameters cannot be parenthesized" );
+ D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ may appear only once" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20276,24 +20266,31 @@ invalid_parameters_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'"));
}
- { // "/" ','
+ { // slash_no_default? param_no_default* invalid_parameters_helper param_no_default
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"/\" ','"));
- Token * _literal;
- Token * a;
+ D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default"));
+ asdl_seq * _loop0_161_var;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ arg_ty a;
+ void *invalid_parameters_helper_var;
if (
- (a = _PyPegen_expect_token(p, 17)) // token='/'
+ (_opt_var = slash_no_default_rule(p), !p->error_indicator) // slash_no_default?
&&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ (_loop0_161_var = _loop0_161_rule(p)) // param_no_default*
+ &&
+ (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper
+ &&
+ (a = param_no_default_rule(p)) // param_no_default
)
{
- D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"/\" ','"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "at least one argument must precede /" );
+ D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameter without a default follows parameter with a default" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20303,27 +20300,34 @@ invalid_parameters_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"/\" ','"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default"));
}
- { // (slash_no_default | slash_with_default) param_maybe_default* '/'
+ { // param_no_default* '(' param_no_default+ ','? ')'
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'"));
- asdl_seq * _loop0_163_var;
- void *_tmp_162_var;
+ D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'"));
+ asdl_seq * _loop0_162_var;
+ asdl_seq * _loop1_163_var;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
Token * a;
+ Token * b;
if (
- (_tmp_162_var = _tmp_162_rule(p)) // slash_no_default | slash_with_default
+ (_loop0_162_var = _loop0_162_rule(p)) // param_no_default*
&&
- (_loop0_163_var = _loop0_163_rule(p)) // param_maybe_default*
+ (a = _PyPegen_expect_token(p, 7)) // token='('
&&
- (a = _PyPegen_expect_token(p, 17)) // token='/'
+ (_loop1_163_var = _loop1_163_rule(p)) // param_no_default+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','?
+ &&
+ (b = _PyPegen_expect_token(p, 8)) // token=')'
)
{
- D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ may appear only once" );
+ D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Function parameters cannot be parenthesized" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20333,7 +20337,7 @@ invalid_parameters_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'"));
}
{ // [(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'
if (p->error_indicator) {
@@ -20784,10 +20788,10 @@ invalid_parameters_helper_rule(Parser *p)
}
// invalid_lambda_parameters:
-// | lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default
-// | lambda_param_no_default* '(' ','.lambda_param+ ','? ')'
// | "/" ','
// | (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'
+// | lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default
+// | lambda_param_no_default* '(' ','.lambda_param+ ','? ')'
// | [(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'
// | lambda_param_maybe_default+ '/' '*'
static void *
@@ -20803,25 +20807,22 @@ invalid_lambda_parameters_rule(Parser *p)
}
void * _res = NULL;
int _mark = p->mark;
- { // lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default
+ { // "/" ','
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default"));
- asdl_seq * _loop0_176_var;
- arg_ty a;
- void *invalid_lambda_parameters_helper_var;
+ D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"/\" ','"));
+ Token * _literal;
+ Token * a;
if (
- (_loop0_176_var = _loop0_176_rule(p)) // lambda_param_no_default*
- &&
- (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper
+ (a = _PyPegen_expect_token(p, 17)) // token='/'
&&
- (a = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
)
{
- D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "non-default argument follows default argument" );
+ D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"/\" ','"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "at least one argument must precede /" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20831,34 +20832,27 @@ invalid_lambda_parameters_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"/\" ','"));
}
- { // lambda_param_no_default* '(' ','.lambda_param+ ','? ')'
+ { // (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'"));
- asdl_seq * _gather_178_var;
+ D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'"));
asdl_seq * _loop0_177_var;
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
+ void *_tmp_176_var;
Token * a;
- Token * b;
if (
- (_loop0_177_var = _loop0_177_rule(p)) // lambda_param_no_default*
+ (_tmp_176_var = _tmp_176_rule(p)) // lambda_slash_no_default | lambda_slash_with_default
&&
- (a = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (_gather_178_var = _gather_178_rule(p)) // ','.lambda_param+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','?
+ (_loop0_177_var = _loop0_177_rule(p)) // lambda_param_maybe_default*
&&
- (b = _PyPegen_expect_token(p, 8)) // token=')'
+ (a = _PyPegen_expect_token(p, 17)) // token='/'
)
{
- D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Lambda expression parameters cannot be parenthesized" );
+ D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ may appear only once" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20868,24 +20862,31 @@ invalid_lambda_parameters_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'"));
}
- { // "/" ','
+ { // lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"/\" ','"));
- Token * _literal;
- Token * a;
+ D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default"));
+ asdl_seq * _loop0_178_var;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ arg_ty a;
+ void *invalid_lambda_parameters_helper_var;
if (
- (a = _PyPegen_expect_token(p, 17)) // token='/'
+ (_opt_var = lambda_slash_no_default_rule(p), !p->error_indicator) // lambda_slash_no_default?
&&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ (_loop0_178_var = _loop0_178_rule(p)) // lambda_param_no_default*
+ &&
+ (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper
+ &&
+ (a = lambda_param_no_default_rule(p)) // lambda_param_no_default
)
{
- D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"/\" ','"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "at least one argument must precede /" );
+ D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameter without a default follows parameter with a default" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20895,27 +20896,34 @@ invalid_lambda_parameters_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"/\" ','"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default"));
}
- { // (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'
+ { // lambda_param_no_default* '(' ','.lambda_param+ ','? ')'
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'"));
- asdl_seq * _loop0_181_var;
- void *_tmp_180_var;
+ D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'"));
+ asdl_seq * _gather_180_var;
+ asdl_seq * _loop0_179_var;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
Token * a;
+ Token * b;
if (
- (_tmp_180_var = _tmp_180_rule(p)) // lambda_slash_no_default | lambda_slash_with_default
+ (_loop0_179_var = _loop0_179_rule(p)) // lambda_param_no_default*
+ &&
+ (a = _PyPegen_expect_token(p, 7)) // token='('
&&
- (_loop0_181_var = _loop0_181_rule(p)) // lambda_param_maybe_default*
+ (_gather_180_var = _gather_180_rule(p)) // ','.lambda_param+
&&
- (a = _PyPegen_expect_token(p, 17)) // token='/'
+ (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','?
+ &&
+ (b = _PyPegen_expect_token(p, 8)) // token=')'
)
{
- D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ may appear only once" );
+ D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Lambda expression parameters cannot be parenthesized" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20925,7 +20933,7 @@ invalid_lambda_parameters_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'"));
}
{ // [(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'
if (p->error_indicator) {
@@ -33538,9 +33546,67 @@ _tmp_158_rule(Parser *p)
return _res;
}
-// _loop0_159: param_no_default
+// _tmp_159: slash_no_default | slash_with_default
+static void *
+_tmp_159_rule(Parser *p)
+{
+ if (p->level++ == MAXSTACK) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ }
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // slash_no_default
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default"));
+ asdl_arg_seq* slash_no_default_var;
+ if (
+ (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default"));
+ _res = slash_no_default_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default"));
+ }
+ { // slash_with_default
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
+ SlashWithDefault* slash_with_default_var;
+ if (
+ (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
+ _res = slash_with_default_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default"));
+ }
+ _res = NULL;
+ done:
+ p->level--;
+ return _res;
+}
+
+// _loop0_160: param_maybe_default
static asdl_seq *
-_loop0_159_rule(Parser *p)
+_loop0_160_rule(Parser *p)
{
if (p->level++ == MAXSTACK) {
p->error_indicator = 1;
@@ -33562,18 +33628,18 @@ _loop0_159_rule(Parser *p)
}
Py_ssize_t _children_capacity = 1;
Py_ssize_t _n = 0;
- { // param_no_default
+ { // param_maybe_default
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
- arg_ty param_no_default_var;
+ D(fprintf(stderr, "%*c> _loop0_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default"));
+ NameDefaultPair* param_maybe_default_var;
while (
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
)
{
- _res = param_no_default_var;
+ _res = param_maybe_default_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -33589,8 +33655,8 @@ _loop0_159_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_159[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ D(fprintf(stderr, "%*c%s _loop0_160[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
if (!_seq) {
@@ -33602,14 +33668,14 @@ _loop0_159_rule(Parser *p)
}
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_159_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_160_type, _seq);
p->level--;
return _seq;
}
-// _loop0_160: param_no_default
+// _loop0_161: param_no_default
static asdl_seq *
-_loop0_160_rule(Parser *p)
+_loop0_161_rule(Parser *p)
{
if (p->level++ == MAXSTACK) {
p->error_indicator = 1;
@@ -33636,7 +33702,7 @@ _loop0_160_rule(Parser *p)
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ D(fprintf(stderr, "%*c> _loop0_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
arg_ty param_no_default_var;
while (
(param_no_default_var = param_no_default_rule(p)) // param_no_default
@@ -33658,7 +33724,7 @@ _loop0_160_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_160[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_161[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -33671,14 +33737,14 @@ _loop0_160_rule(Parser *p)
}
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_160_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_161_type, _seq);
p->level--;
return _seq;
}
-// _loop1_161: param_no_default
+// _loop0_162: param_no_default
static asdl_seq *
-_loop1_161_rule(Parser *p)
+_loop0_162_rule(Parser *p)
{
if (p->level++ == MAXSTACK) {
p->error_indicator = 1;
@@ -33705,7 +33771,7 @@ _loop1_161_rule(Parser *p)
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> _loop1_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ D(fprintf(stderr, "%*c> _loop0_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
arg_ty param_no_default_var;
while (
(param_no_default_var = param_no_default_rule(p)) // param_no_default
@@ -33727,14 +33793,9 @@ _loop1_161_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_161[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_162[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
}
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- p->level--;
- return NULL;
- }
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
if (!_seq) {
PyMem_Free(_children);
@@ -33745,72 +33806,14 @@ _loop1_161_rule(Parser *p)
}
for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);
PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_161_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_162_type, _seq);
p->level--;
return _seq;
}
-// _tmp_162: slash_no_default | slash_with_default
-static void *
-_tmp_162_rule(Parser *p)
-{
- if (p->level++ == MAXSTACK) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- }
- if (p->error_indicator) {
- p->level--;
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // slash_no_default
- if (p->error_indicator) {
- p->level--;
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default"));
- asdl_arg_seq* slash_no_default_var;
- if (
- (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default"));
- _res = slash_no_default_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default"));
- }
- { // slash_with_default
- if (p->error_indicator) {
- p->level--;
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
- SlashWithDefault* slash_with_default_var;
- if (
- (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
- _res = slash_with_default_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default"));
- }
- _res = NULL;
- done:
- p->level--;
- return _res;
-}
-
-// _loop0_163: param_maybe_default
+// _loop1_163: param_no_default
static asdl_seq *
-_loop0_163_rule(Parser *p)
+_loop1_163_rule(Parser *p)
{
if (p->level++ == MAXSTACK) {
p->error_indicator = 1;
@@ -33832,18 +33835,18 @@ _loop0_163_rule(Parser *p)
}
Py_ssize_t _children_capacity = 1;
Py_ssize_t _n = 0;
- { // param_maybe_default
+ { // param_no_default
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default"));
- NameDefaultPair* param_maybe_default_var;
+ D(fprintf(stderr, "%*c> _loop1_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ arg_ty param_no_default_var;
while (
- (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
)
{
- _res = param_maybe_default_var;
+ _res = param_no_default_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -33859,8 +33862,13 @@ _loop0_163_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_163[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default"));
+ D(fprintf(stderr, "%*c%s _loop1_163[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ p->level--;
+ return NULL;
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
if (!_seq) {
@@ -33872,7 +33880,7 @@ _loop0_163_rule(Parser *p)
}
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_163_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_163_type, _seq);
p->level--;
return _seq;
}
@@ -34660,9 +34668,67 @@ _loop1_175_rule(Parser *p)
return _seq;
}
-// _loop0_176: lambda_param_no_default
+// _tmp_176: lambda_slash_no_default | lambda_slash_with_default
+static void *
+_tmp_176_rule(Parser *p)
+{
+ if (p->level++ == MAXSTACK) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ }
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // lambda_slash_no_default
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default"));
+ asdl_arg_seq* lambda_slash_no_default_var;
+ if (
+ (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default"));
+ _res = lambda_slash_no_default_var;
+ 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, "lambda_slash_no_default"));
+ }
+ { // lambda_slash_with_default
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
+ SlashWithDefault* lambda_slash_with_default_var;
+ if (
+ (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
+ _res = lambda_slash_with_default_var;
+ 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, "lambda_slash_with_default"));
+ }
+ _res = NULL;
+ done:
+ p->level--;
+ return _res;
+}
+
+// _loop0_177: lambda_param_maybe_default
static asdl_seq *
-_loop0_176_rule(Parser *p)
+_loop0_177_rule(Parser *p)
{
if (p->level++ == MAXSTACK) {
p->error_indicator = 1;
@@ -34684,18 +34750,18 @@ _loop0_176_rule(Parser *p)
}
Py_ssize_t _children_capacity = 1;
Py_ssize_t _n = 0;
- { // lambda_param_no_default
+ { // lambda_param_maybe_default
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
- arg_ty lambda_param_no_default_var;
+ D(fprintf(stderr, "%*c> _loop0_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
+ NameDefaultPair* lambda_param_maybe_default_var;
while (
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
)
{
- _res = lambda_param_no_default_var;
+ _res = lambda_param_maybe_default_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -34711,8 +34777,8 @@ _loop0_176_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_176[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c%s _loop0_177[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
if (!_seq) {
@@ -34724,14 +34790,14 @@ _loop0_176_rule(Parser *p)
}
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_176_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_177_type, _seq);
p->level--;
return _seq;
}
-// _loop0_177: lambda_param_no_default
+// _loop0_178: lambda_param_no_default
static asdl_seq *
-_loop0_177_rule(Parser *p)
+_loop0_178_rule(Parser *p)
{
if (p->level++ == MAXSTACK) {
p->error_indicator = 1;
@@ -34758,7 +34824,7 @@ _loop0_177_rule(Parser *p)
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ D(fprintf(stderr, "%*c> _loop0_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "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
@@ -34780,7 +34846,7 @@ _loop0_177_rule(Parser *p)
_mark = p->mark;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_177[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s _loop0_178[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
@@ -34793,12 +34859,12 @@ _loop0_177_rule(Parser *p)
}
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_177_type, _seq);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_178_type, _seq);
p->level--;
return _seq;
}
-// _loop0_179: ',' lambda_param
+// _loop0_179: lambda_param_no_default
static asdl_seq *
_loop0_179_rule(Parser *p)
{
@@ -34822,27 +34888,18 @@ _loop0_179_rule(Parser *p)
}
Py_ssize_t _children_capacity = 1;
Py_ssize_t _n = 0;
- { // ',' lambda_param
+ { // lambda_param_no_default
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param"));
- Token * _literal;
- arg_ty elem;
+ D(fprintf(stderr, "%*c> _loop0_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ arg_ty lambda_param_no_default_var;
while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = lambda_param_rule(p)) // lambda_param
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
)
{
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- p->level--;
- return NULL;
- }
+ _res = lambda_param_no_default_var;
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -34859,7 +34916,7 @@ _loop0_179_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s _loop0_179[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' lambda_param"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
if (!_seq) {
@@ -34876,107 +34933,7 @@ _loop0_179_rule(Parser *p)
return _seq;
}
-// _gather_178: lambda_param _loop0_179
-static asdl_seq *
-_gather_178_rule(Parser *p)
-{
- if (p->level++ == MAXSTACK) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- }
- if (p->error_indicator) {
- p->level--;
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // lambda_param _loop0_179
- if (p->error_indicator) {
- p->level--;
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_179"));
- arg_ty elem;
- asdl_seq * seq;
- if (
- (elem = lambda_param_rule(p)) // lambda_param
- &&
- (seq = _loop0_179_rule(p)) // _loop0_179
- )
- {
- D(fprintf(stderr, "%*c+ _gather_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_179"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_178[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_179"));
- }
- _res = NULL;
- done:
- p->level--;
- return _res;
-}
-
-// _tmp_180: lambda_slash_no_default | lambda_slash_with_default
-static void *
-_tmp_180_rule(Parser *p)
-{
- if (p->level++ == MAXSTACK) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- }
- if (p->error_indicator) {
- p->level--;
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // lambda_slash_no_default
- if (p->error_indicator) {
- p->level--;
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default"));
- asdl_arg_seq* lambda_slash_no_default_var;
- if (
- (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default"));
- _res = lambda_slash_no_default_var;
- 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, "lambda_slash_no_default"));
- }
- { // lambda_slash_with_default
- if (p->error_indicator) {
- p->level--;
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
- SlashWithDefault* lambda_slash_with_default_var;
- if (
- (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
- _res = lambda_slash_with_default_var;
- 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, "lambda_slash_with_default"));
- }
- _res = NULL;
- done:
- p->level--;
- return _res;
-}
-
-// _loop0_181: lambda_param_maybe_default
+// _loop0_181: ',' lambda_param
static asdl_seq *
_loop0_181_rule(Parser *p)
{
@@ -35000,18 +34957,27 @@ _loop0_181_rule(Parser *p)
}
Py_ssize_t _children_capacity = 1;
Py_ssize_t _n = 0;
- { // lambda_param_maybe_default
+ { // ',' lambda_param
if (p->error_indicator) {
p->level--;
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
- NameDefaultPair* lambda_param_maybe_default_var;
+ D(fprintf(stderr, "%*c> _loop0_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param"));
+ Token * _literal;
+ arg_ty elem;
while (
- (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = lambda_param_rule(p)) // lambda_param
)
{
- _res = lambda_param_maybe_default_var;
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ p->level--;
+ return NULL;
+ }
if (_n == _children_capacity) {
_children_capacity *= 2;
void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
@@ -35028,7 +34994,7 @@ _loop0_181_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s _loop0_181[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' lambda_param"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
if (!_seq) {
@@ -35045,6 +35011,48 @@ _loop0_181_rule(Parser *p)
return _seq;
}
+// _gather_180: lambda_param _loop0_181
+static asdl_seq *
+_gather_180_rule(Parser *p)
+{
+ if (p->level++ == MAXSTACK) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ }
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // lambda_param _loop0_181
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_181"));
+ arg_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = lambda_param_rule(p)) // lambda_param
+ &&
+ (seq = _loop0_181_rule(p)) // _loop0_181
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_181"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_180[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_181"));
+ }
+ _res = NULL;
+ done:
+ p->level--;
+ return _res;
+}
+
// _tmp_182: lambda_slash_no_default | lambda_slash_with_default
static void *
_tmp_182_rule(Parser *p)